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

Node online status cannot find node when using Pipeline job

      Jenkins Version: 1.651
      Mail Watcher Plugin: 1.13
      Pipeline: 2.0

      Steps to re-produce:

      1. Add dumb slave (my-node)
      2. Configure - Notify when node online status changes (ticked)
      3. Create pipeline job (MY_JOB), using node:

      node('my-node') {
        echo 'hello world'
      }
      

      Logs from build run:

      Apr 22, 2016 12:16:15 PM org.jenkinsci.plugins.workflow.job.WorkflowRun finish
      INFO: MY_JOB #1 completed: SUCCESS
      Apr 22, 2016 12:16:15 PM org.jenkinsci.plugins.mailwatcher.NodeAwailabilityListener onFinalized
      INFO: Unable to identify the slave of MY_JOB #1 (class org.jenkinsci.plugins.workflow.job.WorkflowRun)
      java.lang.Exception
      	at org.jenkinsci.plugins.mailwatcher.NodeAwailabilityListener.onFinalized(NodeAwailabilityListener.java:79)
      	at hudson.model.listeners.RunListener.fireFinalized(RunListener.java:232)
      	at hudson.model.Run.onEndBuilding(Run.java:1888)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:540)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$1100(WorkflowRun.java:111)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:777)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:843)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$4.run(CpsThreadGroup.java:340)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:32)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	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:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      https://github.com/jenkinsci/mail-watcher-plugin/blob/master/src/main/java/org/jenkinsci/plugins/mailwatcher/NodeAwailabilityListener.java#L78

          [JENKINS-34385] Node online status cannot find node when using Pipeline job

          This is indeed a bug. The proper fix would be to do the check once node block ends.

          Oliver Gondža added a comment - This is indeed a bug. The proper fix would be to do the check once node block ends.

          Sorin Sbarnea added a comment -

          Any updates on this? Seems quite annoying to see so many stacktraces on the logs.

          Sorin Sbarnea added a comment - Any updates on this? Seems quite annoying to see so many stacktraces on the logs.

          Github PR sent.

          The "solution" is not very elegant, however I think the best we can do is getting rid of that exception in cases when mail-watcher plugin encountered unsupported build type.

          Jakub Cechacek added a comment - Github PR sent. The "solution" is not very elegant, however I think the best we can do is getting rid of that exception in cases when mail-watcher plugin encountered unsupported build type.

          jcechace, just noting that suggested improvement hide the annoying message but doe not address the real problem: this plugin does not support pipeline.

          Oliver Gondža added a comment - jcechace , just noting that suggested improvement hide the annoying message but doe not address the real problem: this plugin does not support pipeline.

          Jakub Cechacek added a comment - - edited

          After discussion with olivergondza I propose the following as optimal way for plugin to be notified about workflow when `node` block was entered or left.

          • Make ExecutorListener extend ExtensionPoint
          • Modify WorkUnitContext to properly notify all registered extensions of type ExecutorListener
          • Implement new WatcherExecutorListener which would notify user when owner node is temporarily offline and all executors become idle.
          • Deprecate NodeAwailabilityListener in favour of WatcherExecutorListener

          The downside is that modifications in core are required and thus the issue will be resolved only with new releases.

          @jglick Could you share your opinion regarding this approach? Thanks.

          Jakub Cechacek added a comment - - edited After discussion with olivergondza I propose the following as optimal way for plugin to be notified about workflow when `node` block was entered or left. Make ExecutorListener extend ExtensionPoint Modify WorkUnitContext to properly notify all registered extensions of type ExecutorListener Implement new WatcherExecutorListener which would notify user when owner node is temporarily offline and all executors become idle. Deprecate NodeAwailabilityListener in favour of WatcherExecutorListener The downside is that modifications in core are required and thus the issue will be resolved only with new releases. @ jglick Could you share your opinion regarding this approach? Thanks.

          Jesse Glick added a comment -

          I am not sure what problem is being solved. Why do you need to know when a node block is exited?

          Jesse Glick added a comment - I am not sure what problem is being solved. Why do you need to know when a node block is exited?

          jglick, plugin needs to detect when node becomes idle. It used to rely on RunListener but it does not work for pipelines for obvious reasons.

          Oliver Gondža added a comment - jglick , plugin needs to detect when node becomes idle. It used to rely on RunListener but it does not work for pipelines for obvious reasons.

          Code changed in jenkins
          User: Jakub Cechacek
          Path:
          src/main/java/org/jenkinsci/plugins/mailwatcher/NodeAwailabilityListener.java
          http://jenkins-ci.org/commit/mail-watcher-plugin/a3401687fbb03f63c3a975ad8d34ee0e71509ead
          Log:
          JENKINS-34385 Ignore "Unable to identify node" exception in case of pipeline job

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jakub Cechacek Path: src/main/java/org/jenkinsci/plugins/mailwatcher/NodeAwailabilityListener.java http://jenkins-ci.org/commit/mail-watcher-plugin/a3401687fbb03f63c3a975ad8d34ee0e71509ead Log: JENKINS-34385 Ignore "Unable to identify node" exception in case of pipeline job

          Code changed in jenkins
          User: Oliver Gondža
          Path:
          src/main/java/org/jenkinsci/plugins/mailwatcher/NodeAwailabilityListener.java
          http://jenkins-ci.org/commit/mail-watcher-plugin/9cd6c15f6bdddd6800b3d3825bfb979690ad104b
          Log:
          Merge pull request #7 from jcechace/JENKINS-34385

          JENKINS-34385 Ignore "Unable to identify node" exception in case of pipeline job

          Compare: https://github.com/jenkinsci/mail-watcher-plugin/compare/618738096eee...9cd6c15f6bdd

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: src/main/java/org/jenkinsci/plugins/mailwatcher/NodeAwailabilityListener.java http://jenkins-ci.org/commit/mail-watcher-plugin/9cd6c15f6bdddd6800b3d3825bfb979690ad104b Log: Merge pull request #7 from jcechace/ JENKINS-34385 JENKINS-34385 Ignore "Unable to identify node" exception in case of pipeline job Compare: https://github.com/jenkinsci/mail-watcher-plugin/compare/618738096eee...9cd6c15f6bdd

            jcechace Jakub Cechacek
            owood Owen Wood
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: