From c808a4ffd46cda9e2c30b7021c3c4c8b9508c160 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 5 Jul 2022 15:54:40 +0300 Subject: [PATCH] Ensure that labels for different k8s targets don't interfere with each other Fixes: #26516 --- .../io/quarkus/kubernetes/deployment/KnativeProcessor.java | 3 ++- .../quarkus/kubernetes/deployment/OpenshiftProcessor.java | 6 ++++-- .../src/test/resources/openshift-v3.properties | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeProcessor.java index c8dcc373edc3d..072ed10cc3b98 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeProcessor.java @@ -172,7 +172,8 @@ public List createDecorators(ApplicationInfoBuildItem applic }); if (config.clusterLocal) { - if (labels.stream().noneMatch(l -> l.getKey().equals(KNATIVE_DEV_VISIBILITY))) { + if (labels.stream().filter(l -> KNATIVE.equals(l.getTarget())) + .noneMatch(l -> l.getKey().equals(KNATIVE_DEV_VISIBILITY))) { result.add(new DecoratorBuildItem(KNATIVE, new AddLabelDecorator(name, KNATIVE_DEV_VISIBILITY, "cluster-local"))); } diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java index 3911a4e659647..3041b38397172 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java @@ -198,7 +198,8 @@ public List createDecorators(ApplicationInfoBuildItem applic if (config.flavor == v3) { //Openshift 3.x doesn't recognize 'app.kubernetes.io/name', it uses 'app' instead. //The decorator will be applied even on non-openshift resources is it may affect for example: knative - if (labels.stream().noneMatch(l -> l.getKey().equals(OPENSHIFT_V3_APP))) { + if (labels.stream().filter(l -> OPENSHIFT.equals(l.getTarget())) + .noneMatch(l -> l.getKey().equals(OPENSHIFT_V3_APP))) { result.add(new DecoratorBuildItem(new AddLabelDecorator(name, OPENSHIFT_V3_APP, name))); } @@ -250,7 +251,8 @@ public List createDecorators(ApplicationInfoBuildItem applic result.add(new DecoratorBuildItem(OPENSHIFT, new ApplyImagePullPolicyDecorator(name, config.getImagePullPolicy()))); - if (labels.stream().noneMatch(l -> l.getKey().equals(OPENSHIFT_APP_RUNTIME))) { + if (labels.stream().filter(l -> OPENSHIFT.equals(l.getTarget())) + .noneMatch(l -> l.getKey().equals(OPENSHIFT_APP_RUNTIME))) { result.add(new DecoratorBuildItem(OPENSHIFT, new AddLabelDecorator(name, OPENSHIFT_APP_RUNTIME, QUARKUS))); } diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-v3.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-v3.properties index 22bc2bebdb904..dbeb5652f7191 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-v3.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-v3.properties @@ -1,2 +1,4 @@ quarkus.kubernetes.deployment-target=openshift -quarkus.openshift.flavor=v3 \ No newline at end of file +quarkus.openshift.flavor=v3 +# used in order to ensure that the non-openshift label does not interfere with the openshift manifest generation +quarkus.knative.labels."app.openshift.io/runtime"=test