diff options
author | HÃ¥kon Hallingstad <hakon.hallingstad@gmail.com> | 2021-01-06 10:32:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-06 10:32:15 +0100 |
commit | 21da42e562beb1cf132118d47170e65b4750efee (patch) | |
tree | ec1a83b3442ea182fc3c680d2fa190854f035bb2 /controller-api | |
parent | 130ac9c430496b5e31098818bff19b869d6c9f44 (diff) |
Revert "Revert "Make clients use orchestratorStatus instead of allowedToBeDown""
Diffstat (limited to 'controller-api')
4 files changed, 33 insertions, 11 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java index 04f1448bec1..b9a81ba8a02 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java @@ -263,7 +263,9 @@ public class Node { public enum ServiceState { expectedUp, allowedDown, - unorchestrated + permanentlyDown, + unorchestrated, + unknown } /** Known cluster types. */ diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java index 7bbf0fb0578..76055e4ddf2 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java @@ -13,6 +13,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeMembership; import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode; import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeState; +import com.yahoo.vespa.hosted.controller.api.integration.noderepository.OrchestratorStatus; import java.time.Duration; import java.time.Instant; @@ -118,7 +119,7 @@ public interface NodeRepository { versionFrom(node.getWantedOsVersion()), Optional.ofNullable(node.getCurrentFirmwareCheck()).map(Instant::ofEpochMilli), Optional.ofNullable(node.getWantedFirmwareCheck()).map(Instant::ofEpochMilli), - fromBoolean(node.getAllowedToBeDown()), + toServiceState(node.getOrchestratorStatus()), Optional.ofNullable(node.suspendedSinceMillis()).map(Instant::ofEpochMilli), toInt(node.getCurrentRestartGeneration()), toInt(node.getRestartGeneration()), @@ -204,10 +205,15 @@ public interface NodeRepository { } } - private static Node.ServiceState fromBoolean(Boolean allowedDown) { - return (allowedDown == null) - ? Node.ServiceState.unorchestrated - : allowedDown ? Node.ServiceState.allowedDown : Node.ServiceState.expectedUp; + private static Node.ServiceState toServiceState(OrchestratorStatus orchestratorStatus) { + switch (orchestratorStatus) { + case ALLOWED_TO_BE_DOWN: return Node.ServiceState.allowedDown; + case PERMANENTLY_DOWN: return Node.ServiceState.permanentlyDown; + case NO_REMARKS: return Node.ServiceState.expectedUp; + case OTHER: return Node.ServiceState.unknown; + } + + return Node.ServiceState.unknown; } private static double toDouble(Double d) { diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java index 0533d30b584..a63058572f9 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java @@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.JsonNode; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Stream; @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) @@ -82,8 +83,8 @@ public class NodeRepositoryNode { private Integer cost; @JsonProperty("history") private List<NodeHistory> history; - @JsonProperty("allowedToBeDown") - private Boolean allowedToBeDown; + @JsonProperty("orchestratorStatus") + private String orchestratorStatus; @JsonProperty("suspendedSinceMillis") private Long suspendedSinceMillis; @JsonProperty("reports") @@ -327,8 +328,15 @@ public class NodeRepositoryNode { this.history = history; } - public Boolean getAllowedToBeDown() { - return allowedToBeDown; + public OrchestratorStatus getOrchestratorStatus() { + if (orchestratorStatus == null) { + return OrchestratorStatus.NO_REMARKS; + } + + return Stream.of(OrchestratorStatus.values()) + .filter(status -> status.name().equalsIgnoreCase(orchestratorStatus)) + .findAny() + .orElse(OrchestratorStatus.OTHER); } public Long suspendedSinceMillis() { @@ -441,7 +449,7 @@ public class NodeRepositoryNode { ", wantToDeprovision=" + wantToDeprovision + ", cost=" + cost + ", history=" + history + - ", allowedToBeDown=" + allowedToBeDown + + ", orchestratorStatus=" + orchestratorStatus + ", reports=" + reports + ", modelName=" + modelName + ", reservedTo=" + reservedTo + diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/OrchestratorStatus.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/OrchestratorStatus.java new file mode 100644 index 00000000000..51942b56b3d --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/OrchestratorStatus.java @@ -0,0 +1,6 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.noderepository; + +public enum OrchestratorStatus { + NO_REMARKS, ALLOWED_TO_BE_DOWN, PERMANENTLY_DOWN, OTHER +} |