Ah ok, for that one you need to set it at podTemplate level, not inside the
yaml


On Fri, Oct 18, 2019, 11:38 drpm <[email protected]> wrote:

> Hello,
>
> Thank you for your reply.
>
> It says here (https://github.com/jenkinsci/kubernetes-plugin) that pod
> will be deleted after the set activeDeadlineSeconds is passed or am I
> totally reading it wrong?
>
>    - podRetention Controls the behavior of keeping slave pods. Can be
>    'never()', 'onFailure()', 'always()', or 'default()' - if empty will
>    default to deleting the pod after activeDeadlineSeconds has passed.
>    - activeDeadlineSeconds If podRetention is set to 'never()' or
>    'onFailure()', pod is deleted after this deadline is passed.
>
> If this is totally wrong, can you recommend a right way to retain a pod
> even if the job is finished using this plugin?
>
> On Friday, October 18, 2019 at 6:17:06 PM UTC+9, Carlos Sanchez wrote:
>>
>> the plugin will delete the kubernetes pod after the jenkins job is
>> completed
>>
>> Also I don't think activeDeadlineSeconds is what you want
>> activeDeadlineSeconds: Optional duration in seconds the pod may be
>> active on the node relative to StartTime before the system will actively
>> try to mark it failed and kill associated containers. Value must be a
>> positive integer.
>>
>>
>> On Fri, Oct 18, 2019 at 11:11 AM drpm <[email protected]> wrote:
>>
>>> Hello,
>>>
>>> For some reason, jenkins is not honoring *activeDeadlineSeconds*
>>> parameter when used in pipeline script. I'm using this kubernetes plugin
>>> for jenkins: https://wiki.jenkins.io/display/JENKINS/Kubernetes+Plugin
>>>
>>> *Sample Pipeline Script*:
>>>
>>>
>>> def label = "jenkins-test-build-${UUID.randomUUID().toString()}"
>>>
>>> podTemplate(label: label, yaml: """
>>>
>>> apiVersion: v1
>>>
>>> kind: Pod
>>>
>>> metadata:
>>>
>>>   labels:
>>>
>>>     slave: jenkins-slave-testing-build
>>>
>>> spec:
>>>
>>>   activeDeadlineSeconds: 3600
>>>
>>>   containers:
>>>
>>>   - name: slave
>>>
>>>     image: '<ecr-repo>/jenkins-slave'
>>>
>>>     tty: true
>>>
>>>     command:
>>>
>>>     - cat
>>>
>>>   nodeSelector:
>>>
>>>     xyz.com/app: cibuild
>>>
>>>   tolerations:
>>>
>>>   - effect: NoSchedule
>>>
>>>     key: xyz.com/abc.xyz.com
>>>
>>>     operator: Equal
>>>
>>>     value: cibuild
>>>
>>> """
>>>
>>> ){
>>>
>>>     node (label) {
>>>
>>>       withEnv(['USER=jenkins']) {
>>>
>>>         container('slave') {
>>>
>>>           stage("test") {
>>>
>>>             sh "echo test"
>>>
>>>           }
>>>
>>>         }
>>>
>>>       }
>>>
>>>     }
>>>
>>> }
>>>
>>>
>>>
>>> I also checked the FINER logs
>>> for org.csanchez.jenkins.plugins.kubernetes and it appears to be getting
>>> the settings:
>>>
>>>
>>> Combining pods, parent: Pod(apiVersion=v1, kind=Pod,
>>>> metadata=ObjectMeta(annotations=null, clusterName=null,
>>>> creationTimestamp=null, deletionGracePeriodSeconds=null,
>>>> deletionTimestamp=null, finalizers=[], generateName=null, generation=null,
>>>> labels={slave=jenkins-slave-testing-build}, managedFields=[], name=null,
>>>> namespace=null, ownerReferences=[], resourceVersion=null, selfLink=null,
>>>> uid=null, additionalProperties={}), spec=PodSpec(
>>>> *activeDeadlineSeconds=3600*, affinity=null,
>>>> automountServiceAccountToken=null, containers=[Container(args=[],
>>>> command=[cat], env=[], envFrom=[], image=<ecrrepo>/jenkins-slave,
>>>> imagePullPolicy=null, lifecycle=null, livenessProbe=null, name=slave,
>>>> ports=[], readinessProbe=null, resources=null, securityContext=null,
>>>> stdin=null, stdinOnce=null, terminationMessagePath=null,
>>>> terminationMessagePolicy=null, tty=true, volumeDevices=[],
>>>> volumeMounts=[VolumeMount(mountPath=null, mountPropagation=null,
>>>> name=docker-sock, readOnly=null, subPath=null, subPathExpr=null,
>>>> additionalProperties={})], workingDir=null, additionalProperties={})],
>>>> dnsConfig=null, dnsPolicy=null, enableServiceLinks=null, hostAliases=[],
>>>> hostIPC=null, hostNetwork=null, hostPID=null, hostname=null,
>>>> imagePullSecrets=[], initContainers=[], nodeName=null, nodeSelector={
>>>> xyz.com/app=cibuild}, preemptionPolicy=null, priority=null,
>>>> priorityClassName=null, readinessGates=[], restartPolicy=null,
>>>> runtimeClassName=null, schedulerName=null, securityContext=null,
>>>> serviceAccount=null, serviceAccountName=null, shareProcessNamespace=null,
>>>> subdomain=null, terminationGracePeriodSeconds=null,
>>>> tolerations=[Toleration(effect=NoSchedule, key=xyz.com/abc.xyz.com,
>>>> operator=Equal, tolerationSeconds=null, value=cibuild,
>>>> additionalProperties={})], volumes=[Volume(awsElasticBlockStore=null,
>>>> azureDisk=null, azureFile=null, cephfs=null, cinder=null, configMap=null,
>>>> csi=null, downwardAPI=null, emptyDir=null, fc=null, flexVolume=null,
>>>> flocker=null, gcePersistentDisk=null, gitRepo=null, glusterfs=null,
>>>> hostPath=null, iscsi=null, name=null, nfs=null, persistentVolumeClaim=null,
>>>> photonPersistentDisk=null, portworxVolume=null, projected=null,
>>>> quobyte=null, rbd=null, scaleIO=null, secret=null, storageos=null,
>>>> vsphereVolume=null, additionalProperties={})],
>>>> additionalProperties={idleMinutes=null}), status=null,
>>>> additionalProperties={})
>>>
>>>
>>>
>>> but it's not working as expected since the pod is terminated right after
>>> the job is finished instead of waiting 3600s.
>>>
>>> Oct 18, 2019 8:58:18 AM INFO 
>>> org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution$PodTemplateCallback
>>>> finished
>>>> Removing pod template
>>>> jenkins-test-build-87928862-54e0-44c3-9be4-c68d414d4427-w9jpl from cloud
>>>> kubernetes
>>>> Oct 18, 2019 8:58:18 AM INFO 
>>>> org.csanchez.jenkins.plugins.kubernetes.pod.retention.Reaper
>>>> eventReceived
>>>> cibuild/jenkins-test-build-87928862-54e0-44c3-9be4-c68d414d44-d2878 was
>>>> just deleted, so removing corresponding Jenkins agent
>>>> Oct 18, 2019 8:58:18 AM INFO 
>>>> org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave
>>>> deleteSlavePod
>>>> Terminated Kubernetes instance for agent
>>>> cibuild/jenkins-mbx-test-build-87928862-54e0-44c3-9be4-c68d414d44-d2878
>>>> Oct 18, 2019 8:58:18 AM INFO 
>>>> org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave
>>>> _terminate
>>>> Disconnected computer
>>>> jenkins-test-build-87928862-54e0-44c3-9be4-c68d414d44-d2878
>>>
>>>
>>>
>>> Thank you in advance for your help.
>>>
>>> - drpm
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Jenkins Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-users/fd798b7c-39cf-41f4-b99b-8ebd5067dd6e%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/fd798b7c-39cf-41f4-b99b-8ebd5067dd6e%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/691690fb-e9bf-446e-a55f-8883e47cde66%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/691690fb-e9bf-446e-a55f-8883e47cde66%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6OAd%3DT8%3DRGZK9JNOE2rOAL-i1pvdrRkkkeFCaZQ5sPGFg%40mail.gmail.com.

Reply via email to