-
Bug
-
Resolution: Unresolved
-
Minor
-
None
Running:
Jenkins 2.289.1
kubernetes plugin: 1.30.0
Based on this example:
https://github.com/jenkinsci/kubernetes-plugin#example
I have created a podTemplate in a separate file:
pod.yaml
apiVersion: v1
kind: Pod
spec:
containers:
- name: jnlp
image: jenkins/inbound-agent:4.9-1-jdk11
command:
- cat
- name: gradle
image: gradle:7.1.1-jdk11
ttyEnabled: true
command:
- cat
Which I use in my Jenkinsfile:
Jenkinsfile:
podTemplate(yaml: readTrusted('pod.yaml')) { node(POD_LABEL) { stage('Checkout') { checkout scm } stage('debug....') { container('gradle') { sh 'whoami' } } } }
But when I run the above pipeline the jenkins agents just hangs - or rather it seems the jnlp container fails with:
$ kubectl -c jnlp logs -f $(kubectl get pods | grep demo | awk '{print $1}') Unable to retrieve container logs for docker://d046ef89fbd062b501c66c9e4e2dc81cc37f1fcfe8d53c7f639469621bd0c4f5
Which does not help much.
I have then tried to update the podtemplate to:
apiVersion: v1 kind: Pod spec: containers: - name: jnlp image: jenkins/inbound-agent:4.9-1-jdk11 command: - "" args: - "^${computer.jnlpmac} ^${computer.name}" ttyEnabled: true - name: gradle image: gradle:7.1.1-jdk11 ttyEnabled: true command: - cat
But then I get:
[Warning].....[Failed] Error: failed to start container "jnlp": Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "^${computer.jnlpmac} ^${computer.name}": executable file not found in $PATH: unknown
If instead include the podTemplate in my Jenkinsfile like below:
podTemplate(label: 'builder', containers: [ containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:4.9-1-jdk11', args: '${computer.jnlpmac} ${computer.name}'), containerTemplate(name: 'gradle', image: 'gradle:7.1.1-jdk11', ttyEnabled: true, command: 'cat') ]) { node('builder') { stage('Checkout') { checkout scm } stage('debug....') { container('gradle') { sh 'whoami' } } } }
it works fine.
Is this a bug or am I missing something?
A few other things I have tried:
apiVersion: v1 kind: Pod spec: containers: - name: jnlp image: jenkins/jnlp-slave:latest args: ['$(JENKINS_SECRET)', '$(JENKINS_NAME)'] - name: gradle image: gradle:7.1.1-jdk11 ttyEnabled: true command: - cat
JNLP container just keeps restating and the only thing in the log:
Jul 06, 2021 8:24:51 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Remote identity confirmed: 30****14 Jul 06, 2021 8:24:52 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Connected Jul 06, 2021 8:25:06 PM org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave$SlaveDisconnector call INFO: Disabled agent engine reconnects. Jul 06, 2021 8:25:06 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Terminated
Also tried using:
image: jenkins/inbound-agent:4.9-1-jdk11
instead but same behavior/error.
I found out that we must set tty: true (not ttyEnabled) for all container templates. (Took me 20 attempts of trial deployments and errors).
In my case, I didn't set tty and my containers were terminated with error log:
Unable to retrieve container logs for containerd <...hash...>