diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-07-15 09:54:10 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-07-16 09:02:31 +0200 |
commit | 0b0140b6f0667cc09380a0d0e173f7c5ba8812ce (patch) | |
tree | f8e4c2e1b9690e2f2eb2717f261ca74558346f80 /controller-server | |
parent | 6a558ebb82bb58b42990ff7dad8af35c70812424 (diff) |
VCMR -> Vcmr
Diffstat (limited to 'controller-server')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java | 3 | ||||
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainer.java (renamed from controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VCMRMaintainer.java) | 45 | ||||
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainerTest.java (renamed from controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/VCMRMaintainerTest.java) | 12 | ||||
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json | 2 |
4 files changed, 32 insertions, 30 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java index 56bf870c7fc..668ca0f4ee1 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java @@ -10,7 +10,6 @@ import com.yahoo.jdisc.Metric; import com.yahoo.vespa.hosted.controller.Controller; import java.time.Duration; -import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalUnit; import java.util.Collections; import java.util.List; @@ -71,7 +70,7 @@ public class ControllerMaintenance extends AbstractComponent { maintainers.add(new ArchiveAccessMaintainer(controller, metric, intervals.archiveAccessMaintainer)); maintainers.add(new TenantRoleMaintainer(controller, intervals.tenantRoleMaintainer)); maintainers.add(new ChangeRequestMaintainer(controller, intervals.changeRequestMaintainer)); - maintainers.add(new VCMRMaintainer(controller, intervals.vcmrMaintainer)); + maintainers.add(new VcmrMaintainer(controller, intervals.vcmrMaintainer)); maintainers.add(new CloudTrialExpirer(controller, intervals.defaultInterval)); maintainers.add(new RetriggerMaintainer(controller, intervals.retriggerMaintainer)); } 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 96ba87575e4..69c9bd83ba5 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 @@ -14,7 +14,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.vcmr.ChangeRequest.Impa import com.yahoo.vespa.hosted.controller.api.integration.vcmr.ChangeRequestClient; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.HostAction; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.HostAction.State; -import com.yahoo.vespa.hosted.controller.api.integration.vcmr.VCMRReport; +import com.yahoo.vespa.hosted.controller.api.integration.vcmr.VcmrReport; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.VespaChangeRequest; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.VespaChangeRequest.Status; import com.yahoo.vespa.hosted.controller.persistence.CuratorDb; @@ -32,22 +32,25 @@ import java.util.logging.Logger; import java.util.stream.Collectors; /** - * @author olaa * - * Maintains status and execution of VCMRs - * For now only retires all affected tenant hosts if zone capacity allows it + * Maintains status and execution of Vespa CMRs. + * + * Currently this retires all affected tenant hosts if zone capacity allows it. + * + * @author olaa */ -public class VCMRMaintainer extends ControllerMaintainer { +public class VcmrMaintainer extends ControllerMaintainer { + + private static final Logger LOG = Logger.getLogger(VcmrMaintainer.class.getName()); + private static final Duration ALLOWED_RETIREMENT_TIME = Duration.ofHours(60); + private static final Duration ALLOWED_POSTPONEMENT_TIME = Duration.ofDays(7); - private final Logger logger = Logger.getLogger(VCMRMaintainer.class.getName()); - private final Duration ALLOWED_RETIREMENT_TIME = Duration.ofHours(60); - private final Duration ALLOWED_POSTPONEMENT_TIME = Duration.ofDays(7); private final CuratorDb curator; private final NodeRepository nodeRepository; private final ChangeRequestClient changeRequestClient; private final SystemName system; - public VCMRMaintainer(Controller controller, Duration interval) { + public VcmrMaintainer(Controller controller, Duration interval) { super(controller, interval, null, SystemName.allOf(Predicate.not(SystemName::isPublic))); this.curator = controller.curator(); this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); @@ -142,7 +145,7 @@ public class VCMRMaintainer extends ControllerMaintainer { .orElse(new HostAction(node.hostname().value(), State.NONE, Instant.now())); if (changeRequest.getChangeRequestSource().isClosed()) { - logger.fine(() -> changeRequest.getChangeRequestSource().getId() + " is closed, recycling " + node.hostname()); + LOG.fine(() -> changeRequest.getChangeRequestSource().getId() + " is closed, recycling " + node.hostname()); recycleNode(changeRequest.getZoneId(), node, hostAction); removeReport(changeRequest, node); return hostAction.withState(State.COMPLETE); @@ -154,7 +157,7 @@ public class VCMRMaintainer extends ControllerMaintainer { addReport(changeRequest, node); if (isPostponed(changeRequest, hostAction)) { - logger.fine(() -> changeRequest.getChangeRequestSource().getId() + " is postponed, recycling " + node.hostname()); + LOG.fine(() -> changeRequest.getChangeRequestSource().getId() + " is postponed, recycling " + node.hostname()); recycleNode(changeRequest.getZoneId(), node, hostAction); return hostAction.withState(State.PENDING_RETIREMENT); } @@ -165,12 +168,12 @@ public class VCMRMaintainer extends ControllerMaintainer { if (shouldRetire(changeRequest, hostAction)) { if (!node.wantToRetire()) { - logger.info(Text.format("Retiring %s due to %s", node.hostname().value(), changeRequest.getChangeRequestSource().getId())); + LOG.info(Text.format("Retiring %s due to %s", node.hostname().value(), changeRequest.getChangeRequestSource().getId())); // TODO: Remove try/catch once retirement is stabilized try { setWantToRetire(changeRequest.getZoneId(), node, true); } catch (Exception e) { - logger.warning("Failed to retire host " + node.hostname() + ": " + Exceptions.toMessageString(e)); + LOG.warning("Failed to retire host " + node.hostname() + ": " + Exceptions.toMessageString(e)); // Check if retirement actually failed if (!nodeRepository.getNode(changeRequest.getZoneId(), node.hostname().value()).wantToRetire()) { return hostAction; @@ -181,12 +184,12 @@ public class VCMRMaintainer extends ControllerMaintainer { } if (hasRetired(node, hostAction)) { - logger.fine(() -> node.hostname() + " has retired"); + LOG.fine(() -> node.hostname() + " has retired"); return hostAction.withState(State.RETIRED); } if (pendingRetirement(node, hostAction)) { - logger.fine(() -> node.hostname() + " is pending retirement"); + LOG.fine(() -> node.hostname() + " is pending retirement"); return hostAction.withState(State.PENDING_RETIREMENT); } @@ -197,7 +200,7 @@ public class VCMRMaintainer extends ControllerMaintainer { private void recycleNode(ZoneId zoneId, Node node, HostAction hostAction) { if (hostAction.getState() == State.RETIRED && node.state() == Node.State.parked) { - logger.info("Setting " + node.hostname() + " to dirty"); + LOG.info("Setting " + node.hostname() + " to dirty"); nodeRepository.setState(zoneId, Node.State.dirty, node.hostname().value()); } if (hostAction.getState() == State.RETIRING && node.wantToRetire()) { @@ -283,12 +286,12 @@ public class VCMRMaintainer extends ControllerMaintainer { if (changeRequest.getApproval() != ChangeRequest.Approval.REQUESTED) return; - logger.info("Approving " + changeRequest.getChangeRequestSource().getId()); + LOG.info("Approving " + changeRequest.getChangeRequestSource().getId()); changeRequestClient.approveChangeRequest(changeRequest); } private void removeReport(VespaChangeRequest changeRequest, Node node) { - var report = VCMRReport.fromReports(node.reports()); + var report = VcmrReport.fromReports(node.reports()); if (report.removeVcmr(changeRequest.getChangeRequestSource().getId())) { updateReport(changeRequest.getZoneId(), node, report); @@ -296,7 +299,7 @@ public class VCMRMaintainer extends ControllerMaintainer { } private void addReport(VespaChangeRequest changeRequest, Node node) { - var report = VCMRReport.fromReports(node.reports()); + var report = VcmrReport.fromReports(node.reports()); var source = changeRequest.getChangeRequestSource(); if (report.addVcmr(source.getId(), source.getPlannedStartTime(), source.getPlannedEndTime())) { @@ -304,8 +307,8 @@ public class VCMRMaintainer extends ControllerMaintainer { } } - private void updateReport(ZoneId zoneId, Node node, VCMRReport report) { - logger.info(Text.format("Updating report for %s: %s", node.hostname(), report)); + private void updateReport(ZoneId zoneId, Node node, VcmrReport report) { + LOG.info(Text.format("Updating report for %s: %s", node.hostname(), report)); nodeRepository.updateReports(zoneId, node.hostname().value(), report.toNodeReports()); } 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 f957b14ef95..1d66434ea42 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 @@ -9,7 +9,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.vcmr.ChangeRequest; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.ChangeRequestSource; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.HostAction; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.HostAction.State; -import com.yahoo.vespa.hosted.controller.api.integration.vcmr.VCMRReport; +import com.yahoo.vespa.hosted.controller.api.integration.vcmr.VcmrReport; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.VespaChangeRequest; import com.yahoo.vespa.hosted.controller.api.integration.vcmr.VespaChangeRequest.Status; import com.yahoo.vespa.hosted.controller.integration.NodeRepositoryMock; @@ -30,10 +30,10 @@ import static org.junit.Assert.assertTrue; /** * @author olaa */ -public class VCMRMaintainerTest { +public class VcmrMaintainerTest { private ControllerTester tester; - private VCMRMaintainer maintainer; + private VcmrMaintainer maintainer; private NodeRepositoryMock nodeRepo; private final ZoneId zoneId = ZoneId.from("prod.us-east-3"); private final HostName host1 = HostName.from("host1"); @@ -43,13 +43,13 @@ public class VCMRMaintainerTest { @Before public void setup() { tester = new ControllerTester(); - maintainer = new VCMRMaintainer(tester.controller(), Duration.ofMinutes(1)); + maintainer = new VcmrMaintainer(tester.controller(), Duration.ofMinutes(1)); nodeRepo = tester.serviceRegistry().configServer().nodeRepository().allowPatching(true); } @Test public void recycle_hosts_after_completion() { - var vcmrReport = new VCMRReport(); + var vcmrReport = new VcmrReport(); vcmrReport.addVcmr("id123", ZonedDateTime.now(), ZonedDateTime.now()); var parkedNode = createNode(host1, NodeType.host, Node.State.parked, true); var failedNode = createNode(host2, NodeType.host, Node.State.failed, false); @@ -169,7 +169,7 @@ public class VCMRMaintainerTest { assertEquals(1, approvedChangeRequests.size()); activeNode = nodeRepo.list(zoneId, List.of(host2)).get(0); - var report = VCMRReport.fromReports(activeNode.reports()); + var report = VcmrReport.fromReports(activeNode.reports()); var reportAdded = report.getVcmrs().stream() .filter(vcmr -> vcmr.getId().equals(changeRequestId)) .count() == 1; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json index 668baa50cc1..3a7e6e63574 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json @@ -100,7 +100,7 @@ "name": "Upgrader" }, { - "name": "VCMRMaintainer" + "name": "VcmrMaintainer" }, { "name": "VersionStatusUpdater" |