Skip to content

Commit 36d08fa

Browse files
committed
[JENKINS-67664] Adapt to kubernetes-client changes
InterruptedException is no longer thrown on websocket timeout, rather a KubernetesClientException. Unfortunately there is no way to differentiate between a timeout and an error. * fabric8io/kubernetes-client#3274 * fabric8io/kubernetes-client#3197
1 parent 85e0d7e commit 36d08fa

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
import hudson.AbortException;
4747
import io.fabric8.kubernetes.api.model.Container;
48-
import org.apache.commons.io.output.NullOutputStream;
4948
import org.apache.commons.io.output.TeeOutputStream;
5049
import org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate;
5150
import org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave;
@@ -64,7 +63,6 @@
6463
import io.fabric8.kubernetes.client.dsl.ExecListener;
6564
import io.fabric8.kubernetes.client.dsl.ExecWatch;
6665
import io.fabric8.kubernetes.client.dsl.Execable;
67-
import okhttp3.Response;
6866

6967
import static org.csanchez.jenkins.plugins.kubernetes.pipeline.Constants.EXIT;
7068

@@ -427,19 +425,10 @@ public void onClose(int i, String s) {
427425
try {
428426
watch = execable.exec(sh);
429427
} catch (KubernetesClientException e) {
430-
if (e.getCause() instanceof InterruptedException) {
431-
throw new IOException(
432-
"Interrupted while starting websocket connection, you should increase the Max connections to Kubernetes API",
433-
e);
434-
} else {
435-
throw e;
436-
}
437-
} catch (RejectedExecutionException e) {
438-
throw new IOException(
439-
"Connection was rejected, you should increase the Max connections to Kubernetes API", e);
428+
throw new IOException("Unable to perform kubernetes execution, you should consider increasing the Max connections to Kubernetes API", e);
440429
}
441430

442-
boolean hasStarted = false;
431+
boolean hasStarted;
443432
try {
444433
// prevent a wait forever if the connection is closed as the listener would never be called
445434
hasStarted = started.await(WEBSOCKET_CONNECTION_TIMEOUT, TimeUnit.SECONDS);

0 commit comments

Comments
 (0)