[JIRA] (JENKINS-60249) Pod retention policy onFailure is not applied

7 views
Skip to first unread message

ignaciojavierpascual@gmail.com (JIRA)

unread,
Nov 22, 2019, 10:54:03 AM11/22/19
to jenkinsc...@googlegroups.com
Ignacio Pascual created an issue
 
Jenkins / Bug JENKINS-60249
Pod retention policy onFailure is not applied
Issue Type: Bug Bug
Assignee: Unassigned
Components: kubernetes-plugin
Created: 2019-11-22 15:53
Environment: Kubernetes v1.14
Helm 2.15.1
Kubernetes plugin v1.21.3
Jenkins v2.190.3
Priority: Major Major
Reporter: Ignacio Pascual

When the Pod retention policy is set on "onFailure" and the build fails, the slaves should be kept for debug and analysis. However, they are terminated immediately as if the build was succesful.

 

For instance, we can use this simple Pod template.

podTemplate(podRetention: onFailure(),
activeDeadlineSeconds: 600,
yaml: """
apiVersion: v1
kind: Pod
spec:
 containers:
 - name: ansible
 image: (private repo)/ansible:0.2
 imagePullPolicy: IfNotPresent
 command: ['cat']
 tty: true
"""
)

 

I have also used a simple pipeline

{
    node(POD_LABEL) {
      container('ansible') {
        sh "sleep 10"
        sh "hola"
      }
    }
}

As a result the pod will fail, since the if not such command as "hola".

Due to the Pod retention policy, I would expect that the pod is still alive for the timeout configured, but Jenkins terminates it.

To reproduce this issue is as simple as deploy the stable/jenkins Helm chart and create a pipeline with the details given above.

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

ignaciojavierpascual@gmail.com (JIRA)

unread,
Dec 6, 2019, 7:48:02 AM12/6/19
to jenkinsc...@googlegroups.com
Ignacio Pascual commented on Bug JENKINS-60249
 
Re: Pod retention policy onFailure is not applied

Can I provide more information to clarify?

 

elhayefrat@gmail.com (JIRA)

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

Ignacio Pascual 

according to the code

public boolean shouldDeletePod(KubernetesCloud cloud, Pod pod) {
if (pod == null || pod.getStatus() == null)

{ return false; }

boolean hasErrors = pod.getStatus().getPhase().toLowerCase().matches("(failed|unknown)");
return !hasErrors;
}

 

 

it will keep the pods only if the pods are in failure or unknow state 

not the job  

ignaciojavierpascual@gmail.com (JIRA)

unread,
Feb 7, 2020, 6:36:03 PM2/7/20
to jenkinsc...@googlegroups.com

Thanks for your response.

I see. In that case, Jenkins does not keep the pods when there are pipeline execution failures, but when there is some failure with the pod itself.

According to the documentation, it should take the status of the build. Right?

https://jenkins.io/doc/pipeline/steps/kubernetes/

 

Reply all
Reply to author
Forward
0 new messages