Remove deprovisioning child node when readied
@@ -471,7 +471,7 @@ public class Nodes {
*/
public Node markNodeAvailableForNewAllocation(String hostname, Agent agent, String reason) {
Node node = requireNode(hostname);
- if (node.flavor().getType() == Flavor.Type.DOCKER_CONTAINER && node.type() == NodeType.tenant) {
+ if (removeOnReadyingOf(node)) {
if (node.state() != Node.State.dirty)
illegal("Cannot make " + node + " available for new allocation as it is not in state [dirty]");
return removeRecursively(node, true).get(0);
@@ -846,6 +846,12 @@ public class Nodes {
retirementRequestedByOperator;
}
+ /** Returns whether node should be deleted when it's moved to ready */
+ private static boolean removeOnReadyingOf(Node node) {
+ if (node.flavor().getType() != Flavor.Type.DOCKER_CONTAINER) return false;
+ return node.type() == NodeType.tenant || (node.status().wantToRetire() && node.status().wantToDeprovision());
+ }
+
/** The different ways a host can be decommissioned */
private enum DecommissionOperation {
deprovision,
