summaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorvalerijf <valerijf@oath.com>2017-08-15 11:13:49 +0200
committervalerijf <valerijf@oath.com>2017-08-15 11:13:49 +0200
commit645b08755297db8916023883c4bc58d70cff0dd5 (patch)
treed712957d5550e2b7fa2fdda2cd53d9ed1e559a7b /node-repository/src/main/java/com/yahoo
parent5d24790f45fdb1260a1b720f27ab60a07e53de9c (diff)
Rename hardwareFailureType to hardwareFailureDescription
Diffstat (limited to 'node-repository/src/main/java/com/yahoo')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/FailedExpirer.java4
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java28
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java6
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java16
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java5
7 files changed, 31 insertions, 32 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java
index 96eae71d403..1885b54e9c0 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java
@@ -381,7 +381,7 @@ public class NodeRepository extends AbstractComponent {
Node nodeToDirty = getNode(hostname, Node.State.provisioned, Node.State.failed, Node.State.parked).orElseThrow(() ->
new IllegalArgumentException("Could not deallocate " + hostname + ": No such node in the provisioned, failed or parked state"));
- if (nodeToDirty.status().hardwareFailure().isPresent())
+ if (nodeToDirty.status().hardwareFailureDescription().isPresent())
throw new IllegalArgumentException("Could not deallocate " + hostname + ": It has a hardware failure");
return setDirty(nodeToDirty);
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/FailedExpirer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/FailedExpirer.java
index e8f890fb9f3..d61f06be744 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/FailedExpirer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/FailedExpirer.java
@@ -29,7 +29,7 @@ import java.util.List;
* to failed due to some undetected hardware failure will end up being failed again.
* When that has happened enough they will not be recycled.
* <p>
- * The Chef recipe running locally on the node may set the hardwareFailure flag to avoid the node
+ * The Chef recipe running locally on the node may set the hardwareFailureDescription to avoid the node
* being automatically recycled in cases where an error has been positively detected.
*
* @author bratseth
@@ -50,7 +50,7 @@ public class FailedExpirer extends Expirer {
protected void expire(List<Node> expired) {
List<Node> nodesToRecycle = new ArrayList<>();
for (Node recycleCandidate : expired) {
- if (recycleCandidate.status().hardwareFailure().isPresent()) continue;
+ if (recycleCandidate.status().hardwareFailureDescription().isPresent()) continue;
if (failCountIndicatesHwFail(zone, recycleCandidate) && recycleCandidate.status().failCount() >= 5) continue;
nodesToRecycle.add(recycleCandidate);
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java
index ea26eef0007..63bd8f1b424 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java
@@ -144,7 +144,7 @@ public class NodeFailer extends Maintainer {
private List<Node> readyNodesWithHardwareFailure() {
return nodeRepository().getNodes(Node.State.ready).stream()
- .filter(node -> node.status().hardwareFailure().isPresent())
+ .filter(node -> node.status().hardwareFailureDescription().isPresent())
.collect(Collectors.toList());
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java
index 49916dad4aa..19e34ccb169 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java
@@ -18,7 +18,7 @@ public class Status {
private final Generation reboot;
private final Optional<Version> vespaVersion;
private final int failCount;
- private final Optional<String> hardwareFailure;
+ private final Optional<String> hardwareFailureDescription;
private final boolean wantToRetire;
private final boolean wantToDeprovision;
private final Optional<String> hardwareDivergence;
@@ -26,53 +26,53 @@ public class Status {
public Status(Generation generation,
Optional<Version> vespaVersion,
int failCount,
- Optional<String> hardwareFailure,
+ Optional<String> hardwareFailureDescription,
boolean wantToRetire,
boolean wantToDeprovision,
Optional<String> hardwareDivergence) {
Objects.requireNonNull(generation, "Generation must be non-null");
Objects.requireNonNull(vespaVersion, "Vespa version must be non-null");
- Objects.requireNonNull(hardwareFailure, "Hardware failure must be non-null");
+ Objects.requireNonNull(hardwareFailureDescription, "Hardware failure description must be non-null");
Objects.requireNonNull(hardwareDivergence, "Hardware divergence must be non-null");
hardwareDivergence.ifPresent(s -> requireNonEmptyString(s, "Hardware divergence must be non-empty"));
this.reboot = generation;
this.vespaVersion = vespaVersion;
this.failCount = failCount;
- this.hardwareFailure = hardwareFailure;
+ this.hardwareFailureDescription = hardwareFailureDescription;
this.wantToRetire = wantToRetire;
this.wantToDeprovision = wantToDeprovision;
this.hardwareDivergence = hardwareDivergence;
}
/** Returns a copy of this with the reboot generation changed */
- public Status withReboot(Generation reboot) { return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withReboot(Generation reboot) { return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
/** Returns the reboot generation of this node */
public Generation reboot() { return reboot; }
/** Returns a copy of this with the vespa version changed */
- public Status withVespaVersion(Version version) { return new Status(reboot, Optional.of(version), failCount, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withVespaVersion(Version version) { return new Status(reboot, Optional.of(version), failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
/** Returns the Vespa version installed on the node, if known */
public Optional<Version> vespaVersion() { return vespaVersion; }
- public Status withIncreasedFailCount() { return new Status(reboot, vespaVersion, failCount + 1, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withIncreasedFailCount() { return new Status(reboot, vespaVersion, failCount + 1, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
- public Status withDecreasedFailCount() { return new Status(reboot, vespaVersion, failCount - 1, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withDecreasedFailCount() { return new Status(reboot, vespaVersion, failCount - 1, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
- public Status setFailCount(Integer value) { return new Status(reboot, vespaVersion, value, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status setFailCount(Integer value) { return new Status(reboot, vespaVersion, value, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
/** Returns how many times this node has been moved to the failed state. */
public int failCount() { return failCount; }
- public Status withHardwareFailure(Optional<String> hardwareFailure) { return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withHardwareFailureDescription(Optional<String> hardwareFailureDescription) { return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
/** Returns the type of the last hardware failure detected on this node, or empty if none */
- public Optional<String> hardwareFailure() { return hardwareFailure; }
+ public Optional<String> hardwareFailureDescription() { return hardwareFailureDescription; }
/** Returns a copy of this with the want to retire flag changed */
public Status withWantToRetire(boolean wantToRetire) {
- return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence);
}
/**
@@ -85,7 +85,7 @@ public class Status {
/** Returns a copy of this with the want to de-provision flag changed */
public Status withWantToDeprovision(boolean wantToDeprovision) {
- return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence);
}
/**
@@ -96,7 +96,7 @@ public class Status {
}
public Status withHardwareDivergence(Optional<String> hardwareDivergence) {
- return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision, hardwareDivergence);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence);
}
/** Returns hardware divergence report as JSON string, if any */
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
index 77ffd7415b3..8056bd787db 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
@@ -106,7 +106,7 @@ public class NodeSerializer {
object.setLong(currentRebootGenerationKey, node.status().reboot().current());
node.status().vespaVersion().ifPresent(version -> object.setString(vespaVersionKey, version.toString()));
object.setLong(failCountKey, node.status().failCount());
- node.status().hardwareFailure().ifPresent(failure -> object.setString(hardwareFailureKey, failure));
+ node.status().hardwareFailureDescription().ifPresent(failure -> object.setString(hardwareFailureKey, failure));
object.setBool(wantToRetireKey, node.status().wantToRetire());
object.setBool(wantToDeprovisionKey, node.status().wantToDeprovision());
node.allocation().ifPresent(allocation -> toSlime(allocation, object.setObject(instanceKey)));
@@ -168,7 +168,7 @@ public class NodeSerializer {
return new Status(generationFromSlime(object, rebootGenerationKey, currentRebootGenerationKey),
versionFromSlime(object.field(vespaVersionKey)),
(int)object.field(failCountKey).asLong(),
- hardwareFailureFromSlime(object),
+ hardwareFailureDescriptionFromSlime(object),
object.field(wantToRetireKey).asBool(),
wantToDeprovision,
hardwareDivergenceFromSlime(object));
@@ -245,7 +245,7 @@ public class NodeSerializer {
return ipAddresses.build();
}
- private Optional<String> hardwareFailureFromSlime(Inspector object) {
+ private Optional<String> hardwareFailureDescriptionFromSlime(Inspector object) {
if (object.field(hardwareFailureKey).valid()) {
return Optional.of(object.field(hardwareFailureKey).asString());
}
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 fd0992d19c6..10514b62bc1 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
@@ -30,7 +30,7 @@ import java.util.stream.Collectors;
*/
public class NodePatcher {
- public static final String HARDWARE_FAILURE_TYPE = "hardwareFailureType";
+ public static final String HARDWARE_FAILURE_TYPE = "hardwareFailureDescription";
private final NodeFlavors nodeFlavors;
private final Inspector inspector;
private final NodeRepository nodeRepository;
@@ -83,7 +83,7 @@ public class NodePatcher {
Optional.empty() : Optional.of(inspector.field(HARDWARE_FAILURE_TYPE).asString());
modified = true;
children = children.stream()
- .map(node -> node.with(node.status().withHardwareFailure(hardwareFailure)))
+ .map(node -> node.with(node.status().withHardwareFailureDescription(hardwareFailure)))
.collect(Collectors.toList());
}
@@ -114,9 +114,7 @@ public class NodePatcher {
case "flavor" :
return node.with(nodeFlavors.getFlavorOrThrow(asString(value)));
case HARDWARE_FAILURE_TYPE:
- Optional<String> hardwareFailure = value.type().equals(Type.NIX) ?
- Optional.empty() : Optional.of(asString(value));
- return node.with(node.status().withHardwareFailure(hardwareFailure));
+ return node.with(node.status().withHardwareFailureDescription(asOptionalString(value)));
case "parentHostname" :
return node.withParentHostname(asString(value));
case "ipAddresses" :
@@ -128,9 +126,7 @@ public class NodePatcher {
case "wantToDeprovision" :
return node.with(node.status().withWantToDeprovision(asBoolean(value)));
case "hardwareDivergence" :
- Optional<String> hardwareDivergence = value.type().equals(Type.NIX) ?
- Optional.empty() : Optional.of(asString(value));
- return node.with(node.status().withHardwareDivergence(hardwareDivergence));
+ return node.with(node.status().withHardwareDivergence(asOptionalString(value)));
default :
throw new IllegalArgumentException("Could not apply field '" + name + "' on a node: No such modifiable field");
}
@@ -171,6 +167,10 @@ public class NodePatcher {
return field.asString();
}
+ private Optional<String> asOptionalString(Inspector field) {
+ return field.type().equals(Type.NIX) ? Optional.empty() : Optional.of(asString(field));
+ }
+
private boolean asBoolean(Inspector field) {
if ( ! field.type().equals(Type.BOOL))
throw new IllegalArgumentException("Expected a BOOL value, got a " + field.type());
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
index d5ab5610980..f47fab6091d 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
@@ -12,7 +12,6 @@ import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.provision.Node;
import com.yahoo.vespa.hosted.provision.NodeRepository;
import com.yahoo.vespa.hosted.provision.node.History;
-import com.yahoo.vespa.hosted.provision.node.Status;
import com.yahoo.vespa.hosted.provision.node.filter.NodeFilter;
import java.io.IOException;
@@ -171,8 +170,8 @@ class NodesResponse extends HttpResponse {
object.setString("convergedStateVersion", version.toFullString());
});
object.setLong("failCount", node.status().failCount());
- object.setBool("hardwareFailure", node.status().hardwareFailure().isPresent());
- node.status().hardwareFailure().ifPresent(failure -> object.setString("hardwareFailureType", failure));
+ object.setBool("hardwareFailure", node.status().hardwareFailureDescription().isPresent());
+ node.status().hardwareFailureDescription().ifPresent(failure -> object.setString("hardwareFailureDescription", failure));
object.setBool("wantToRetire", node.status().wantToRetire());
object.setBool("wantToDeprovision", node.status().wantToDeprovision());
toSlime(node.history(), object.setArray("history"));