aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <martin.polden@gmail.com>2017-06-12 10:00:27 +0200
committerMartin Polden <martin.polden@gmail.com>2017-06-12 11:34:10 +0200
commit44352dabe868bccf2aab2db0f426a88b5ed3c27a (patch)
tree05ffde8d41b779aeafaae935d38ef5b910ec7005
parent3c4d24437dbbc120d9ee9c9642600024125a649e (diff)
Fix TODO: Stop persisting deprecated version fields
This removes hostedVersion and convergedStateVersion from the model, but keeps external API compatibility. Patching these fields does nothing. In read calls, these fields will always have the same value as vespaVersion.
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java47
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java8
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java4
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java14
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java7
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json4
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json4
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json2
9 files changed, 32 insertions, 60 deletions
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 e8a24b85714..24216370d63 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
@@ -17,8 +17,6 @@ public class Status {
private final Generation reboot;
private final Optional<Version> vespaVersion;
- private final Optional<Version> hostedVersion; // TODO: Remove when all nodes have started using vespaVersion
- private final Optional<String> stateVersion; // TODO: Remove when all nodes have started using vespaVersion
private final int failCount;
private final Optional<HardwareFailureType> hardwareFailure;
private final boolean wantToRetire;
@@ -37,16 +35,12 @@ public class Status {
public Status(Generation generation,
Optional<Version> vespaVersion,
- Optional<Version> hostedVersion,
- Optional<String> stateVersion,
int failCount,
Optional<HardwareFailureType> hardwareFailure,
boolean wantToRetire,
boolean wantToDeprovision) {
this.reboot = generation;
this.vespaVersion = vespaVersion;
- this.hostedVersion = hostedVersion;
- this.stateVersion = stateVersion;
this.failCount = failCount;
this.hardwareFailure = hardwareFailure;
this.wantToRetire = wantToRetire;
@@ -54,63 +48,46 @@ public class Status {
}
/** Returns a copy of this with the reboot generation changed */
- public Status withReboot(Generation reboot) { return new Status(reboot, vespaVersion, hostedVersion, stateVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision); }
+ public Status withReboot(Generation reboot) { return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision); }
/** 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), hostedVersion, stateVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision); }
+ public Status withVespaVersion(Version version) { return new Status(reboot, Optional.of(version), failCount, hardwareFailure, wantToRetire, wantToDeprovision); }
/** Returns the Vespa version installed on the node, if known */
public Optional<Version> vespaVersion() { return vespaVersion; }
- /** Returns a copy of this with the hosted version changed */
- public Status withHostedVersion(Version version) { return new Status(reboot, vespaVersion, Optional.of(version), stateVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision); }
-
- /** Returns the hosted version installed on the node, if known */
- public Optional<Version> hostedVersion() { return hostedVersion; }
-
- /** Returns a copy of this with the state version changed */
- public Status withStateVersion(String version) { return new Status(reboot, vespaVersion, hostedVersion, Optional.of(version), failCount, hardwareFailure, wantToRetire, wantToDeprovision); }
-
- /**
- * Returns the state version the node last successfully converged with.
- * The state version contains the version-specific parts in identifying state
- * files on dist, and is of the form HOSTEDVERSION.
- * It's also used to uniquely identify a hosted Vespa release.
- */
- public Optional<String> stateVersion() { return stateVersion; }
-
/** Returns a copy of this with the docker image changed */
public Status withDockerImage(String dockerImage) {
Optional<Version> vespaVersion = Optional.of(dockerImage)
.filter(image -> !image.isEmpty())
.map(DockerImage::new)
.map(DockerImage::tagAsVersion);
- return new Status(reboot, vespaVersion, hostedVersion, stateVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision);
}
/** Returns the current docker image the node is running, if known. */
public Optional<String> dockerImage() { return vespaVersion.map(DockerImage.defaultImage::withTag).map(DockerImage::toString); }
- public Status withIncreasedFailCount() { return new Status(reboot, vespaVersion, hostedVersion, stateVersion, failCount + 1, hardwareFailure, wantToRetire, wantToDeprovision); }
+ public Status withIncreasedFailCount() { return new Status(reboot, vespaVersion, failCount + 1, hardwareFailure, wantToRetire, wantToDeprovision); }
- public Status withDecreasedFailCount() { return new Status(reboot, vespaVersion, hostedVersion, stateVersion, failCount - 1, hardwareFailure, wantToRetire, wantToDeprovision); }
+ public Status withDecreasedFailCount() { return new Status(reboot, vespaVersion, failCount - 1, hardwareFailure, wantToRetire, wantToDeprovision); }
- public Status setFailCount(Integer value) { return new Status(reboot, vespaVersion, hostedVersion, stateVersion, value, hardwareFailure, wantToRetire, wantToDeprovision); }
+ public Status setFailCount(Integer value) { return new Status(reboot, vespaVersion, value, hardwareFailure, wantToRetire, wantToDeprovision); }
/** Returns how many times this node has been moved to the failed state. */
public int failCount() { return failCount; }
- public Status withHardwareFailure(Optional<HardwareFailureType> hardwareFailure) { return new Status(reboot, vespaVersion, hostedVersion, stateVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision); }
+ public Status withHardwareFailure(Optional<HardwareFailureType> hardwareFailure) { return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision); }
/** Returns the type of the last hardware failure detected on this node, or empty if none */
public Optional<HardwareFailureType> hardwareFailure() { return hardwareFailure; }
/** Returns a copy of this with the want to retire flag changed */
public Status withWantToRetire(boolean wantToRetire) {
- return new Status(reboot, vespaVersion, hostedVersion, stateVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision);
}
/**
@@ -121,19 +98,19 @@ public class Status {
return wantToRetire;
}
- /** Returns a copy of this with the want to deprovision flag changed */
+ /** Returns a copy of this with the want to de-provision flag changed */
public Status withWantToDeprovision(boolean wantToDeprovision) {
- return new Status(reboot, vespaVersion, hostedVersion, stateVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailure, wantToRetire, wantToDeprovision);
}
/**
- * Returns whether this node should be deprovisioned when possible.
+ * Returns whether this node should be de-provisioned when possible.
*/
public boolean wantToDeprovision() {
return wantToDeprovision;
}
/** Returns the initial status of a newly provisioned node */
- public static Status initial() { return new Status(Generation.inital(), Optional.empty(), Optional.empty(), Optional.empty(), 0, Optional.empty(), false, false); }
+ public static Status initial() { return new Status(Generation.inital(), Optional.empty(), 0, Optional.empty(), false, false); }
}
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 582f97361b2..a090ee9f3e5 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
@@ -30,8 +30,6 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
-import static com.yahoo.vespa.config.SlimeUtils.optionalString;
-
/**
* Serializes a node to/from JSON.
* Instances of this are multithread safe and can be reused
@@ -54,8 +52,6 @@ public class NodeSerializer {
private static final String rebootGenerationKey = "rebootGeneration";
private static final String currentRebootGenerationKey = "currentRebootGeneration";
private static final String vespaVersionKey = "vespaVersion";
- private static final String hostedVersionKey = "hostedVersion";
- private static final String stateVersionKey = "stateVersion";
private static final String failCountKey = "failCount";
private static final String hardwareFailureKey = "hardwareFailure";
private static final String nodeTypeKey = "type";
@@ -108,8 +104,6 @@ public class NodeSerializer {
object.setLong(rebootGenerationKey, node.status().reboot().wanted());
object.setLong(currentRebootGenerationKey, node.status().reboot().current());
node.status().vespaVersion().ifPresent(version -> object.setString(vespaVersionKey, version.toString()));
- node.status().hostedVersion().ifPresent(version -> object.setString(hostedVersionKey, version.toString()));
- node.status().stateVersion().ifPresent(version -> object.setString(stateVersionKey, version));
object.setLong(failCountKey, node.status().failCount());
node.status().hardwareFailure().ifPresent(failure -> object.setString(hardwareFailureKey, toString(failure)));
object.setBool(wantToRetireKey, node.status().wantToRetire());
@@ -170,8 +164,6 @@ public class NodeSerializer {
boolean wantToDeprovision = object.field(wantToDeprovisionKey).valid() && object.field(wantToDeprovisionKey).asBool();
return new Status(generationFromSlime(object, rebootGenerationKey, currentRebootGenerationKey),
versionFromSlime(object.field(vespaVersionKey)),
- versionFromSlime(object.field(hostedVersionKey)),
- optionalString(object.field(stateVersionKey)),
(int)object.field(failCountKey).asLong(),
hardwareFailureFromSlime(object.field(hardwareFailureKey)),
object.field(wantToRetireKey).asBool(),
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 b410b0c8ead..091f5654636 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
@@ -62,7 +62,7 @@ public class NodePatcher {
private Node applyField(String name, Inspector value) {
switch (name) {
case "convergedStateVersion" :
- return node.with(node.status().withStateVersion(asString(value)));
+ return node; // TODO: Ignored, can be removed when callers no longer include this field
case "currentRebootGeneration" :
return node.withCurrentRebootGeneration(asLong(value), clock.instant());
case "currentRestartGeneration" :
@@ -72,7 +72,7 @@ public class NodePatcher {
case "currentVespaVersion" :
return node.with(node.status().withVespaVersion(Version.fromString(asString(value))));
case "currentHostedVersion" :
- return node.with(node.status().withHostedVersion(Version.fromString(asString(value))));
+ return node; // TODO: Ignored, can be removed when callers no longer include this field
case "failCount" :
return node.with(node.status().setFailCount(asLong(value).intValue()));
case "flavor" :
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 00bec80b758..6d66cdd3764 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
@@ -1,7 +1,6 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.restapi.v2;
-import com.yahoo.component.Version;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ClusterMembership;
import com.yahoo.config.provision.NodeType;
@@ -161,12 +160,15 @@ class NodesResponse extends HttpResponse {
}
object.setLong("rebootGeneration", node.status().reboot().wanted());
object.setLong("currentRebootGeneration", node.status().reboot().current());
- node.status().vespaVersion().ifPresent(version -> {
- if (! version.equals(Version.emptyVersion)) object.setString("vespaVersion", version.toFullString());
- });
- node.status().hostedVersion().ifPresent(version -> object.setString("hostedVersion", version.toFullString()));
+ node.status().vespaVersion()
+ .filter(version -> !version.isEmpty())
+ .ifPresent(version -> {
+ object.setString("vespaVersion", version.toFullString());
+ // TODO: Remove these when they are no longer read
+ object.setString("hostedVersion", version.toFullString());
+ object.setString("convergedStateVersion", version.toFullString());
+ });
node.status().dockerImage().ifPresent(image -> object.setString("currentDockerImage", image));
- node.status().stateVersion().ifPresent(version -> object.setString("convergedStateVersion", version));
object.setLong("failCount", node.status().failCount());
object.setBool("hardwareFailure", node.status().hardwareFailure().isPresent());
node.status().hardwareFailure().ifPresent(failure -> object.setString("hardwareFailureType", toString(failure)));
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java
index adfccd1f874..96604fca233 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockNodeRepository.java
@@ -8,15 +8,14 @@ import com.yahoo.config.provision.Capacity;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.HostSpec;
import com.yahoo.config.provision.InstanceName;
+import com.yahoo.config.provision.NodeFlavors;
import com.yahoo.config.provision.NodeType;
import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.Zone;
import com.yahoo.transaction.NestedTransaction;
-import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
import com.yahoo.vespa.hosted.provision.Node;
import com.yahoo.vespa.hosted.provision.NodeRepository;
-import com.yahoo.config.provision.NodeFlavors;
import com.yahoo.vespa.hosted.provision.node.Agent;
import com.yahoo.vespa.hosted.provision.node.Status;
import com.yahoo.vespa.hosted.provision.provisioning.NodeRepositoryProvisioner;
@@ -78,9 +77,7 @@ public class MockNodeRepository extends NodeRepository {
Node node10 = createNode("node10", "host10.yahoo.com", ipAddresses, Optional.of("parent1.yahoo.com"), flavors.getFlavorOrThrow("default"), NodeType.tenant);
Status node10newStatus = node10.status();
node10newStatus = node10newStatus
- .withVespaVersion(Version.fromString("5.104.142"))
- .withHostedVersion(Version.fromString("2.1.2408"))
- .withStateVersion("5.104.142-2.1.2408");
+ .withVespaVersion(Version.fromString("5.104.142"));
node10 = node10.with(node10newStatus);
nodes.add(node10);
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json
index f6368c58196..4dccaaab521 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json
@@ -32,9 +32,9 @@
"rebootGeneration": 1,
"currentRebootGeneration": 0,
"vespaVersion": "5.104.142",
- "hostedVersion": "2.1.2408",
+ "hostedVersion": "5.104.142",
+ "convergedStateVersion": "5.104.142",
"currentDockerImage": "docker-registry.ops.yahoo.com:4443/vespa/ci:5.104.142",
- "convergedStateVersion": "5.104.142-2.1.2408",
"failCount": 0,
"hardwareFailure" : false,
"wantToRetire" : false,
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json
index cc907a2280c..bcc042f7792 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json
@@ -32,9 +32,9 @@
"rebootGeneration": 2,
"currentRebootGeneration": 1,
"vespaVersion": "6.43.0",
- "hostedVersion": "2.1.2408",
+ "hostedVersion": "6.43.0",
+ "convergedStateVersion": "6.43.0",
"currentDockerImage": "docker-registry.ops.yahoo.com:4443/vespa/ci:6.43.0",
- "convergedStateVersion": "5.104.142-2.1.2408",
"failCount": 0,
"hardwareFailure": true,
"hardwareFailureType": "memory_mcelog",
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json
index e416634bbe5..aff3f85f9fb 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json
@@ -32,6 +32,8 @@
"rebootGeneration": 1,
"currentRebootGeneration": 0,
"vespaVersion": "6.41.0",
+ "hostedVersion": "6.41.0",
+ "convergedStateVersion": "6.41.0",
"currentDockerImage": "docker-registry.ops.yahoo.com:4443/vespa/ci:6.41.0",
"failCount": 0,
"hardwareFailure" : false,
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json
index f8e18a08ae6..23d63c40c10 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json
@@ -16,6 +16,8 @@
"rebootGeneration": 1,
"currentRebootGeneration": 0,
"vespaVersion": "1.2.3",
+ "hostedVersion": "1.2.3",
+ "convergedStateVersion": "1.2.3",
"currentDockerImage": "docker-registry.ops.yahoo.com:4443/vespa/ci:1.2.3",
"failCount": 1,
"hardwareFailure" : false,