Immediately exit cluster controller if node index config is changed live
We do not support live reconfigs of CC index, so swiftly exit if we
detect this, allowing the config sentinel to restart the service.
@@ -70,6 +70,7 @@ public class FleetController implements NodeStateOrHostInfoChangeHandler, NodeAd
private final AtomicBoolean running = new AtomicBoolean(true);
private FleetControllerOptions options;
private FleetControllerOptions nextOptions;
+ private final int configuredIndex;
private final List<SystemStateListener> systemStateListeners = new CopyOnWriteArrayList<>();
private boolean processingCycle = false;
private boolean wantedStateChanged = false;
@@ -125,6 +126,7 @@ public class FleetController implements NodeStateOrHostInfoChangeHandler, NodeAd
MetricUpdater metricUpdater,
FleetControllerOptions options) {
log.info("Starting up cluster controller " + options.fleetControllerIndex + " for cluster " + cluster.getName());
+ this.configuredIndex = options.fleetControllerIndex;
this.timer = timer;
this.monitor = timer;
this.eventLog = eventLog;
@@ -487,6 +489,7 @@ public class FleetController implements NodeStateOrHostInfoChangeHandler, NodeAd
/** This is called when the options field has been set to a new set of options */
private void propagateOptions() {
verifyInControllerThread();
+ selfTerminateIfConfiguredNodeIndexHasChanged();
if (changesConfiguredNodeSet(options.nodes)) {
// Force slobrok node re-fetch in case of changes to the set of configured nodes
@@ -544,6 +547,16 @@ public class FleetController implements NodeStateOrHostInfoChangeHandler, NodeAd
nextConfigGeneration = -1;
}
+ private void selfTerminateIfConfiguredNodeIndexHasChanged() {
+ if (options.fleetControllerIndex != configuredIndex) {
+ log.warning(String.format("Got new configuration where CC index has changed from %d to %d. We do not support "+
+ "doing this live; immediately exiting now to force new configuration",
+ configuredIndex, options.fleetControllerIndex));
+ prepareShutdownEdge();
+ System.exit(1);
+ }
+ }
+
public StatusPageResponse fetchStatusPage(StatusPageServer.HttpRequest httpRequest) {
verifyInControllerThread();
StatusPageResponse.ResponseCode responseCode;
@@ -1103,11 +1116,15 @@ public class FleetController implements NodeStateOrHostInfoChangeHandler, NodeAd
synchronized (monitor) { running.set(false); }
System.exit(1);
} finally {
+ prepareShutdownEdge();
+ }
+ }
+
+ private void prepareShutdownEdge() {
running.set(false);
failAllVersionDependentTasks();
synchronized (monitor) { monitor.notifyAll(); }
}
- }
public DatabaseHandler.Context databaseContext = new DatabaseHandler.Context() {
@Override
