quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.55k stars 2.62k forks source link

The flyway extension generates Kubernetes resources as if quarkus.flyway.enabled was a runtime property #37040

Open PierreBtz opened 10 months ago

PierreBtz commented 10 months ago

Describe the bug

I noticed that when generating Kubernetes resource with the flyway extension in the classpath, an initialization task is created (as expected), but then the main container containing the application defines the QUARKUS_FLYWAY_ENABLED as false, which cannot have any effect since the quarkus.flyway.enabled is now a build time property.

Expected behavior

Either the variable is removed if it's useless anymore, or the logic is changed.

Actual behavior

With the variable set, at startup, Quarkus will warn that a change on a build property has no effect at runtime. I cannot say if it breaks a previous workflow since I detected this while playing around with the extension, I suspect it's not breaking anything but it's not optimal since migration logic will try to run in any application container.

How to Reproduce?

To reproduce:

    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: QUARKUS_FLYWAY_ENABLED
              value: "false"

Output of uname -a or ver

Darwin ** 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64

Output of java -version

openjdk version "17.0.4" 2022-07-19 OpenJDK Runtime Environment Temurin-17.0.4+8 (build 17.0.4+8) OpenJDK 64-Bit Server VM Temurin-17.0.4+8 (build 17.0.4+8, mixed mode)

Quarkus version or git rev

3.5.1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)

Additional information

Note that the same is true for the init task (which sets the variable to true):

- env:
    - name: QUARKUS_INIT_AND_EXIT
      value: "true"
    - name: QUARKUS_FLYWAY_ENABLED
      value: "true"
quarkus-bot[bot] commented 10 months ago

/cc @cristhiank (flyway), @gastaldi (flyway), @geoand (flyway,kubernetes), @gsmet (flyway), @iocanel (kubernetes)

PierreBtz commented 9 months ago

Hey folks, gentle ping. Let me know if you need more details.

phillipvanheerden commented 8 months ago

I was wondering why my <project>-flyway-init container wasn't doing anything.

After reading this issue, I ended up setting quarkus.flyway.migrate-at-start=true in application.properties and changing the environment variable in the generated manifests from QUARKUS_FLYWAY_ENABLED to QUARKUS_FLYWAY_ACTIVE and that did the trick.

So looks like we might need to make a small fix to the quarkus-flyway extension (or quarkus-kubernetes, had a quick look and I'm not too sure which is responsible for the manifests) if I'm understanding the situation correctly?

edit: found it https://github.com/quarkusio/quarkus/blob/6884f92c3cfb4b0d18262477920311b533f7e5e4/extensions/flyway/deployment/src/main/java/io/quarkus/flyway/deployment/FlywayProcessor.java#L270

anchialas commented 7 months ago

As a workaround, set this in your application.properties:

 quarkus.flyway.migrate-at-start=${QUARKUS_FLYWAY_ENABLED:true}
jbgomond commented 2 months ago

Hi, this is still a thing. Should it be QUARKUS_FLYWAY_ACTIVE now ?