diff options
author | Ola Aunrønning <olaa@verizonmedia.com> | 2022-04-08 13:29:51 +0200 |
---|---|---|
committer | Ola Aunrønning <olaa@verizonmedia.com> | 2022-04-08 13:29:51 +0200 |
commit | 462243dfe6153c2b5e3bf6b7d9eed8ddd204d835 (patch) | |
tree | 1ac7bf21c2a012b5c093962c8640b7a379d9039b /controller-server | |
parent | 6a6687ca516a3912cdb4669c36268b1bb5fb856b (diff) |
Add out-of-sync CMR state
Diffstat (limited to 'controller-server')
2 files changed, 30 insertions, 0 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainer.java index f7e085bd90f..39234973af3 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainer.java @@ -106,6 +106,10 @@ public class VcmrMaintainer extends ControllerMaintainer { return Status.REQUIRES_OPERATOR_ACTION; } + if (byActionState.getOrDefault(State.OUT_OF_SYNC, 0L) > 0) { + return Status.OUT_OF_SYNC; + } + if (byActionState.getOrDefault(State.RETIRING, 0L) > 0) { return Status.IN_PROGRESS; } @@ -170,6 +174,9 @@ public class VcmrMaintainer extends ControllerMaintainer { addReport(zoneId, changeRequest, node); + if (isOutOfSync(node, hostAction)) + return hostAction.withState(State.OUT_OF_SYNC); + if (isPostponed(changeRequest, hostAction)) { LOG.fine(() -> changeRequest.getChangeRequestSource().getId() + " is postponed, recycling " + node.hostname()); recycleNode(zoneId, node, hostAction); @@ -248,6 +255,12 @@ public class VcmrMaintainer extends ControllerMaintainer { && node.state() == Node.State.active; } + // Determines if node state is unexpected based on previous action taken + private boolean isOutOfSync(Node node, HostAction action) { + return action.getState() == State.RETIRED && node.state() != Node.State.parked || + action.getState() == State.RETIRING && !node.wantToRetire(); + } + private Map<ZoneId, List<Node>> nodesByZone() { return controller().zoneRegistry() .zones() diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainerTest.java index ad480bc1712..7f369d21d3a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainerTest.java @@ -227,6 +227,23 @@ public class VcmrMaintainerTest { assertEquals(State.PENDING_RETIREMENT, tenantAction2.getState()); } + @Test + public void out_of_sync_when_manual_reactivation() { + var nonRetiringNode = createNode(host1, NodeType.host, Node.State.active, false); + nodeRepo.putNodes(zoneId, nonRetiringNode); + + tester.curator().writeChangeRequest(inProgressChangeRequest()); + maintainer.maintain(); + + var writtenChangeRequest = tester.curator().readChangeRequest(changeRequestId).get(); + var actionPlan = writtenChangeRequest.getHostActionPlan(); + + var action = findHostAction(actionPlan, nonRetiringNode); + + assertEquals(State.OUT_OF_SYNC, action.getState()); + assertEquals(Status.OUT_OF_SYNC, writtenChangeRequest.getStatus()); + } + private VespaChangeRequest canceledChangeRequest() { return newChangeRequest(ChangeRequestSource.Status.CANCELED, State.RETIRED, State.RETIRING, ZonedDateTime.now()); } |