Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions java/src/org/openqa/selenium/grid/node/config/NodeFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ public class NodeFlags implements HasRoles {
@ConfigValue(section = NODE_SECTION, name = "register-period", example = "120")
public int registerPeriod = DEFAULT_REGISTER_PERIOD;

@Parameter(
names = "--register-shutdown-on-failure",
description =
"If this flag is enabled, the Node will shut down after the register period is completed."
+ " This is useful for container environments to restart and register again. If"
+ " restarted multiple times, the Node container status will be CrashLoopBackOff.")
@ConfigValue(section = NODE_SECTION, name = "register-shutdown-on-failure", example = "false")
public boolean registerShutdownOnFailure = false;

@Parameter(
names = "--heartbeat-period",
description =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ public Duration getRegisterPeriod() {
return Duration.ofSeconds(seconds);
}

public boolean getRegisterShutdownOnFailure() {
return config.getBool(NODE_SECTION, "register-shutdown-on-failure").orElse(false);
}

public Duration getHeartbeatPeriod() {
// If the user sets 0 or less, we default to 1s.
int seconds =
Expand Down
12 changes: 12 additions & 0 deletions java/src/org/openqa/selenium/grid/node/httpd/NodeServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ public NettyServer start() {
.withMaxDuration(nodeOptions.getRegisterPeriod())
.withDelay(nodeOptions.getRegisterCycle())
.handleResultIf(result -> true)
.onFailure(
event -> {
LOG.severe(
String.format(
"Registration event failed after period of %s seconds. Node will not"
+ " attempt to register again",
nodeOptions.getRegisterPeriod().getSeconds()));
if (nodeOptions.getRegisterShutdownOnFailure()) {
LOG.severe("Shutting down");
System.exit(1);
}
})
.build();

LOG.info("Starting registration process for Node " + node.getUri());
Expand Down
Loading