timja / jenkins-gh-issues-poc-06-18

0 stars 0 forks source link

[JENKINS-24679] Executor_Number variable doesn't align with the “build executor status” #5476

Open timja opened 9 years ago

timja commented 9 years ago

After cancelling a build on an agent, the EXECUTOR_NUMBER variable gets out of sync with the "build executor status" number.

Please check attached screenshots.


Originally reported by fadelw, imported from: Executor_Number variable doesn't align with the “build executor status”
  • status: Open
  • priority: Major
  • resolution: Unresolved
  • imported: 2022/01/10
timja commented 9 years ago

danielbeck:

Executors are 0-indexed internally (and this is passed to the job), and 1-indexed on the UI. (In fact, you can have much higher internal executor indexes after increasing and then decreasing executor count and it'll not show up on the UI as to not confuse users.) So this isn't actually a bug from my POV. What exactly is affected by this?

timja commented 8 years ago

timothy_duch:

From what I can see, this is still happening, and I consider it a bug (from the perspective of the documentation: https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project) "This is the number you see in the "build executor status", except that the number starts from 0, not 1".

You can see in the images above that Build #7 has EXECUTOR_NUMBER 0, whilst on the UI under the build executor status, build #7 is running on what I would expect to be EXECUTOR_NUMBER 1 (#2 - 1 = 1).

timja commented 8 years ago

roebi:

The Problem ist here
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Computer.java#L1045
in removeExecutor(Executor e): executors.remove(e);
This remove a Executor in CopyOnWriteArrayList executors
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Computer.java#L151
in Combination with
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Computer.java#L1046
addNewExecutorIfNecessary();
This add a new Executor with the same Number like the removed, but add it at the End of the List:
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Computer.java#L904
executors.add(e);

Possible Solution
In End of Method addNewExecutorIfNecessary() a Sort in executors List sorted by the Executor Numbers.