quarkiverse / quarkus-antivirus

Virus scan files using ClamAV or VirusTotal
https://www.clamav.net/
Apache License 2.0
9 stars 3 forks source link

Health config at build time #38

Closed silviu-negoita closed 6 months ago

silviu-negoita commented 6 months ago

Hello,

Any idea if you can move the health configuration from build time to runtime? It is a bit strange that you configure for example quarkus.antivirus.clamav.enabled=false at runtime (depending on your deployment environment), but health will fail since you cannot control it via quarkus.antivirus.clamav.health.enabled since it is at build time. I am now forced to build different images with antivirus enabled and disabled, since one of our environments has no clamav available.

Thanks, Silviu

melloware commented 6 months ago

@silviu-negoita great report! I will fix it. I was just being lazy or stupid 😄

melloware commented 6 months ago

actually @silviu-negoita i am looking at other Quarkus Extensions and the HealthCheck Enabled is always a BuildTime config not a run time config?

Kafka: https://github.com/quarkusio/quarkus/blob/1323185d39314126ea3703d3712a7580c91ed60c/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java#L469-L472

MongoDB: https://github.com/quarkusio/quarkus/blob/1323185d39314126ea3703d3712a7580c91ed60c/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java#L427-L430

melloware commented 6 months ago

I spoke to the Quarkus devs and they said this concern has been raised by others as well: https://stackoverflow.com/questions/78296786/is-there-any-way-to-disable-or-override-the-default-readiness-in-quarkushealth/78297736#78297736

So it seems like HealthChecks were baked into the core at BuildTime for now.

melloware commented 6 months ago

@all-contributors add @silviu-negoita for ideas, bug

allcontributors[bot] commented 6 months ago

@melloware

I've put up a pull request to add @silviu-negoita! :tada:

melloware commented 6 months ago

@silviu-negoita can you try this?

Can you also try quarkus.smallrye-health.check."my-health-check".enabled=false maybe for your use case? where my-health-check is ClamAV?

melloware commented 6 months ago

@silviu-negoita did you get a chance to try the above config?

silviu-negoita commented 6 months ago

smallrye-health

Hello! Thank you for looking into this.

I just tried this config (i'm using yml)

quarkus:
  smallrye-health:
    check:
      clamav:
        enabled: false/true

It has no effect over my health report. Health reacts only on quarkus.antivirus.clamav.health.enabled.

xstefank commented 6 months ago

EDIT: Sorry @melloware, I forgot it needs to be full classname. So updating this.

@silviu-negoita can you try:

quarkus.smallrye-health.check."io.quarkiverse.antivirus.runtime.ClamAVHealthCheck".enabled=false

Should work.

silviu-negoita commented 6 months ago

EDIT: Sorry @melloware, I forgot it needs to be full classname. So updating this.

@silviu-negoita can you try:

quarkus.smallrye-health.check."io.quarkiverse.antivirus.runtime.ClamAVHealthCheck".enabled=false

Should work.

yup, it works with:

quarkus:
  smallrye-health:
    check:
      "io.quarkiverse.antivirus.runtime.ClamAVHealthCheck":
        enabled: false

It seems this config has priority over quarkus.antivirus.clamav.enabled. I will use this as a workaround, thanks!

melloware commented 6 months ago

i am going to update the docs with this!

melloware commented 6 months ago

@all-contributors add @xstefank for question

allcontributors[bot] commented 6 months ago

@melloware

I've put up a pull request to add @xstefank! :tada: