Stop process started by MasterToSlaveCallable when connection to master is lost

38 views
Skip to first unread message

Rouke Broersma

unread,
Jun 10, 2016, 1:20:33 PM6/10/16
to Jenkins Developers
I am a maintainer of the selenium grid plugin, and as part of our plugin we start potentially multiple processes on slaves (selenium nodes, as part of a distributed selenium grid).
We have implemented the RestartListener to shutdown all our selenium nodes on the slaves when Jenkins is restarting, but I am unable to find how to do this when the master becomes unavailable for some reason.

As in, when the master becomes unavailable to a slave, I want to be able to have the slave shut down it's selenium node processes. This is necessary because selenium contains an automatic reconnect mechanism,
so if the connection to master is lost for unexpected reasons, we would end up with duplicate selenium nodes on the slaves (plugin tries to create new node on all slaves that become available and match the criteria).
This is undesirable.

So I would like to know, is there a way to tell Jenkins slaves to clean up any processes I started when it no longer has a connection to master?

Jesse Glick

unread,
Jun 10, 2016, 3:30:34 PM6/10/16
to Jenkins Dev
On Fri, Jun 10, 2016 at 1:20 PM, Rouke Broersma <mobro...@gmail.com> wrote:
> when the master becomes unavailable to a slave, I want to be able to
> have the slave shut down it's selenium node processes.

Of course if you are using Pipeline builds, they should be able to
just keep running, and reattach the log file when the master is back
up and the agent is connected to it again.

Rouke Broersma

unread,
Jun 10, 2016, 3:36:37 PM6/10/16
to Jenkins Dev

Um what? Pipeline builds have nothing whatsoever to do with the plugin. The plugin starts a process on boot that anyone can freely use, has nothing to do with builds.


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/bOZLnvre19o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2YAUQHHck4sET3pBfmqhEwp1np1kdKmcGDQcWCtV5aJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Rouke Broersma

unread,
Jun 18, 2016, 7:24:03 AM6/18/16
to Jenkins Developers
Does anyone have any idea if this is possible in any way?

Jesse Glick

unread,
Jun 20, 2016, 11:54:20 AM6/20/16
to Jenkins Dev
On Sat, Jun 18, 2016 at 7:24 AM, Rouke Broersma <mobro...@gmail.com> wrote:
> Does anyone have any idea if this is possible in any way?

If you are asking whether there is a listener on the _agent_ side for
a disconnection, I am not aware of one. `ComputerListener` runs on the
master side. Even if there were a hook run on the agent side, it is
questionable whether it would work reliably: an implementation would
need to be very careful to force all required classes to have been
loaded into the agent JVM while the connection was still alive, since
after disconnection any stray code that runs which attempts to load
novel classes will simply get `NoClassDefFoundError`s.

Rouke Broersma

unread,
Jun 20, 2016, 11:56:48 AM6/20/16
to Jenkins Developers
Yea I figured as much, thanks :/
Reply all
Reply to author
Forward
0 new messages