Looking for some feedback to make my plugin work in distributed Jenkins (master/slave) setups

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

Looking for some feedback to make my plugin work in distributed Jenkins (master/slave) setups

Daniel Anechitoaie
Hi,

I'm looking for some feedback regarding making my plugin work in distributed Jenkins (master/slave) setups.
For now I have made a "private static class DeployCallable extends MasterToSlaveCallable<Boolean, InterruptedException>" internal class 
with all my code being inside the "public Boolean call() throws InterruptedException" method.
I then just call this method with "launcher.getChannel().call(deployCallable)".



I think current code should work in a distributed Jenkins (master/slave) setup.

I just have one problem, if a user cancels the build from the master my plugin does not get interrupted and still gets executed until the end and only then the job is marked as canceled even tough it still finished doing everything.

I have described this issue here https://issues.jenkins-ci.org/browse/JENKINS-46705

Is there anything that I can do? I'm thinking of breaking my "do it all" "DeployCallable" into smaller pieces. Like one DeployCallable class to prepare the build and return a list of folders to be deployed, then another DeployCallable class that will zip one folder and iterate from master over the list returned by the first callable and then call this other Callable to zip one folder at a time, then another DeployCallable class that will upload the zip files and do the same iterate over the list of zips generated by the previous callable and call this Callable for each zip to upload it.

Would this make sense? I think in this case the interrupted exception might work? But my code will be more complicated and ugly.

What are my options? What can I do? 

Thank you.

--
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/c7ecd19d-021a-4bde-97cc-be2d5ba966c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Looking for some feedback to make my plugin work in distributed Jenkins (master/slave) setups

Oleg Nenashev
Hi Daniel,

I will check this case. Remoting is expected to interrupt calls on the Remote side: https://github.com/jenkinsci/remoting/blob/a1294d6fd5e0053098a532488aca02586c02a887/src/main/java/hudson/remoting/Request.java#L196-L203

Sorry for the response delay in the ticket, responded there. I'd guess the Interrupted Exception is being suppressed somehow. I check the code. If there is no obvious place, maybe it makes sense to just debug the agent side and to see what happens with the Cancel command.

BR, Oleg

среда, 27 сентября 2017 г., 10:57:12 UTC+3 пользователь Daniel Anechitoaie написал:
Hi,

I'm looking for some feedback regarding making my plugin work in distributed Jenkins (master/slave) setups.
For now I have made a "private static class DeployCallable extends MasterToSlaveCallable<Boolean, InterruptedException>" internal class 
with all my code being inside the "public Boolean call() throws InterruptedException" method.
I then just call this method with "launcher.getChannel().call(deployCallable)".

<a href="https://github.com/jenkinsci/osf-builder-suite-for-sfcc-deploy-plugin/blob/master/src/main/java/org/jenkinsci/plugins/osfbuildersuiteforsfcc/deploy/DeployBuilder.java#L413" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fosf-builder-suite-for-sfcc-deploy-plugin%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Forg%2Fjenkinsci%2Fplugins%2Fosfbuildersuiteforsfcc%2Fdeploy%2FDeployBuilder.java%23L413\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFZtzZHy4DEi7Pdh0g-oTBU0qZYYw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fosf-builder-suite-for-sfcc-deploy-plugin%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Forg%2Fjenkinsci%2Fplugins%2Fosfbuildersuiteforsfcc%2Fdeploy%2FDeployBuilder.java%23L413\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFZtzZHy4DEi7Pdh0g-oTBU0qZYYw&#39;;return true;">https://github.com/jenkinsci/osf-builder-suite-for-sfcc-deploy-plugin/blob/master/src/main/java/org/jenkinsci/plugins/osfbuildersuiteforsfcc/deploy/DeployBuilder.java#L413


I think current code should work in a distributed Jenkins (master/slave) setup.

I just have one problem, if a user cancels the build from the master my plugin does not get interrupted and still gets executed until the end and only then the job is marked as canceled even tough it still finished doing everything.

I have described this issue here <a href="https://issues.jenkins-ci.org/browse/JENKINS-46705" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-46705\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFKs3SWQWIA-sM7y75AnjLAiLQe9Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-46705\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFKs3SWQWIA-sM7y75AnjLAiLQe9Q&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-46705

Is there anything that I can do? I'm thinking of breaking my "do it all" "DeployCallable" into smaller pieces. Like one DeployCallable class to prepare the build and return a list of folders to be deployed, then another DeployCallable class that will zip one folder and iterate from master over the list returned by the first callable and then call this other Callable to zip one folder at a time, then another DeployCallable class that will upload the zip files and do the same iterate over the list of zips generated by the previous callable and call this Callable for each zip to upload it.

Would this make sense? I think in this case the interrupted exception might work? But my code will be more complicated and ugly.

What are my options? What can I do? 

Thank you.

--
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/698a2017-7536-4328-a239-fb491d658a49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.