Skip to content

Commit

Permalink
Merge pull request #325 from jenkinsci/JENKINS-50268
Browse files Browse the repository at this point in the history
[JENKINS-50268] instanceCap reached with preexisting pods
  • Loading branch information
carlossg authored May 24, 2018
2 parents 609ef37 + f538240 commit aa3b0ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateMap;
import org.jenkinsci.plugins.plaincredentials.StringCredentials;
import org.jenkinsci.plugins.plaincredentials.FileCredentials;
import org.jenkinsci.plugins.plaincredentials.StringCredentials;
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
Expand Down Expand Up @@ -336,9 +336,15 @@ public int getConnectTimeout() {
* Labels for all pods started by the plugin
*/
public Map<String, String> getLabels() {
return labels == null ? Collections.emptyMap() : labels;
return labels == null || labels.isEmpty() ? DEFAULT_POD_LABELS : labels;
}

/**
* No UI yet, so this is never re-set
*
* @param labels
*/
// @DataBoundSetter
public void setLabels(Map<String, String> labels) {
this.labels = labels;
}
Expand Down Expand Up @@ -630,9 +636,6 @@ private Object readResolve() {
if (maxRequestsPerHost == 0) {
maxRequestsPerHost = DEFAULT_MAX_REQUESTS_PER_HOST;
}
if (labels == null) {
labels = DEFAULT_POD_LABELS;
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.csanchez.jenkins.plugins.kubernetes;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

import java.util.Arrays;
Expand All @@ -40,9 +41,7 @@
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.recipes.LocalData;

import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey;
import com.cloudbees.plugins.credentials.Credentials;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;

Expand All @@ -62,8 +61,8 @@ public class KubernetesTest {

@Before
public void before() throws Exception {
cloud = r.jenkins.clouds.get(KubernetesCloud.class);
r.configRoundtrip();
cloud = r.jenkins.clouds.get(KubernetesCloud.class);
}

@Test
Expand All @@ -77,6 +76,7 @@ public void upgradeFrom_1_1() throws Exception {
FileSystemServiceAccountCredential cred1 = (FileSystemServiceAccountCredential) credentials.get(1);
StringCredentialsImpl cred2 = (StringCredentialsImpl) credentials.get(2);
assertEquals("mytoken", Secret.toString(cred2.getSecret()));
assertThat(cloud.getLabels(), hasEntry("jenkins", "slave"));
}

@Test
Expand Down

0 comments on commit aa3b0ed

Please sign in to comment.