Skip to content

Conversation

@janosbabik
Copy link
Contributor

This PR introduces a health check HTTP endpoint to the online ingestor, allowing external monitoring of the service's connectivity to Kafka, storage, and SciCat.

@janosbabik janosbabik marked this pull request as draft November 25, 2025 16:18
@janosbabik janosbabik marked this pull request as ready for review November 26, 2025 14:31
def _check_kafka(self) -> bool:
"""Check if Kafka is reachable."""
try:
self.consumer.list_topics(timeout=5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if kafka consumer is thread safe.
Should we use threading.Lock?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... maybe it's okay as we're not consuming messages here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I will do some research on this and keep you updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the confluent-kafka-python library uses librdkafka, which is thread safe according to its documentation. The list_topics() calls librdkafka.rd_kafka_metadata() function which is unrelated to reading messages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you for letting me know : D

Copy link
Contributor

@YooSunYoung YooSunYoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, apart from the minor concer about using the consumer in the other thread.

@janosbabik
Copy link
Contributor Author

It looks good to me, apart from the minor concer about using the consumer in the other thread.

Hi @YooSunYoung, I added a new “stress” test script that sends Kafka messages to the online ingestor and, in parallel, continuously calls the health endpoint to see how the app handles it. Based on what I saw in the kafka library and from this test, I’m more confident in the threadsafety. ref: #207 (comment)

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.

4 participants