summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2018-03-08 14:42:22 +0100
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2018-03-08 14:42:22 +0100
commit5f7645e8bbb389864c850c526b30cb77d1a78027 (patch)
treeab1fbbf7eeb38f9732d9681b0dae1b1cf3a5c2c3 /node-repository
parenta405462e2408a274ab66fab963413c663c168aab (diff)
Don't delete reservation without re-adding it
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java3
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java8
2 files changed, 3 insertions, 8 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java
index 3228e6ca17e..df21950c69f 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java
@@ -63,7 +63,8 @@ public class History {
/** Returns a copy of this history with a record of this state transition added, if applicable */
public History recordStateTransition(Node.State from, Node.State to, Agent agent, Instant at) {
- if (from == to) return this;
+ // If the event is a re-reservation, allow the new one to override the older one.
+ if (from == to && from != Node.State.reserved) return this;
switch (to) {
case provisioned: return this.with(new Event(Event.Type.provisioned, agent, at));
case ready: return this.withoutApplicationEvents().with(new Event(Event.Type.readied, agent, at));
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
index 78be6fe57d1..4e4b29c8098 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
@@ -210,13 +210,7 @@ public class CuratorDatabaseClient {
}
private History recordStateTransition(Node node, Node.State toState, Agent agent) {
- History history = node.history();
- // When a node is re-reserved we want to update the reservation instant, we do this by removing the existing
- // event and recording a new one
- if (node.state() == Node.State.reserved && toState == Node.State.reserved) {
- history = history.without(History.Event.Type.reserved);
- }
- return history.recordStateTransition(node.state(), toState, agent, clock.instant());
+ return node.history().recordStateTransition(node.state(), toState, agent, clock.instant());
}
private Status newNodeStatus(Node node, Node.State toState) {