From d4c724b11ae0b01467b4942f61f9acf45ec120d9 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 (cherry picked from commit c808a4ffd46cda9e2c30b7021c3c4c8b9508c160) --- .../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 a8689796a425e..6dfdf57540b47 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 @@ -175,7 +175,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 f2cf12fe65613..b6dd77db59288 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