Skip to content

feat: broker connect validation#198

Open
tknikita wants to merge 1 commit intoStephenSorriaux:masterfrom
tknikita:fix/broker-validation-in-manager
Open

feat: broker connect validation#198
tknikita wants to merge 1 commit intoStephenSorriaux:masterfrom
tknikita:fix/broker-validation-in-manager

Conversation

@tknikita
Copy link

Description:
This PR adds broker connection validation to the KafkaManager class to prevent indefinite hanging when the Kafka broker is unreachable.

Changes:

  • Added connection check to at least one broker before proceeding with operations
  • Validates broker availability by checking self.client.cluster.brokers()
  • Iterates through available brokers and attempts connection using connection_check()
  • Raises UnableToRefreshState exception with descriptive error messages when:
    • No brokers are available
    • Unable to connect to any broker
  • Includes helpful troubleshooting information in error messages (bootstrap servers, security protocol)
  • Properly closes the client connection before raising exceptions

Files Modified:

  • module_utils/kafka_manager.py (+28 lines)

Benefits:

  • Prevents indefinite hanging when Kafka server is unreachable
  • Provides clear, actionable error messages for connection failures
  • Improves debugging experience by indicating whether the issue is broker availability or connection configuration

@tknikita tknikita marked this pull request as ready for review February 10, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant