diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-06-01 09:05:43 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-06-01 09:05:43 +0200 |
commit | 4c328e70d3e20d501ee2ded5a59b1c4910b3563d (patch) | |
tree | c6ff4b92915b4bd9455dbac8cfb2b6d38b42ce1a | |
parent | 53d102f6d2a062d2aa88ace0422889838c9d8db4 (diff) |
Set wantToEncrypt for children
This ensures that children of infrastructure hosts are parked when expiring from
inactive.
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java | 20 | ||||
-rw-r--r-- | node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostEncrypterTest.java | 2 |
2 files changed, 14 insertions, 8 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java index 70fac32f7a6..3afe5824af5 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java @@ -248,7 +248,7 @@ public class Nodes { public List<Node> fail(List<Node> nodes, Agent agent, String reason) { NestedTransaction transaction = new NestedTransaction(); nodes = fail(nodes, agent, reason, transaction); - transaction.commit();; + transaction.commit(); return nodes; } @@ -642,16 +642,22 @@ public class Nodes { List<Node> result; boolean wantToDeprovision = op == DecommissionOperation.deprovision; boolean wantToRebuild = op == DecommissionOperation.rebuild; + Optional<Report> wantToEncryptReport = op == DecommissionOperation.encrypt + ? Optional.of(Report.basicReport(Report.WANT_TO_ENCRYPT_ID, Report.Type.UNSPECIFIED, instant, "")) + : Optional.empty(); try (NodeMutex lock = nodeMutex.get(); Mutex allocationLock = lockUnallocated()) { // This takes allocationLock to prevent any further allocation of nodes on this host host = lock.node(); - result = performOn(list(allocationLock).childrenOf(host), - (node, nodeLock) -> write(node.withWantToRetire(true, wantToDeprovision, wantToRebuild, agent, instant), - nodeLock)); + result = performOn(list(allocationLock).childrenOf(host), (node, nodeLock) -> { + Node newNode = node.withWantToRetire(true, wantToDeprovision, wantToRebuild, agent, instant); + if (wantToEncryptReport.isPresent()) { + newNode = newNode.with(newNode.reports().withReport(wantToEncryptReport.get())); + } + return write(newNode, nodeLock); + }); Node newHost = host.withWantToRetire(true, wantToDeprovision, wantToRebuild, agent, instant); - if (op == DecommissionOperation.encrypt) { - Report report = Report.basicReport(Report.WANT_TO_ENCRYPT_ID, Report.Type.UNSPECIFIED, instant, ""); - newHost = newHost.with(newHost.reports().withReport(report)); + if (wantToEncryptReport.isPresent()) { + newHost = newHost.with(newHost.reports().withReport(wantToEncryptReport.get())); } result.add(write(newHost, lock)); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostEncrypterTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostEncrypterTest.java index 4df7526c07f..010fc40ded7 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostEncrypterTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostEncrypterTest.java @@ -70,7 +70,7 @@ public class HostEncrypterTest { assertEquals(owners.size(), hostsEncrypting.size()); for (int i = 0; i < hostsEncrypting.size(); i++) { Optional<ApplicationId> owner = owners.get(i); - List<Node> retiringChildren = allNodes.childrenOf(hostsEncrypting.get(i)).retiring().asList(); + List<Node> retiringChildren = allNodes.childrenOf(hostsEncrypting.get(i)).retiring().encrypting().asList(); assertEquals(owner.isPresent() ? 1 : 0, retiringChildren.size()); assertEquals("Encrypting host of " + owner.map(ApplicationId::toString) .orElse("no application"), |