From 628896bd76c524b4b3b6d1e096e6ea537556d12c Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 14 Oct 2024 12:57:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20cURL=20=E6=A0=BC=E5=BC=8F=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/engine/KubernetesProvider.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/engine/KubernetesProvider.java b/backend/services/api-test/src/main/java/io/metersphere/api/engine/KubernetesProvider.java index 65346addbf..037c9f4f98 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/engine/KubernetesProvider.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/engine/KubernetesProvider.java @@ -151,14 +151,14 @@ public class KubernetesProvider { .writingOutput(System.out) .writingError(System.err) .withTTY() - .usingListener(new SimpleListener(runRequest)) + .usingListener(new SimpleListener(runRequest, client)) .exec(SHELL_COMMAND, "-c", command); } catch (Exception e) { LogUtils.error("Failed to execute command on pod {} ", pod.getMetadata().getName(), e); } } - private record SimpleListener(Object runRequest) implements ExecListener { + private record SimpleListener(Object runRequest, KubernetesClient client) implements ExecListener { @Override public void onOpen() { LogUtils.info("K8s 开启监听"); @@ -175,6 +175,8 @@ public class KubernetesProvider { @Override public void onClose(int code, String reason) { LogUtils.info("K8s 监听关闭:code=" + code + ", reason=" + reason); + // 关闭客户端 + client.close(); } } @@ -227,7 +229,7 @@ public class KubernetesProvider { "-X POST -d '%s' " + "--connect-timeout %d " + "--max-time %d " + - "--retry-max-time %d" + + "--retry-max-time %d " + "--retry %d " + "%s%s", optToken, // otp-token