From b7ccde1c5ef0f30bf01822fe858e1cb197fcb4bd Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 4 Jun 2019 18:36:58 -0400 Subject: [PATCH 1/6] Verifying that tools do not assume sh is in /bin/sh. --- pom.xml | 4 ++-- .../kubernetes/pipeline/ContainerExecDecorator.java | 2 +- .../kubernetes/pipeline/KubernetesPipelineTest.java | 6 ++++++ .../kubernetes/pipeline/bourneShellElsewhereInPath.groovy | 7 +++++++ 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy diff --git a/pom.xml b/pom.xml index 8e619ba2bf..22f6402ec9 100644 --- a/pom.xml +++ b/pom.xml @@ -91,10 +91,10 @@ 6.7 - + org.jenkins-ci.plugins durable-task - 1.28 + 1.30-SNAPSHOT org.jenkins-ci.plugins diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java index 524adbe2bd..52dd109fb0 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java @@ -85,7 +85,7 @@ public class ContainerExecDecorator extends LauncherDecorator implements Seriali private static final String COOKIE_VAR = "JENKINS_SERVER_COOKIE"; private static final Logger LOGGER = Logger.getLogger(ContainerExecDecorator.class.getName()); - private static final String DEFAULT_SHELL="/bin/sh"; + private static final String DEFAULT_SHELL = "sh"; /** * stdin buffer size for commands sent to Kubernetes exec api. A low value will cause slowness in commands executed. diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java index 58f9453aac..f07c237b3a 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java @@ -191,6 +191,12 @@ public void runInPodWithDifferentShell() throws Exception { r.assertLogContains("/bin/bash: no such file or directory", b); } + @Test + public void bourneShellElsewhereInPath() throws Exception { + r.assertBuildStatusSuccess(r.waitForCompletion(b)); + r.assertLogContains("+ ls -la /", b); + } + @Test public void runInPodWithMultipleContainers() throws Exception { r.assertBuildStatusSuccess(r.waitForCompletion(b)); diff --git a/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy b/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy new file mode 100644 index 0000000000..9c5d4bab6c --- /dev/null +++ b/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy @@ -0,0 +1,7 @@ +podTemplate(label: 'bourneShellElsewhereInPath', containers: [containerTemplate(name: 'kaniko', image: 'gcr.io/kaniko-project/executor:debug', command: 'sleep', args: '99d')]) { + node('bourneShellElsewhereInPath') { + container(name: 'kaniko') { + sh 'ls -la /' + } + } +} From 5852bccbef4fd03f1b9b3c29d184af7325a3e71f Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 4 Jun 2019 20:15:03 -0400 Subject: [PATCH 2/6] Incrementals. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 22f6402ec9..3e3029d929 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ org.jenkins-ci.plugins durable-task - 1.30-SNAPSHOT + 1.30-rc416.ace2b55005b1 org.jenkins-ci.plugins From 3eb8feb109698f9a897aa6f55a82b83c31c437ad Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 4 Jun 2019 20:56:27 -0400 Subject: [PATCH 3/6] CI build failed cryptically, so trying something else. + ls -la / ls: can't open '/': Value too large for defined data type total 0 --- .../plugins/kubernetes/pipeline/KubernetesPipelineTest.java | 2 +- .../kubernetes/pipeline/bourneShellElsewhereInPath.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java index f07c237b3a..3560b5e45f 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java @@ -194,7 +194,7 @@ public void runInPodWithDifferentShell() throws Exception { @Test public void bourneShellElsewhereInPath() throws Exception { r.assertBuildStatusSuccess(r.waitForCompletion(b)); - r.assertLogContains("+ ls -la /", b); + r.assertLogContains("/kaniko:/busybox", b); } @Test diff --git a/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy b/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy index 9c5d4bab6c..b89237933e 100644 --- a/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy +++ b/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy @@ -1,7 +1,7 @@ podTemplate(label: 'bourneShellElsewhereInPath', containers: [containerTemplate(name: 'kaniko', image: 'gcr.io/kaniko-project/executor:debug', command: 'sleep', args: '99d')]) { node('bourneShellElsewhereInPath') { container(name: 'kaniko') { - sh 'ls -la /' + sh 'echo $PATH' } } } From 575a8f87b880fc34aca8c479c87580c678979c38 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 4 Jun 2019 20:59:55 -0400 Subject: [PATCH 4/6] Test flake seen on CI. Probably due to: https://issues.jenkins-ci.org/browse/JENKINS-46076?focusedCommentId=368388&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-368388 java.lang.AssertionError: Expected: a string containing "Labels must follow required specs - https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set: mypod!123" but: was "Started Running in Durability level: MAX_SURVIVABILITY [Pipeline] podTemplate [Pipeline] // podTemplate [Pipeline] End of Pipeline " at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20) at org.junit.Assert.assertThat(Assert.java:956) at org.junit.Assert.assertThat(Assert.java:923) at org.jvnet.hudson.test.JenkinsRule.assertLogContains(JenkinsRule.java:1308) at org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecutionTest.testBadLabel(PodTemplateStepExecutionTest.java:85) --- .../kubernetes/pipeline/PodTemplateStepExecutionTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecutionTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecutionTest.java index a4f64a8323..c477011021 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecutionTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecutionTest.java @@ -62,7 +62,7 @@ public void testBadNameDetection() throws Exception { WorkflowRun b = p.scheduleBuild2(0).waitForStart(); assertNotNull(b); r.assertBuildStatus(Result.FAILURE, r.waitForCompletion(b)); - r.assertLogContains(Messages.RFC1123_error("badcontainerName_!"), b); + r.waitForMessage(Messages.RFC1123_error("badcontainerName_!"), b); } @Test @@ -72,7 +72,7 @@ public void testBadNameYamlDetection() throws Exception { WorkflowRun b = p.scheduleBuild2(0).waitForStart(); assertNotNull(b); r.assertBuildStatus(Result.FAILURE, r.waitForCompletion(b)); - r.assertLogContains(Messages.RFC1123_error("badcontainername_!, badcontainername2_!"), b); + r.waitForMessage(Messages.RFC1123_error("badcontainername_!, badcontainername2_!"), b); } @Test @@ -82,7 +82,7 @@ public void testBadLabel() throws Exception { WorkflowRun b = p.scheduleBuild2(0).waitForStart(); assertNotNull(b); r.assertBuildStatus(Result.FAILURE, r.waitForCompletion(b)); - r.assertLogContains(Messages.label_error("mypod!123"), b); + r.waitForMessage(Messages.label_error("mypod!123"), b); } } From df76d9f710dfb860ea97773f871832cceeb71cbb Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 7 Jun 2019 10:59:40 -0400 Subject: [PATCH 5/6] Revert "Test flake seen on CI." This reverts commit 575a8f87b880fc34aca8c479c87580c678979c38. Not clear that this would actually fix the flake. RCA in JENKINS-46076. --- .../kubernetes/pipeline/PodTemplateStepExecutionTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecutionTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecutionTest.java index c477011021..a4f64a8323 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecutionTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecutionTest.java @@ -62,7 +62,7 @@ public void testBadNameDetection() throws Exception { WorkflowRun b = p.scheduleBuild2(0).waitForStart(); assertNotNull(b); r.assertBuildStatus(Result.FAILURE, r.waitForCompletion(b)); - r.waitForMessage(Messages.RFC1123_error("badcontainerName_!"), b); + r.assertLogContains(Messages.RFC1123_error("badcontainerName_!"), b); } @Test @@ -72,7 +72,7 @@ public void testBadNameYamlDetection() throws Exception { WorkflowRun b = p.scheduleBuild2(0).waitForStart(); assertNotNull(b); r.assertBuildStatus(Result.FAILURE, r.waitForCompletion(b)); - r.waitForMessage(Messages.RFC1123_error("badcontainername_!, badcontainername2_!"), b); + r.assertLogContains(Messages.RFC1123_error("badcontainername_!, badcontainername2_!"), b); } @Test @@ -82,7 +82,7 @@ public void testBadLabel() throws Exception { WorkflowRun b = p.scheduleBuild2(0).waitForStart(); assertNotNull(b); r.assertBuildStatus(Result.FAILURE, r.waitForCompletion(b)); - r.waitForMessage(Messages.label_error("mypod!123"), b); + r.assertLogContains(Messages.label_error("mypod!123"), b); } } From b2804bb97030ebb7bdd4b3fc1e692eb8219f2d1a Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 5 Jul 2019 15:27:07 -0400 Subject: [PATCH 6/6] durable-task 1.30 Co-Authored-By: Devin Nusbaum --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 078a8e3793..7c8ed4f431 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ org.jenkins-ci.plugins durable-task - 1.30-rc416.ace2b55005b1 + 1.30 org.jenkins-ci.plugins