plugin to validate agents before allowing jobs to run

26 views
Skip to first unread message

Antonio Beyah

unread,
Mar 16, 2016, 9:33:04 PM3/16/16
to Jenkins Developers
I have recently started using the Jenkins Swarm plugin which grants us the ability to allow dynamic agents to join the cluster, I am thinking about writing a plugin that would perform a set of actions before the agent is allowed to take jobs, irrespective of the 'mode' or 'label' assignments.

When a new agent joins, I would like to be able to run a set of tests, or jobs that would signify whether or not the agent is capable of taking on real jobs.  Things such as: checkout code from scm, run a gradle build, etc

My thinking for implementation:
- When an agent joins the cluster, don't allow it to take any jobs until it is vetted
- To vet the agent, a set of jobs would all be required to pass (run and return a success)

More implementation details:
1) When an agent joins, immediately set its mode to 'exclusive' and change all labels to <label>_candidate
2) Do a search for any job with the <label>_candidate restriction and run those jobs
3) If those jobs are all successful, remove the <label>_candidate label and set the mode back to its original setting

My questions:
1) Is there a better way to do this?
2) What extension points should I look at to do this?  So far I have started looking at hudson.slaves.ComputerListener but am unsure if I can hook in early enough to prevent any jobs from running on the newly added agent before changing it
3) Does a plugin already exist that does this or have similar behavior?

Any guidance would be appreciated.

Thanks!
Antonio

Robert Sandell

unread,
Mar 17, 2016, 10:35:38 AM3/17/16
to jenkin...@googlegroups.com
You could use a QueueTaskDispatcher [1] to block any builds (except the vetting jobs) from running on the node until it has cleared the vetting process. And using the NodeLabel parameter plugin [2] you could schedule a job to run on a specific Node (the one that just connected).
You could also use an OptionalJobPropery [3] to mark specific jobs as being specially for this purpose or maybe pick all jobs in a special Folder [4].
/B

--
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 jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/98cf67d2-58c1-4634-9579-07116751db57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.

Antonio Beyah

unread,
Mar 18, 2016, 11:28:56 AM3/18/16
to Jenkins Developers
Thank you, I will try this out and reach out if I have any questions.

Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages