Skip to content

Commit

Permalink
JENKINS-60088: move label key to non-unique value; breaking change
Browse files Browse the repository at this point in the history
making labels require compliant format - no / or other characters
allowed

Change-Id: I28d5dfb01900227ebfe81a91ca01c4b73164dc89
  • Loading branch information
MattLud committed Dec 12, 2019
1 parent c655ef4 commit 377e465
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
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 @@ -737,7 +737,7 @@ protected Object readResolve() {

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
// as to not blow up things like termination path
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",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

0 comments on commit 377e465

Please sign in to comment.