aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2018-02-08 14:57:10 +0100
committerGitHub <noreply@github.com>2018-02-08 14:57:10 +0100
commit3c46d5b0b5e4b72be914eac47d58eee1b9cec7cf (patch)
tree368b1d4b60c439f1391a1326ff26577d2c9563d7
parent07a796e91d91f1c12c6d4a148ed7714da4ea2b63 (diff)
parent0685a5ec817a523bb6c1234eeda4e545979f8010 (diff)
Merge pull request #4969 from vespa-engine/freva/retire-if-children-are-parked
Retire host if children are parked
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirer.java7
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java9
2 files changed, 13 insertions, 3 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirer.java
index 6d82dfb7b4e..5cfb9d73c91 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirer.java
@@ -86,14 +86,17 @@ public class RetiredExpirer extends Maintainer {
/**
* Checks if the node can be removed:
- * if the node is {@link NodeType#host}, it will only be removed if it has no children
+ * if the node is {@link NodeType#host}, it will only be removed if it has no children,
+ * or all its children are parked or failed
* Otherwise, a removal is allowed if either of these are true:
* - The node has been in state {@link History.Event.Type#retired} for longer than {@link #retiredExpiry}
* - Orchestrator allows it
*/
private boolean canRemove(Node node) {
if (node.type() == NodeType.host) {
- return nodeRepository().getChildNodes(node.hostname()).isEmpty();
+ return nodeRepository()
+ .getChildNodes(node.hostname()).stream()
+ .allMatch(child -> child.state() == Node.State.parked || child.state() == Node.State.failed);
}
Optional<Instant> timeOfRetiredEvent = node.history().event(History.Event.Type.retired).map(History.Event::at);
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
index b04990928ba..85322ae1c91 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
@@ -33,6 +33,7 @@ public class NodePatcher {
private static final String HARDWARE_FAILURE_DESCRIPTION = "hardwareFailureDescription";
private static final String WANT_TO_RETIRE = "wantToRetire";
+ private static final String WANT_TO_DEPROVISION = "wantToDeprovision";
private final NodeFlavors nodeFlavors;
private final Inspector inspector;
@@ -94,6 +95,12 @@ public class NodePatcher {
return childNodes.stream()
.map(child -> child.with(child.status().withWantToRetire(asBoolean(value))))
.collect(Collectors.toList());
+
+ case WANT_TO_DEPROVISION:
+ return childNodes.stream()
+ .map(child -> child.with(child.status().withWantToDeprovision(asBoolean(value))))
+ .collect(Collectors.toList());
+
default :
throw new IllegalArgumentException("Field " + name + " is not recursive");
}
@@ -132,7 +139,7 @@ public class NodePatcher {
return node.withAdditionalIpAddresses(asStringSet(value));
case WANT_TO_RETIRE :
return node.with(node.status().withWantToRetire(asBoolean(value)));
- case "wantToDeprovision" :
+ case WANT_TO_DEPROVISION :
return node.with(node.status().withWantToDeprovision(asBoolean(value)));
case "hardwareDivergence" :
return node.with(node.status().withHardwareDivergence(removeQuotedNulls(asOptionalString(value))));