Issue
- Agent provisioning fail and master logs show an issue similar to the following:
io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://127.0.0.1/api/v1/namespaces/cloudbees-core/pods. Message: Pod "default-jnlp-dfptn" is invalid: metadata.labels: Invalid value: "MY%20MASTER": 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=422, details=StatusDetails(causes=[StatusCause(field=metadata.labels, message=Invalid value: "MY%MASTER": 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])?'), reason=FieldValueInvalid, additionalProperties={})], group=null, kind=Pod, name=default-jnlp-dfptn, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Pod "default-jnlp-dfptn" is invalid: metadata.labels: Invalid value: "MY%MASTER": 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, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:503)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.assertResponseCode(OperationSupport.java:442)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:406)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:365)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleCreate(OperationSupport.java:234)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.handleCreate(BaseOperation.java:796)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.create(BaseOperation.java:326)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.create(BaseOperation.java:322)
at org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher.launch(KubernetesLauncher.java:124)
at com.cloudbees.jenkins.plugins.kube.ListenableKubernetesLauncher.launch(ListenableKubernetesLauncher.java:30)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Environment
Related Issue
- CPLT2-5649: Tag each pod created by a master with a backlink to the master
- CPLT2-5956: Master label doesn’t work when master has a space in its name
Explanation
This is caused by a feature introduced in Kube Agent Management plugin version 1.1.14 that automatically adds a label with the master’s name to agent pods. If the master contains a space in its name, the label cannot be applied.
Resolution
The issue has been resolved in the Kube Agent Management plugin version 1.1.17 and is available in the October release of CloudBees Core 2.190.2.2.
Solution
Upgrade CloudBees Core to version 2.190.2.2 or later.
Workaround
The workaround for a live instance is to execute the following groovy script under Manage Jenkins > Script Console:
import hudson.*
def podTemplateExtensionList = org.csanchez.jenkins.plugins.kubernetes.PodTemplateFilter.all()
println "Current ExtensionList:" + podTemplateExtensionList
def masterLinkExtension = podTemplateExtensionList.get(com.cloudbees.jenkins.plugins.kube.MasterLinkFilter.class)
println "Removing " + masterLinkExtension
podTemplateExtensionList.remove(masterLinkExtension)
println "Resulting ExtensionList: " + org.csanchez.jenkins.plugins.kubernetes.PodTemplateFilter.all()
This will however not survive a restart.
To make this workaround around permanent, create a groovy script named CPLT2-5956.groovy
under /var/jenkins_home/init.groovy.d/
in the $JENKINS_HOME
of the masters impacted.
0 Comments