Build blocker does not block on node level

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Build blocker does not block on node level

Denis Mone
Hello.
We have build-blocker plugin installed on our Jenkins installation in my company, and we discovered that the node level blocking does not work.
Scheduling two mutually excluded jobs on the same node for example succeeds.
From a quick google search i found out that there is a similar issue reported on jira JENKINS-50187

I cloned the repo and managed to run the plugin, and by going through the code i think that the issue may be on getBuildBlockerProperty method.
When canRun method of BuildBlockerQueueTaskDispatcher class is called the method correctly returns the property object.
But when canTake method is called it returns null, which implies that the node can take this job in order to build it.

@CheckForNull
private BuildBlockerProperty getBuildBlockerProperty(Queue.Item item) {
   
if (!(item.task instanceof Job)) {
       
return null;
   
}
   
Job<?,?> job = (Job<?,?>) item.task;

   
return job.getProperty(BuildBlockerProperty.class);
}


Can anyone who is familiar with Pipeline API to point me to a direction where i can solve this issue?


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/54a364ab-e585-41f9-9752-eb07634e6cf3%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Build blocker does not block on node level

Denis Mone


Τη Δευτέρα, 4 Νοεμβρίου 2019 - 5:54:07 μ.μ. UTC+2, ο χρήστης Denis Mone έγραψε:
Hello.
We have build-blocker plugin installed on our Jenkins installation in my company, and we discovered that the node level blocking does not work.
Scheduling two mutually excluded jobs on the same node for example succeeds.
From a quick google search i found out that there is a similar issue reported on jira <a href="https://issues.jenkins-ci.org/browse/JENKINS-50187" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-50187\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHaHCU_N0M9qENW_87urc_fRW_ugw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-50187\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHaHCU_N0M9qENW_87urc_fRW_ugw&#39;;return true;">JENKINS-50187

I cloned the repo and managed to run the plugin, and by going through the code i think that the issue may be on getBuildBlockerProperty method.
When canRun method of BuildBlockerQueueTaskDispatcher class is called the method correctly returns the property object.
But when canTake method is called it returns null, which implies that the node can take this job in order to build it.

@CheckForNull
private BuildBlockerProperty getBuildBlockerProperty(Queue.Item item) {
   
if (!(item.task instanceof Job)) {
       
return null;
   
}
   
Job<?,?> job = (Job<?,?>) item.task;

   
return job.getProperty(BuildBlockerProperty.class);
}


Can anyone who is familiar with Pipeline API to point me to a direction where i can solve this issue?

I have added another if statement on the method to check if ownerTask is instance of Job class. If its true then go ahead and get the property.
            if (!(item.task.getOwnerTask() instanceof Job)) {
               
return null;
           
} else {
               
return ((Job<?, ?>) item.task.getOwnerTask()).getProperty(BuildBlockerProperty.class);
           
}

This seems to solve the issue, at least when running the plugin locally.


 

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/b35aa7bf-dd22-48d2-8a88-2b5ac491bf5d%40googlegroups.com.