Skip to content

Conversation

loicmathieu
Copy link
Contributor

This fixes #5073

This is a draft PR as the Kafka health check is subject to discussion:

  • it instanciate a new AdminClient as the check is on quarkus-kafka-client that didn't provides any Kafka client inside CDI.
  • it uses the (standard) property kafka.bootstrap.servers as a temporary solution : a better solution should be to scan all properties and find the one that defines a Kafka cluster (from mp-messaging or kafka-stream config) and creates an AdminClient for each.
  • it is disabled by default because I think it's the best things to do (see the rational on the issue description).

When #3343 lands in, we must impact the MongoDB health check to check all the mongo clients.

@gastaldi
Copy link
Contributor

gastaldi commented Nov 5, 2019

This looks great.

Here is an idea: would it be possible to enable them automatically if the quarkus-smallrye-health extension is present? I think this would save the developer the trouble of having to define the health=enabled flag for these services.

@gastaldi
Copy link
Contributor

gastaldi commented Nov 5, 2019

Ah ignore my idea, I think you already do that :) Awesome!

@ConfigRoot(name = "neo4j", phase = ConfigPhase.BUILD_TIME)
public class Neo4jBuildTimeConfig {
/**
* Whether or not an healt check is published in case the smallrye-health extension is present (default to true).
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can remove the (default to true) from the description. It will be automatically picked from ConfigItem during doc generation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes but the JavaDoc is also usefull for Quarkus developpers :)
Maybe I could but best is to make it after to keep all health check enabled comments the same (agroal, these 3 new ones, kafka-streams)

@loicmathieu
Copy link
Contributor Author

@gunnarmorling can you review the Kafka health check implementation and some question I raised inside the PR description ?

driver.verifyConnectivity();
return builder.build();
} catch (Exception e) {
return builder.down().withData("reason", e.getMessage()).build();
Copy link
Contributor

@jmartisk jmartisk Nov 14, 2019

Choose a reason for hiding this comment

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

Not that it matters much, so just nitpicking that it is a little weird if you first call up() and then change it to down(). To me reading this, the first impression was "So this always returns 'up', why?". You could call up() only after verifyConnectivity() passes. Otherwise a big +1 from me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This constuct is inspired by the Agroal health check because of multiple datasource support. When we will support multiple MongoDB connection/ Kafka connection / ... this construct will be needed (because you will fails the health check if one of the multiple connection fails).
So better keep it this way.

@loicmathieu
Copy link
Contributor Author

Can someone review the Kafka part and gives feedback of the fact that I choose to disabled the health check by default (rational is in the issue description)? Maybe @gunnarmorling or @cescoffier ?

Copy link
Contributor

@gunnarmorling gunnarmorling left a comment

Choose a reason for hiding this comment

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

Nice work, @loicmathieu; a few comments on the Kafka part.

@loicmathieu loicmathieu force-pushed the feat/mongodb-kafka-neo4j-health branch from 4d8f254 to d3c1314 Compare November 29, 2019 10:14
@loicmathieu loicmathieu marked this pull request as ready for review November 29, 2019 10:16
@gsmet
Copy link
Member

gsmet commented Nov 29, 2019

Just a heads up that I started a review of this one.

I'm working on the Qute PR today but will get back to this one soon.

@loicmathieu
Copy link
Contributor Author

@gunnarmorling WDYT regarding my latests comments on this PR?

@loicmathieu loicmathieu force-pushed the feat/mongodb-kafka-neo4j-health branch from d3c1314 to 3043525 Compare December 4, 2019 13:22
@loicmathieu loicmathieu added this to the 1.1.0 milestone Dec 6, 2019
@loicmathieu loicmathieu force-pushed the feat/mongodb-kafka-neo4j-health branch from 3043525 to c033695 Compare December 6, 2019 11:36
@loicmathieu
Copy link
Contributor Author

I rebase on master to fix a conflict.

@gsmet did you have time to review it as you intended ?

@gsmet gsmet force-pushed the feat/mongodb-kafka-neo4j-health branch from c033695 to 94b59e3 Compare December 8, 2019 11:18
@gsmet
Copy link
Member

gsmet commented Dec 8, 2019

I adjusted a few things.


So when you access the `/health/ready` endpoint of your application you will have information about the connection validation status.

This behavior can be disabled via the property `quarkus.mongodb.health.enabled`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This behavior can be disabled via the property `quarkus.mongodb.health.enabled`.
This behavior can be disabled by setting the property `quarkus.mongodb.health.enabled` to `false` in your `application.properties`.

Same for the others.

@ConfigRoot(name = "kafka", phase = ConfigPhase.BUILD_TIME)
public class KafkaBuildTimeConfig {
/**
* Whether or not an health check is published in case the smallrye-health extension is present (default to false).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Whether or not an health check is published in case the smallrye-health extension is present (default to false).
* Whether or not an health check is published in case the smallrye-health extension is present (defaults to false).

@gsmet gsmet merged commit b76f837 into quarkusio:master Dec 8, 2019
@gsmet
Copy link
Member

gsmet commented Dec 8, 2019

Merged, thanks.

@loicmathieu
Copy link
Contributor Author

@gsmet you move the bootstrap server property from the standard one to a quarkus specific one.
According to me it's an issue as the standard one is already used when using smallrye-reactive-messaging Kafka (as it uses standard producer and consumer properties).
So if a user uses the quarkus-smallrye-reactive-messaging-kafka extension it will needs to provides the boostrap-server in two properties: a quarkus one and a standard one.

@loicmathieu loicmathieu deleted the feat/mongodb-kafka-neo4j-health branch December 9, 2019 09:37
@gsmet gsmet changed the title Add health check for mongodb, kafka and neo4j Add health checks for Mongodb, Kafka and Neo4j Dec 9, 2019
@zeljkot
Copy link

zeljkot commented Jan 11, 2020

Having two separate properties for reactive streams and health is very confusing. The need for additional property in "Guides" can be easily overlooked. Please emphasize that in the documentation, or add all messaging bootstrap servers automatically. IMHO health check should not be general Kafka health check, but rather reactive messaging specific one; otherwise, whoever writes a Kafka client should somehow register it with health check functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provides extension HealthCheck for MongoDB, Neo4j and Kafka

7 participants