From 4f60e55944782a9960d5ae39edea9504b2a938c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:31:26 +0100 Subject: [PATCH 1/7] chore(deps): bump log4j.version from 2.24.2 to 2.24.3 Bumps `log4j.version` from 2.24.2 to 2.24.3. Updates `org.apache.logging.log4j:log4j-slf4j2-impl` from 2.24.2 to 2.24.3 Updates `org.apache.logging.log4j:log4j-core` from 2.24.2 to 2.24.3 Updates `org.apache.logging.log4j:log4j-api` from 2.24.2 to 2.24.3 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-slf4j2-impl dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.logging.log4j:log4j-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8e5489053f..57c3a5a7e5 100644 --- a/pom.xml +++ b/pom.xml @@ -126,7 +126,7 @@ 1.3.0 8.0.1 2.0.16 - 2.24.2 + 2.24.3 1.18.36 1.27.1 2.18.0 From b6913bef3429033c18176ea7665a8c2e7e64136a Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 16 Dec 2024 15:06:00 +0100 Subject: [PATCH 2/7] test: improve async reliability of AbstractHttpClientNewWebSocketBuilderTest Signed-off-by: Marc Nuri --- .../client/http/AbstractHttpClientNewWebSocketBuilderTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpClientNewWebSocketBuilderTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpClientNewWebSocketBuilderTest.java index fd24e7e66c..087c77a9f1 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpClientNewWebSocketBuilderTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpClientNewWebSocketBuilderTest.java @@ -98,7 +98,7 @@ void buildAsyncReceivesMultipleMessages() throws Exception { .always(); final CountDownLatch latch = new CountDownLatch(2); final Set messages = ConcurrentHashMap.newKeySet(); - final WebSocket ws = httpClient.newWebSocketBuilder() + httpClient.newWebSocketBuilder() .uri(URI.create(server.url("/websocket-multiple-message"))) .buildAsync(new WebSocket.Listener() { @Override @@ -157,6 +157,7 @@ void buildAsyncIncludesRequiredHeaders() throws Exception { server.expect().withPath("/websocket-headers-test") .andUpgradeToWebSocket() .open() + .waitFor(50L).andEmit("OK") .done() .always(); httpClient.newWebSocketBuilder() From 6aa1076a15fdcfa4969e3bcc75e0427e832b5e29 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 16 Dec 2024 18:24:29 +0100 Subject: [PATCH 3/7] test: set content length = 0 in abstract simultaneous connections test Signed-off-by: Marc Nuri --- .../client/http/AbstractSimultaneousConnectionsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java index 69d346eda4..d06a7bc58e 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java @@ -96,7 +96,7 @@ private void withHttp1() { @DisabledOnOs(OS.WINDOWS) public void http1Connections() throws Exception { final DelayedResponseHandler handler = new DelayedResponseHandler(MAX_HTTP_1_CONNECTIONS, - exchange -> exchange.sendResponseHeaders(204, -1)); + exchange -> exchange.sendResponseHeaders(204, 0)); httpServer.createContext("/http", handler); try (final HttpClient client = clientBuilder.build()) { final Collection>> asyncResponses = ConcurrentHashMap.newKeySet(); From 65df6b22a4f0197a2fb9783c12fd5d680ef123f6 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 16 Dec 2024 19:38:20 +0100 Subject: [PATCH 4/7] test: close exchange on AbstractSimultaneousConnectionsTest Signed-off-by: Marc Nuri --- .../client/http/AbstractSimultaneousConnectionsTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java index d06a7bc58e..998233f952 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractSimultaneousConnectionsTest.java @@ -96,7 +96,10 @@ private void withHttp1() { @DisabledOnOs(OS.WINDOWS) public void http1Connections() throws Exception { final DelayedResponseHandler handler = new DelayedResponseHandler(MAX_HTTP_1_CONNECTIONS, - exchange -> exchange.sendResponseHeaders(204, 0)); + exchange -> { + exchange.sendResponseHeaders(204, -1); + exchange.close(); + }); httpServer.createContext("/http", handler); try (final HttpClient client = clientBuilder.build()) { final Collection>> asyncResponses = ConcurrentHashMap.newKeySet(); From a09d1c1403f0484d903f7e1ebcaabb05d7e724a5 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 16 Dec 2024 20:00:51 +0100 Subject: [PATCH 5/7] ci: temporarily disable parallel build Signed-off-by: Marc Nuri --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d53ab0bac6..2e4384edd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,8 @@ jobs: java-version: ${{ matrix.java }} distribution: 'temurin' - name: Build Project - run: make install MAVEN_ARGS="${MAVEN_ARGS}" + #run: make install MAVEN_ARGS="${MAVEN_ARGS}" + run: mvn ${MAVEN_ARGS} install - name: Check java-generator CLI run: | From 03439f22dda019cb582a3181d32d380098178686 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 16 Dec 2024 21:46:43 +0100 Subject: [PATCH 6/7] fix(vertx): VertxHttpClientFactory reuses the same Vertx instance for each VertxHttpClient instance Signed-off-by: Marc Nuri --- CHANGELOG.md | 5 ++ .../client/vertx/VertxHttpClientFactory.java | 61 ++++++++++++------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 967a3902ee..9fb629faa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ #### _**Note**_: Breaking changes +### 7.0.1 (TBD) + +#### Bugs + +* Fix #6709: VertxHttpClientFactory reuses the same Vertx instance for each VertxHttpClient instance ### 7.0.0 (2024-12-03) diff --git a/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientFactory.java b/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientFactory.java index c0e70a0e56..c5d969aaf2 100644 --- a/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientFactory.java +++ b/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientFactory.java @@ -25,10 +25,47 @@ public class VertxHttpClientFactory implements io.fabric8.kubernetes.client.http.HttpClient.Factory { + private static final class VertxHolder { + + private static final Vertx INSTANCE = createVertxInstance(); + + private static synchronized Vertx createVertxInstance() { + // We must disable the async DNS resolver as it can cause issues when resolving the Vault instance. + // This is done using the DISABLE_DNS_RESOLVER_PROP_NAME system property. + // The DNS resolver used by vert.x is configured during the (synchronous) initialization. + // So, we just need to disable the async resolver around the Vert.x instance creation. + final String originalValue = System.getProperty(DISABLE_DNS_RESOLVER_PROP_NAME); + Vertx vertx; + try { + System.setProperty(DISABLE_DNS_RESOLVER_PROP_NAME, "true"); + vertx = Vertx.vertx(new VertxOptions() + .setFileSystemOptions(new FileSystemOptions().setFileCachingEnabled(false).setClassPathResolvingEnabled(false)) + .setUseDaemonThread(true)); + } finally { + // Restore the original value + if (originalValue == null) { + System.clearProperty(DISABLE_DNS_RESOLVER_PROP_NAME); + } else { + System.setProperty(DISABLE_DNS_RESOLVER_PROP_NAME, originalValue); + } + } + return vertx; + } + } + private final Vertx vertx; public VertxHttpClientFactory() { - this.vertx = createVertxInstance(); + this(VertxHolder.INSTANCE); + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + if (vertx != null) { + vertx.close(); + } + })); + } + + public VertxHttpClientFactory(Vertx vertx) { + this.vertx = vertx; } @Override @@ -36,28 +73,6 @@ public VertxHttpClientBuilder newBuilder() { return new VertxHttpClientBuilder<>(this, vertx); } - private static synchronized Vertx createVertxInstance() { - // We must disable the async DNS resolver as it can cause issues when resolving the Vault instance. - // This is done using the DISABLE_DNS_RESOLVER_PROP_NAME system property. - // The DNS resolver used by vert.x is configured during the (synchronous) initialization. - // So, we just need to disable the async resolver around the Vert.x instance creation. - final String originalValue = System.getProperty(DISABLE_DNS_RESOLVER_PROP_NAME); - Vertx vertx; - try { - System.setProperty(DISABLE_DNS_RESOLVER_PROP_NAME, "true"); - vertx = Vertx.vertx(new VertxOptions() - .setFileSystemOptions(new FileSystemOptions().setFileCachingEnabled(false).setClassPathResolvingEnabled(false))); - } finally { - // Restore the original value - if (originalValue == null) { - System.clearProperty(DISABLE_DNS_RESOLVER_PROP_NAME); - } else { - System.setProperty(DISABLE_DNS_RESOLVER_PROP_NAME, originalValue); - } - } - return vertx; - } - /** * Additional configuration to be applied to the options after the {@link Config} has been processed. */ From 6c7e7505aee6212c7f0b148ec849fc74956925d2 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 16 Dec 2024 22:48:24 +0100 Subject: [PATCH 7/7] test: improve http client failure test performance (disable retry) Signed-off-by: Marc Nuri --- .../fabric8/kubernetes/client/http/AbstractHttpPostTest.java | 4 +++- .../fabric8/kubernetes/client/http/AbstractHttpPutTest.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPostTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPostTest.java index 50866bc85c..0896f9cf50 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPostTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPostTest.java @@ -15,6 +15,7 @@ */ package io.fabric8.kubernetes.client.http; +import io.fabric8.kubernetes.client.RequestConfigBuilder; import io.fabric8.mockwebserver.DefaultMockServer; import io.fabric8.mockwebserver.http.RecordedRequest; import org.junit.jupiter.api.AfterAll; @@ -161,7 +162,8 @@ public void expectContinue() throws Exception { public void expectFailure() throws IOException, URISyntaxException { try (final ServerSocket serverSocket = new ServerSocket(0)) { - try (HttpClient client = getHttpClientFactory().newBuilder().build()) { + try (HttpClient client = getHttpClientFactory().newBuilder() + .tag(new RequestConfigBuilder().withRequestRetryBackoffLimit(0).build()).build()) { final URI uri = uriForPath(serverSocket, "/post-failing"); serverSocket.close(); diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPutTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPutTest.java index 9bcbae7187..d902786a51 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPutTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractHttpPutTest.java @@ -15,6 +15,7 @@ */ package io.fabric8.kubernetes.client.http; +import io.fabric8.kubernetes.client.RequestConfigBuilder; import io.fabric8.mockwebserver.DefaultMockServer; import io.fabric8.mockwebserver.http.RecordedRequest; import org.junit.jupiter.api.AfterAll; @@ -97,7 +98,8 @@ public void putInputStreamBody() throws Exception { public void expectFailure() throws IOException, URISyntaxException { try (final ServerSocket serverSocket = new ServerSocket(0)) { - try (HttpClient client = getHttpClientFactory().newBuilder().build()) { + try (HttpClient client = getHttpClientFactory().newBuilder() + .tag(new RequestConfigBuilder().withRequestRetryBackoffLimit(0).build()).build()) { final URI uri = uriForPath(serverSocket, "/put-failing"); serverSocket.close();