Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing SSL config to kafka admin clients #710

Merged
merged 6 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions logprep/connector/confluent_kafka/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ def _kafka_config(self) -> dict:
DEFAULTS.update({"client.id": getfqdn()})
DEFAULTS.update(
{
"group.instance.id": f"{getfqdn().strip('.')}-Pipeline{self.pipeline_index}-pid{os.getpid()}"
"group.instance.id": f"{getfqdn().strip('.')}-"
f"Pipeline{self.pipeline_index}-pid{os.getpid()}"
}
)
return DEFAULTS | self._config.kafka_config | injected_config
Expand All @@ -288,6 +289,9 @@ def _admin(self) -> AdminClient:
confluent_kafka admin client object
"""
admin_config = {"bootstrap.servers": self._config.kafka_config["bootstrap.servers"]}
for key, value in self._config.kafka_config.items():
if key.startswith(("security.", "ssl.")):
admin_config[key] = value
return AdminClient(admin_config)

@cached_property
Expand Down Expand Up @@ -375,7 +379,8 @@ def _commit_callback(
if offset in SPECIAL_OFFSETS:
offset = 0
labels = {
"description": f"topic: {self._config.topic} - partition: {topic_partition.partition}"
"description": f"topic: {self._config.topic} - "
f"partition: {topic_partition.partition}"
}
self.metrics.committed_offsets.add_with_labels(offset, labels)

Expand Down Expand Up @@ -473,7 +478,8 @@ def batch_finished_callback(self) -> None:
"""
if self._enable_auto_offset_store:
return
# in case the ConfluentKafkaInput._revoke_callback is triggered before the first message was polled
# in case the ConfluentKafkaInput._revoke_callback is triggered before the first message
# was polled
if not self._last_valid_record:
return
try:
Expand Down
8 changes: 7 additions & 1 deletion logprep/connector/confluent_kafka/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ def _admin(self) -> AdminClient:
confluent_kafka admin client object
"""
admin_config = {"bootstrap.servers": self._config.kafka_config["bootstrap.servers"]}
for key, value in self._config.kafka_config.items():
if key.startswith(("security.", "ssl.")):
admin_config[key] = value
return AdminClient(admin_config)

@cached_property
Expand Down Expand Up @@ -266,7 +269,10 @@ def describe(self) -> str:

"""
base_description = super().describe()
return f"{base_description} - Kafka Output: {self._config.kafka_config.get('bootstrap.servers')}"
return (
f"{base_description} - Kafka Output: "
f"{self._config.kafka_config.get('bootstrap.servers')}"
)

def store(self, document: dict) -> Optional[bool]:
"""Store a document in the producer topic.
Expand Down
Loading