Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-66049

Kubernetes Plugin throws NPE when trying to cancel item

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • kubernetes-plugin
    • None
    • kubernetes-1.30.1

      Issue

      When a kubernetes agent is spun up to fulfil a node step (not a podTemplate step nor kubernetes}) declarative directive), certain failure to create pods would cause a {{NullPointerException in the logs:

      2021-07-05 06:33:32.815+0000 [id=2910]	WARNING	o.c.j.p.k.KubernetesLauncher#launch: Error in provisioning; agent=KubernetesSlave name: default-java-fbmpk, template=PodTemplate{id='9828c91f-e185-4d4a-8d92-6a88733fd6e2', name='default-java', label='default-java'}
      java.lang.NullPointerException
      	at org.csanchez.jenkins.plugins.kubernetes.PodUtils.cancelQueueItemFor(PodUtils.java:76)
      	at org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher.launch(KubernetesLauncher.java:149)
      	at com.cloudbees.jenkins.plugins.kube.ListenableKubernetesLauncher.launch(ListenableKubernetesLauncher.java:30)
      	at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:294)
      	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
      	at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:80)
      	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)
      

      How to Reproduce

      • Create a Kubernetes Pod template globally, with label "default-java"
      • Create a pipeline like the following
      node ('default-java') {
          echo "OK"
      }
      
      • Revoke the pod/create permission for the ServiceAccount used to deploy the pod (this is one example scenario that would fall into that condition, there might be other)
      • Start the pipeline

      The pipeline fails (expected) and the Jenkins logs show the NPE.

            allan_burdajewicz Allan BURDAJEWICZ
            allan_burdajewicz Allan BURDAJEWICZ
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: