0

After Jenkins restart we found few nodes with busy executor. The job that occupies executor have striped white blue loading bar and does not link to any specific build (in fact no build is ongoing for that job). So we don't have id or ui way to abort it, you can see it here:

How the job looks on jenkins node

Now, I wanted to find a way to kill it without really looking into cause of the issue, maybe its related to Jenkins pipeline job wont finish in the UI - but in our case we don't have underlying finished job. We tried to kill it by:

  • Restarting node
  • Killing any jenkins/agent threads on node - it just caused node to disconnect
  • Locating it somehow via ui

None of above worked, the ghost job was still there. Any clues how to kill such job or at least point to it without id ?

Edit: I found similar thread How to stop an unstoppable zombie job on Jenkins without restarting the server? with plenty answers though different solution that didn't work for me

Malvander
  • 1
  • 2

1 Answers1

0

Ok, so I've found a way to free these executors via groovy script executed on Jenkins Script Console.

The way I managed to kill it was to get node by label as Computer, iterate through executors (or rather, call the only one ;) ) and call Interrupt()

def busyExecutors = Jenkins.instance.getNode("myNode").toComputer()
 
println "Busy Executors list"

println busyExecutors;
println busyExecutors.getExecutors().get(0)
println busyExecutors.getExecutors().get(0).interrupt() 

Here was my result of the script. Important part is of course the interrupt, other prints above are just for information.

Malvander
  • 1
  • 2
  • **A bit more investigation:** So, this is not really part of answer anymore, but I find it interesting, maybe someone will too. Here are some finds from investigating: Executor.getCurrentExecutable() return null According to documentation this method "Returns the current build this executor is running.". In my case it returned null – Malvander May 28 '21 at 14:38
  • By executing [getId()](https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html?is-external=true#getId--) I managed to get Thread id but surprisingly I haven't found it on node (centos) nor by listing node threads with groovy script on node script console – Malvander May 28 '21 at 14:45