Skip to content

Commit

Permalink
Placeholder
Browse files Browse the repository at this point in the history
Change-Id: I59b5f85d36e892be17d7a6a9bb214d68a07fa3d9
  • Loading branch information
MattLud committed Nov 14, 2019
1 parent c655ef4 commit 230fc97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,5 @@ public static class DescriptorImpl extends Descriptor<PodLabel> {
public String getDisplayName() {
return "Pod Label";
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public class PodTemplate extends AbstractDescribableImpl<PodTemplate> implements
private String image;

private boolean privileged;

private Long runAsUser;

private Long runAsGroup;

private boolean capOnlyOnAlivePods;
Expand Down Expand Up @@ -381,7 +381,7 @@ public Map<String, String> getLabelsMap() {
ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder();
if (!labelSet.isEmpty()) {
for (LabelAtom label : labelSet) {
builder.put(label == null ? DEFAULT_ID : "jenkins/" + label.getName(), "true");
builder.put("jenkins/label",label == null ? DEFAULT_ID : label.getName());
}
}
return builder.build();
Expand Down Expand Up @@ -434,7 +434,7 @@ public boolean isPrivileged() {
public void setRunAsUser(String runAsUser) {
this.runAsUser = PodTemplateUtils.parseLong(runAsUser);
}

public String getRunAsUser() {
return runAsUser == null ? null : runAsUser.toString();
}
Expand Down Expand Up @@ -734,12 +734,12 @@ protected Object readResolve() {
containerTemplate.setWorkingDir(remoteFs);
containers.add(containerTemplate);
}

if (podRetention == null) {
// https://issues.jenkins-ci.org/browse/JENKINS-53260
// various legacy paths for injecting pod templates can
// various legacy paths for injecting pod templates can
// bypass the defaulting paths and the
// value can still be null, so check for it here so
// value can still be null, so check for it here so
// as to not blow up things like termination path
podRetention = PodRetention.getPodTemplateDefault();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public void runInPod() throws Exception {
}
assertTrue(foundBuildUrl);
assertEquals(Integer.MAX_VALUE, template.getInstanceCap());
assertThat(template.getLabelsMap(), hasEntry("jenkins/" + name.getMethodName(), "true"));
assertThat(template.getLabelsMap(), hasEntry("jenkins/label", name.getMethodName()));

Pod pod = pods.getItems().get(0);
LOGGER.log(Level.INFO, "One pod found: {0}", pod);
assertThat(pod.getMetadata().getLabels(), hasEntry("jenkins", "slave"));
assertThat("Pod labels are wrong: " + pod, pod.getMetadata().getLabels(), hasEntry("jenkins/" + name.getMethodName(), "true"));
assertThat("Pod labels are wrong: " + pod, pod.getMetadata().getLabels(), hasEntry("jenkins/label", name.getMethodName()));

r.assertBuildStatusSuccess(r.waitForCompletion(b));
r.assertLogContains("script file contents: ", b);
Expand All @@ -167,10 +167,10 @@ public void runIn2Pods() throws Exception {
PodTemplate template1 = podTemplatesWithLabel(label1, cloud.getAllTemplates()).get(0);
SemaphoreStep.success("podTemplate1/1", null);
assertEquals(Integer.MAX_VALUE, template1.getInstanceCap());
assertThat(template1.getLabelsMap(), hasEntry("jenkins/" + label1, "true"));
assertThat(template1.getLabelsMap(), hasEntry("jenkins/label", label1));
SemaphoreStep.waitForStart("pod1/1", b);
Map<String, String> labels1 = getLabels(cloud, this, name);
labels1.put("jenkins/"+label1, "true");
labels1.put("jenkins/label","jenkins/"+label1);
PodList pods = cloud.connect().pods().withLabels(labels1).list();
assertTrue(!pods.getItems().isEmpty());
SemaphoreStep.success("pod1/1", null);
Expand All @@ -180,11 +180,11 @@ public void runIn2Pods() throws Exception {
PodTemplate template2 = podTemplatesWithLabel(label2, cloud.getAllTemplates()).get(0);
SemaphoreStep.success("podTemplate2/1", null);
assertEquals(Integer.MAX_VALUE, template2.getInstanceCap());
assertThat(template2.getLabelsMap(), hasEntry("jenkins/" + label2, "true"));
assertThat(template2.getLabelsMap(), hasEntry("jenkins/label", label2));
assertNull(label2 + " should not inherit from anything", template2.getInheritFrom());
SemaphoreStep.waitForStart("pod2/1", b);
Map<String, String> labels2 = getLabels(cloud, this, name);
labels1.put("jenkins/" + label2, "true");
labels1.put("jenkins/label", label2);
PodList pods2 = cloud.connect().pods().withLabels(labels2).list();
assertTrue(!pods2.getItems().isEmpty());
SemaphoreStep.success("pod2/1", null);
Expand Down Expand Up @@ -436,7 +436,7 @@ private void assertNotXPath(HtmlPage page, String xpath) {
HtmlElement documentElement = page.getDocumentElement();
assertNull("There should not be an object that matches XPath:" + xpath, DomNodeUtil.selectSingleNode(documentElement, xpath));
}

@Issue("JENKINS-57717")
@Test
public void runInPodWithShowRawYamlFalse() throws Exception {
Expand Down

0 comments on commit 230fc97

Please sign in to comment.