aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src
diff options
context:
space:
mode:
authorOla Aunronning <olaa@yahooinc.com>2023-04-12 14:54:44 +0200
committerOla Aunronning <olaa@yahooinc.com>2023-04-12 14:54:44 +0200
commitb353e521fd996a8062abe43e25dca03572ed1b0b (patch)
treeb01301a4c8aa0b93565fdeeabbeb7ce789da75dc /controller-server/src
parent84bcda7387c5b69428a994f434f87f979200f734 (diff)
Don't rewrite CMR report. Add status field
Diffstat (limited to 'controller-server/src')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainer.java16
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/VcmrMaintainerTest.java2
2 files changed, 14 insertions, 4 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 9271f870390..3e535b28b43 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
@@ -176,7 +176,8 @@ public class VcmrMaintainer extends ControllerMaintainer {
if (isLowImpact(changeRequest))
return hostAction;
- addReport(zoneId, changeRequest, node);
+ if (shouldAddReport(node, changeRequest.getChangeRequestSource().getId(), hostAction))
+ addReport(zoneId, changeRequest, node);
if (isOutOfSync(node, hostAction))
return hostAction.withState(State.OUT_OF_SYNC);
@@ -267,6 +268,16 @@ public class VcmrMaintainer extends ControllerMaintainer {
&& node.state() == Node.State.active;
}
+ private boolean shouldAddReport(Node node, String vcmrId, HostAction previousAction) {
+ var vcmrReport = VcmrReport.fromReports(node.reports());
+ var hasReport = vcmrReport.getVcmrs().stream().map(VcmrReport.Vcmr::getId).anyMatch(id -> id.equals(vcmrId));
+ // Don't add report if none exists and this is not initial assessment
+ // Presumably removed manually by operator.
+ if (!hasReport && previousAction.getState() != State.NONE)
+ return false;
+ return true;
+ }
+
// 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 ||
@@ -343,8 +354,7 @@ public class VcmrMaintainer extends ControllerMaintainer {
private void addReport(ZoneId zoneId, VespaChangeRequest changeRequest, Node node) {
var report = VcmrReport.fromReports(node.reports());
- var source = changeRequest.getChangeRequestSource();
- if (report.addVcmr(source.getId(), source.getPlannedStartTime(), source.getPlannedEndTime())) {
+ if (report.addVcmr(changeRequest.getChangeRequestSource())) {
updateReport(zoneId, node, report);
}
}
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 52bd8e9c618..5bd7b341ef1 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
@@ -58,7 +58,7 @@ public class VcmrMaintainerTest {
@Test
void recycle_hosts_after_completion() {
var vcmrReport = new VcmrReport();
- vcmrReport.addVcmr("id123", ZonedDateTime.now(), ZonedDateTime.now());
+ vcmrReport.addVcmr(new ChangeRequestSource("aws", "id123", "url", ChangeRequestSource.Status.WAITING_FOR_APPROVAL , ZonedDateTime.now(), ZonedDateTime.now()));
var parkedNode = createNode(host1, NodeType.host, Node.State.parked, true);
var failedNode = createNode(host2, NodeType.host, Node.State.failed, false);
var reports = vcmrReport.toNodeReports();