diff options
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VcmrReport.java (renamed from controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VCMRReport.java) | 31 | ||||
-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 |
5 files changed, 48 insertions, 45 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VCMRReport.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VcmrReport.java index 3597c7eb009..fdd382e9007 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VCMRReport.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/VcmrReport.java @@ -17,29 +17,30 @@ import java.util.Set; import static com.yahoo.yolean.Exceptions.uncheck; /** - * @author olaa * * Node repository report containing list of upcoming VCMRs impacting a node + * + * @author olaa */ @JsonIgnoreProperties(ignoreUnknown = true) -public class VCMRReport { +public class VcmrReport { private static final String REPORT_ID = "vcmr"; private static final ObjectMapper objectMapper = new ObjectMapper() .registerModule(new JavaTimeModule()); @JsonProperty("upcoming") - private Set<VCMR> vcmrs; + private Set<Vcmr> vcmrs; - public VCMRReport() { + public VcmrReport() { this(new HashSet<>()); } - public VCMRReport(Set<VCMR> vcmrs) { + public VcmrReport(Set<Vcmr> vcmrs) { this.vcmrs = vcmrs; } - public Set<VCMR> getVcmrs() { + public Set<Vcmr> getVcmrs() { return vcmrs; } @@ -47,7 +48,7 @@ public class VCMRReport { * @return true if list of VCMRs is changed */ public boolean addVcmr(String id, ZonedDateTime plannedStartTime, ZonedDateTime plannedEndtime) { - var vcmr = new VCMR(id, plannedStartTime, plannedEndtime); + var vcmr = new Vcmr(id, plannedStartTime, plannedEndtime); if (vcmrs.contains(vcmr)) return false; @@ -67,12 +68,12 @@ public class VCMRReport { /** * Serialization functions - mapped to {@link Node#reports()} */ - public static VCMRReport fromReports(Map<String, String> reports) { + public static VcmrReport fromReports(Map<String, String> reports) { var serialized = reports.get(REPORT_ID); if (serialized == null) - return new VCMRReport(); + return new VcmrReport(); - return uncheck(() -> objectMapper.readValue(serialized, VCMRReport.class)); + return uncheck(() -> objectMapper.readValue(serialized, VcmrReport.class)); } /** @@ -92,15 +93,15 @@ public class VCMRReport { return "VCMRReport{" + vcmrs + "}"; } - public static class VCMR { + public static class Vcmr { private String id; private ZonedDateTime plannedStartTime; private ZonedDateTime plannedEndTime; - VCMR(@JsonProperty("id") String id, - @JsonProperty("plannedStartTime") ZonedDateTime plannedStartTime, - @JsonProperty("plannedEndTime") ZonedDateTime plannedEndTime) { + Vcmr(@JsonProperty("id") String id, + @JsonProperty("plannedStartTime") ZonedDateTime plannedStartTime, + @JsonProperty("plannedEndTime") ZonedDateTime plannedEndTime) { this.id = id; this.plannedStartTime = plannedStartTime; this.plannedEndTime = plannedEndTime; @@ -122,7 +123,7 @@ public class VCMRReport { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - VCMR vcmr = (VCMR) o; + Vcmr vcmr = (Vcmr) o; return Objects.equals(id, vcmr.id) && Objects.equals(plannedStartTime, vcmr.plannedStartTime) && Objects.equals(plannedEndTime, vcmr.plannedEndTime); 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" |