[JIRA] (JENKINS-60937) Pods are not created due to 'invalid label value: "jenkins/slave-default"'

8 views
Skip to first unread message

fredg02@hotmail.com (JIRA)

unread,
Jan 31, 2020, 7:48:03 AM1/31/20
to jenkinsc...@googlegroups.com
Fred G created an issue
 
Jenkins / Bug JENKINS-60937
Pods are not created due to 'invalid label value: "jenkins/slave-default"'
Issue Type: Bug Bug
Assignee: Unassigned
Components: kubernetes-plugin
Created: 2020-01-31 12:47
Environment: kubernetes-plugin 1.22.1 and following
Jenkins LTS 2.190.1
configuration-as-code-plugin
Labels: regression
Priority: Major Major
Reporter: Fred G

Since upgrading to version 1.22.1 and higher of the kubernetes-plugin pods are not created (and therefore builds are not starting) due to the following error:

Failed to count the # of live instances on Kubernetes
io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: https://172.30.40.1/api/v1/namespaces/rdf4j/pods?labelSelector=jenkins%3Dslave%2Cjenkins%2Flabel%3Djenkins%2Fslave-default. Message: unable to parse requirement: invalid label value: "jenkins/slave-default": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?'). Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=unable to parse requirement: invalid label value: "jenkins/slave-default": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?'), metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:510)

We use the JCasC plugin to define our pod templates and we don't use labels for pod templates. This causes the label to not only be empty ("") but not be set (null) after every restart of the master (or when the JCasC config is re-applied).

This leads to the DEFAULT_ID being used in PodTemplate.getLabelsMap():

public Map<String, String> getLabelsMap() {
    return ImmutableMap.of("jenkins/label", label == null ? DEFAULT_ID : sanitizeLabel(label));
}

See https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java#L383-L385

Unfortunately the DEFAULT_ID is set to "jenkins/slave-default":

private static final String DEFAULT_ID = "jenkins/slave-default";

See https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java#L59

Then the following labels are created:

jenkins=slave
jenkins/label=jenkins/slave-default

This fails because the value of "jenkins/label" contains a slash ("jenkins/slave-default") which is not allowed.

I'd suggest to change the DEFAULT_ID string to "slave-default" and rename it to DEFAULT_LABEL for good measure.

PR incoming.

Workaround is to set pod template labels via JCasC for now.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

fredg02@hotmail.com (JIRA)

unread,
Jan 31, 2020, 9:06:03 AM1/31/20
to jenkinsc...@googlegroups.com

vincent@latombe.net (JIRA)

unread,
Jan 31, 2020, 9:10:09 AM1/31/20
to jenkinsc...@googlegroups.com

vincent@latombe.net (JIRA)

unread,
Jan 31, 2020, 9:10:11 AM1/31/20
to jenkinsc...@googlegroups.com
Vincent Latombe started work on Bug JENKINS-60937
 
Change By: Vincent Latombe
Status: Open In Progress

vincent@latombe.net (JIRA)

unread,
Jan 31, 2020, 9:11:02 AM1/31/20
to jenkinsc...@googlegroups.com

vincent@latombe.net (JIRA)

unread,
Jan 31, 2020, 12:20:05 PM1/31/20
to jenkinsc...@googlegroups.com
Change By: Vincent Latombe
Status: In Review Resolved
Resolution: Fixed
Released As: kubernetes 1.23.2
Reply all
Reply to author
Forward
0 new messages