-
Notifications
You must be signed in to change notification settings - Fork 602
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
MP health 2.0 check with CDI producers fails #7995
Comments
The example in the spec annotates the methods with @ApplicationScoped which you don’t have. I’m wondering if that makes a difference: @ApplicationScoped
class MyChecks {
@Produces
@ApplicationScoped
@Liveness
HealthCheck check1() {
return () -> HealthStatus.state(getMemUsage() < 0.9);
}
@Produces
@ApplicationScoped
@Readiness
HealthCheck check2() {
return () -> HealthStatus.state(getCpuUsage() < 0.9);
}
}} |
... no, that also doesn't work. From a CDI perspective, annotating both also doesn't make a difference scope-wise (also doesn't really make sense IMO). |
Our implementation passed the TCK. This is one of the test https://github.com/eclipse/microprofile-health/blob/c505362dc6d9f02a9c46c88f5ff56b16cd90337e/tck/src/main/java/org/eclipse/microprofile/health/tck/deployment/SuccessfulReadiness.java. @Emily-Jiang Can you help to see if this is a CDI problem? |
@fmhwong Btw, the test verifies a CDI application-scoped bean, not a CDI producer... |
Hi @fmhwong I think this is an issue with mpHealth caused by the line of code here: https://github.com/OpenLiberty/open-liberty/blob/integration/dev/com.ibm.ws.microprofile.health.2.0/src/com/ibm/ws/microprofile/health20/services/impl/HealthCheck20CDIBeanInvokerImpl.java#L134 At this point in the code you do this:
The The second argument to
As a side note, as @sdaschner points out, the test you link doesn't test a Producer method and furthermore I can't see any tests for health check beans created through a producer method. We should add a FAT test for this to liberty and raise a spec issue to get one added to the TCK. |
Thanks @Azquelt |
@Azquelt @sdaschner Do you think this is a must fix before GA? |
@fmhwong Good question, which depends how important we evaluate mpHealth in general (in my projects, I haven't seen too much use of it b/c of the current limitations in cloud-native environments). If folks are using mpHealth in a more complex way then yes, they would expect it to work properly, but at least, due to the error, they don't get false positives. |
@Channyboy I see that you made the change in the Health 2.0 code. Is there a reason you didn't also make the same change in the corresponding file for Health 1.x? Does this problem not also exist there? |
The HealthCheck procedures being defined as CDI Producers was added to the mpHealth-2.0 spec (https://github.com/eclipse/microprofile-health/blob/2.0-RC1/spec/src/main/asciidoc/java-api.adoc) and but was not part of the mpHealth-1.0 spec (https://github.com/eclipse/microprofile-health/blob/1.0/spec/src/main/asciidoc/java-api.adoc). |
Created a follow-up issue to add a test case in our FATs: #8255 |
This is not true. The
Beans created by producer methods are still beans (though note that it's the producer method, not the class of the returned object, which would need to be annotated with |
Defining a mp-health check as CDI producer fails at deployment.
The following, taken from the samples:
... results in ...
Tested with
Open Liberty 19.0.0.7/wlp-1.0.30.cl190720190623-0300
on OpenJ9, version12.0.1+12
and featurempHealth-2.0
.The text was updated successfully, but these errors were encountered: