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

Kubernetes Plugin NullPointerException after upgrade

    XMLWordPrintable

Details

    Description

      Issue started since version 1.27.2, all subsequent version had the same issue.

       

      Jenkins jobs that were successful are now failing with this exception:

      java.lang.NullPointerException
      	at org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud.lambda$getTemplateById$6(KubernetesCloud.java:649)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
      	at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1359)
      	at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
      	at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
      	at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:531)
      	at org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud.getTemplateById(KubernetesCloud.java:649)
      	at org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave.getTemplateOrNull(KubernetesSlave.java:100)
      	at org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave.getTemplate(KubernetesSlave.java:90)
      	at org.csanchez.jenkins.plugins.kubernetes.pipeline.SecretsMasker$Factory.secretsOf(SecretsMasker.java:144)
      	at org.csanchez.jenkins.plugins.kubernetes.pipeline.SecretsMasker$Factory.get(SecretsMasker.java:122)
      	at org.csanchez.jenkins.plugins.kubernetes.pipeline.SecretsMasker$Factory.get(SecretsMasker.java:94)
      	at org.jenkinsci.plugins.workflow.steps.DynamicContext$Typed.get(DynamicContext.java:94)
      	at org.jenkinsci.plugins.workflow.cps.ContextVariableSet.get(ContextVariableSet.java:138)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.getContextVariable(CpsThread.java:135)
      	at org.jenkinsci.plugins.workflow.cps.CpsStepContext.doGet(CpsStepContext.java:297)
      	at org.jenkinsci.plugins.workflow.support.DefaultStepContext.get(DefaultStepContext.java:74)
      	at org.jenkinsci.plugins.workflow.support.DefaultStepContext.getListener(DefaultStepContext.java:126)
      	at org.jenkinsci.plugins.workflow.support.DefaultStepContext.get(DefaultStepContext.java:86)
      	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.checkContextAvailability(StepDescriptor.java:264)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:263)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
      	at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
      	at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
      	at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
      	at standardBuild.call(standardBuild.groovy:10)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
      	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
      	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
      	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:136)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	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)
      Finished: FAILURE 

      Attachments

        Issue Links

          Activity

            aiman Aiman Najjar added a comment -

            vlatombe - I'm not sure I have the same issue reported in JENKINS-63925:

            • I've tried upgrading to 1.28.2, which should have your fix PR, but we are still getting the exception.
            • The reporter of JENKINS-63925 says the issue was fixed by re-creating cloud template. I'm not using pre-existing template in my case, I simply call podTemplate function:
                podTemplate(name: 'standard-worker',
                  label: 'standard-worker',
                  idleMinutes: 180,
                  yaml: standardPodDefinition() // returns a YAML defintion
                ) {
                  node('standard-worker') {
                     ....
                 }
                }
              }
              
            • When I navigate to the Cloud Configuration page on the UI, I do see a template there with same name, I've tried to delete it/re-create it, or completely delete it, and in both cases, I still saw the same NullPointerException.

            Can you please advise? I have even tried to create new Kubernetes cloud entirely and pre-created a template with name "standard-worker" and that didn't help.
             

            aiman Aiman Najjar added a comment - vlatombe - I'm not sure I have the same issue reported in JENKINS-63925 : I've tried upgrading to 1.28.2, which should have your fix PR, but we are still getting the exception. The reporter of JENKINS-63925 says the issue was fixed by re-creating cloud template. I'm not using pre-existing template in my case, I simply call podTemplate function: podTemplate(name: 'standard-worker' , label: 'standard-worker' , idleMinutes: 180, yaml: standardPodDefinition() // returns a YAML defintion ) { node( 'standard-worker' ) { .... } } } When I navigate to the Cloud Configuration page on the UI, I do see a template there with same name, I've tried to delete it/re-create it, or completely delete it, and in both cases, I still saw the same NullPointerException. Can you please advise? I have even tried to create new Kubernetes cloud entirely and pre-created a template with name "standard-worker" and that didn't help.  
            larsbloch Lars added a comment -

            aiman
            I might be too late for your issue and i dont know if it will fix what you are experiencing.

            We had the same problem and the fix was that the pods created by kubernetes before upgrading was not compatible with the new version. As our jobs was running often (and failed) kept the pods alive. We had to manually destroy them / change label to force creation of new pods that were compatible with the new version.

            larsbloch Lars added a comment - aiman I might be too late for your issue and i dont know if it will fix what you are experiencing. We had the same problem and the fix was that the pods created by kubernetes before upgrading was not compatible with the new version. As our jobs was running often (and failed) kept the pods alive. We had to manually destroy them / change label to force creation of new pods that were compatible with the new version.

            People

              Unassigned Unassigned
              aiman Aiman Najjar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: