From 3a035d586d75435726f635bc19c78c4ce467f5ab Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Tue, 12 Dec 2023 20:42:01 +0200 Subject: [PATCH] fix: ServiceMonitor generation (targetPort type and dekorate bump) --- bom/application/pom.xml | 2 +- .../deployment/AddServiceMonitorResourceDecorator.java | 2 +- .../it/kubernetes/KubernetesWithMetricsCustomAbsoluteTest.java | 3 ++- .../it/kubernetes/KubernetesWithMetricsCustomRelativeTest.java | 3 ++- .../it/kubernetes/KubernetesWithMetricsNoAnnotationsTest.java | 3 ++- .../io/quarkus/it/kubernetes/KubernetesWithMetricsTest.java | 3 ++- .../io/quarkus/it/kubernetes/KubernetesWithMicrometerTest.java | 3 ++- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 53ded4c5d5233..485be398dec64 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -164,7 +164,7 @@ 1.7.3 0.27.0 1.6.2 - 4.1.0 + 4.1.1 3.2.0 4.2.0 3.0.2.Final diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddServiceMonitorResourceDecorator.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddServiceMonitorResourceDecorator.java index bc75666b48f15..425377c822541 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddServiceMonitorResourceDecorator.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddServiceMonitorResourceDecorator.java @@ -36,7 +36,7 @@ public void visit(KubernetesListBuilder list) { .endSelector() .addNewEndpoint() .withScheme(scheme) - .withNewTargetPort(targetPort) + .withNewTargetPort(Integer.parseInt(targetPort)) //This needs to be passed as int .withPath(path) .withInterval(interval + "s") .withHonorLabels(honorLabels) diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsCustomAbsoluteTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsCustomAbsoluteTest.java index 65287b49e0d01..38d59234d3081 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsCustomAbsoluteTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsCustomAbsoluteTest.java @@ -92,7 +92,8 @@ public void assertGeneratedResources() throws IOException { assertThat(spec.getEndpoints()).hasSize(1); assertThat(spec.getEndpoints().get(0)).isInstanceOfSatisfying(Endpoint.class, e -> { assertThat(e.getScheme()).isEqualTo("http"); - assertThat(e.getTargetPort().getStrVal()).isEqualTo("9090"); + assertThat(e.getTargetPort().getStrVal()).isNull(); + assertThat(e.getTargetPort().getIntVal()).isEqualTo(9090); assertThat(e.getPath()).isEqualTo("/absolute-metrics"); }); }); diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsCustomRelativeTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsCustomRelativeTest.java index b9b9a113331ac..e12348bea4266 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsCustomRelativeTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsCustomRelativeTest.java @@ -93,7 +93,8 @@ public void assertGeneratedResources() throws IOException { assertThat(spec.getEndpoints()).hasSize(1); assertThat(spec.getEndpoints().get(0)).isInstanceOfSatisfying(Endpoint.class, e -> { assertThat(e.getScheme()).isEqualTo("http"); - assertThat(e.getTargetPort().getStrVal()).isEqualTo("9090"); + assertThat(e.getTargetPort().getStrVal()).isNull(); + assertThat(e.getTargetPort().getIntVal()).isEqualTo(9090); assertThat(e.getPath()).isEqualTo("/q/met"); }); }); diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsNoAnnotationsTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsNoAnnotationsTest.java index aa2d0878db11e..f33973cc55fcb 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsNoAnnotationsTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsNoAnnotationsTest.java @@ -92,7 +92,8 @@ public void assertGeneratedResources() throws IOException { assertThat(spec.getEndpoints()).hasSize(1); assertThat(spec.getEndpoints().get(0)).isInstanceOfSatisfying(Endpoint.class, e -> { assertThat(e.getScheme()).isEqualTo("http"); - assertThat(e.getTargetPort().getStrVal()).isEqualTo("9090"); + assertThat(e.getTargetPort().getStrVal()).isNull(); + assertThat(e.getTargetPort().getIntVal()).isEqualTo(9090); assertThat(e.getPath()).isEqualTo("/q/metrics"); }); }); diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsTest.java index 37c51a12afcdc..f5b8d9bba4067 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMetricsTest.java @@ -95,7 +95,8 @@ public void assertGeneratedResources() throws IOException { assertThat(spec.getEndpoints()).hasSize(1); assertThat(spec.getEndpoints().get(0)).isInstanceOfSatisfying(Endpoint.class, e -> { assertThat(e.getScheme()).isEqualTo("http"); - assertThat(e.getTargetPort().getStrVal()).isEqualTo("9090"); + assertThat(e.getTargetPort().getStrVal()).isNull(); + assertThat(e.getTargetPort().getIntVal()).isEqualTo(9090); assertThat(e.getPath()).isEqualTo("/q/metrics"); }); }); diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMicrometerTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMicrometerTest.java index b41e32d046c14..96b0ca8037269 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMicrometerTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMicrometerTest.java @@ -72,7 +72,8 @@ public void assertGeneratedResources() throws IOException { assertThat(spec.getEndpoints()).hasSize(1); assertThat(spec.getEndpoints().get(0)).isInstanceOfSatisfying(Endpoint.class, e -> { assertThat(e.getScheme()).isEqualTo("http"); - assertThat(e.getTargetPort().getStrVal()).isEqualTo("8080"); + assertThat(e.getTargetPort().getStrVal()).isNull(); + assertThat(e.getTargetPort().getIntVal()).isEqualTo(8080); assertThat(e.getPath()).isEqualTo("/q/metrics"); }); });