File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
java/src/org/openqa/selenium/grid/node Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,15 @@ public class NodeFlags implements HasRoles {
198198 @ ConfigValue (section = NODE_SECTION , name = "register-period" , example = "120" )
199199 public int registerPeriod = DEFAULT_REGISTER_PERIOD ;
200200
201+ @ Parameter (
202+ names = "--register-loopback" ,
203+ description =
204+ "If enable this flag, after register period is completed, the Node will shutdown itself."
205+ + " This is useful for container environments to restart and register again. If"
206+ + " restart multiple times, Node container status will be CrashLoopBackOff." )
207+ @ ConfigValue (section = NODE_SECTION , name = "register-loopback" , example = "false" )
208+ public boolean registerLoopBack = false ;
209+
201210 @ Parameter (
202211 names = "--heartbeat-period" ,
203212 description =
Original file line number Diff line number Diff line change @@ -205,6 +205,10 @@ public Duration getRegisterPeriod() {
205205 return Duration .ofSeconds (seconds );
206206 }
207207
208+ public boolean getRegisterLoopBack () {
209+ return config .getBool (NODE_SECTION , "register-loopback" ).orElse (false );
210+ }
211+
208212 public Duration getHeartbeatPeriod () {
209213 // If the user sets 0 or less, we default to 1s.
210214 int seconds =
Original file line number Diff line number Diff line change @@ -216,6 +216,17 @@ public NettyServer start() {
216216 .withMaxDuration (nodeOptions .getRegisterPeriod ())
217217 .withDelay (nodeOptions .getRegisterCycle ())
218218 .handleResultIf (result -> true )
219+ .onFailure (
220+ event -> {
221+ LOG .severe (
222+ String .format (
223+ "Registration event failed after period of %s seconds. Node will not attempt to register again." ,
224+ nodeOptions .getRegisterPeriod ().getSeconds ()));
225+ if (nodeOptions .getRegisterLoopBack ()) {
226+ LOG .severe ("Shutting down" );
227+ System .exit (1 );
228+ }
229+ })
219230 .build ();
220231
221232 LOG .info ("Starting registration process for Node " + node .getUri ());
You can’t perform that action at this time.
0 commit comments