From adb04e996d20c77c5e9edbf089afe5b68265a148 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 3 May 2023 11:43:33 +0200 Subject: [PATCH] Fix completion mode field when creating a K8s Job resource and Flyway Fix https://github.com/quarkusio/quarkus/issues/33085 --- .../deployment/CreateJobResourceFromImageDecorator.java | 6 ++++-- .../quarkus/it/kubernetes/KubernetesWithFlywayInitTest.java | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/CreateJobResourceFromImageDecorator.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/CreateJobResourceFromImageDecorator.java index 307f810095ece..c69ca855c51a5 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/CreateJobResourceFromImageDecorator.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/CreateJobResourceFromImageDecorator.java @@ -6,6 +6,8 @@ import java.util.List; +import io.dekorate.kubernetes.annotation.JobCompletionMode; +import io.dekorate.kubernetes.annotation.JobRestartPolicy; import io.dekorate.kubernetes.decorator.ResourceProvidingDecorator; import io.fabric8.kubernetes.api.model.KubernetesListBuilder; import io.fabric8.kubernetes.api.model.batch.v1.JobBuilder; @@ -15,8 +17,8 @@ **/ public class CreateJobResourceFromImageDecorator extends ResourceProvidingDecorator { - private static final String DEFAULT_RESTART_POLICY = "OnFailure"; - private static final String DEFAULT_COMPLETION_MODE = "OnFailure"; + private static final String DEFAULT_RESTART_POLICY = JobRestartPolicy.OnFailure.name(); + private static final String DEFAULT_COMPLETION_MODE = JobCompletionMode.NonIndexed.name(); private final String name; private final String image; diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithFlywayInitTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithFlywayInitTest.java index 827c7b3c0c7f6..328352faae67f 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithFlywayInitTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithFlywayInitTest.java @@ -79,8 +79,10 @@ public void assertGeneratedResources() throws IOException { assertThat(job.get()).satisfies(j -> { assertThat(j.getSpec()).satisfies(jobSpec -> { + assertThat(jobSpec.getCompletionMode()).isEqualTo("NonIndexed"); assertThat(jobSpec.getTemplate()).satisfies(t -> { assertThat(t.getSpec()).satisfies(podSpec -> { + assertThat(podSpec.getRestartPolicy()).isEqualTo("OnFailure"); assertThat(podSpec.getContainers()).singleElement().satisfies(container -> { assertThat(container.getName()).isEqualTo("flyway-init"); assertThat(container.getEnv()).filteredOn(env -> "QUARKUS_FLYWAY_ENABLED".equals(env.getName()))