Avoid eventual expiry of cfglike node
@@ -27,7 +27,8 @@ import java.util.stream.Collectors;
*/
public class RetiredExpirer extends NodeRepositoryMaintainer {
- public static final int NUM_CONFIG_SERVERS = 3;
+ private static final int NUM_CONFIG_SERVERS = 3;
+
private final Deployer deployer;
private final Metric metric;
private final Orchestrator orchestrator;
@@ -87,9 +88,18 @@ public class RetiredExpirer extends NodeRepositoryMaintainer {
if (nodeRepository().nodes().list().childrenOf(node).asList().stream()
.allMatch(child -> child.state() == Node.State.parked ||
child.state() == Node.State.failed)) {
+ log.info("Host " + node + " has no non-parked/failed children");
+ return true;
+ }
+
+ return false;
+ }
+
+ if (node.type().isConfigServerLike()) {
+ // Avoid eventual expiry of configserver-like nodes
- if (node.type().isConfigServerLike() && activeNodes.nodeType(node.type()).asSet().size() < NUM_CONFIG_SERVERS) {
- // Scenario: All 3 controllers want to retire.
+ if (activeNodes.nodeType(node.type()).asSet().size() < NUM_CONFIG_SERVERS) {
+ // Scenario: All 3 config servers want to retire.
//
// Say RetiredExpirer runs on cfg1 and gives cfg2 permission to be removed (PERMANENTLY_DOWN in ZK).
// The consequent redeployment moves cfg2 to inactive, removing cfg2 from the application,
@@ -110,14 +120,7 @@ public class RetiredExpirer extends NodeRepositoryMaintainer {
// allowing the removal of any config server.
return false;
}
- log.info("Host " + node + " has no non-parked/failed children");
- return true;
- }
-
- return false;
- }
-
- if (node.history().hasEventBefore(History.Event.Type.retired, clock().instant().minus(retiredExpiry))) {
+ } else if (node.history().hasEventBefore(History.Event.Type.retired, clock().instant().minus(retiredExpiry))) {
log.warning("Node " + node + " has been retired longer than " + retiredExpiry + ": Allowing removal. This may cause data loss");
return true;
}
