diff options
author | Valerij Fredriksen <valerijf@yahooinc.com> | 2021-11-11 13:32:15 +0100 |
---|---|---|
committer | Valerij Fredriksen <valerijf@yahooinc.com> | 2021-11-11 13:32:15 +0100 |
commit | 57f72964d7e2ebb1a2b8168f3e07dae6ee6e8198 (patch) | |
tree | 0a6c88201c6c99b884ba000bd100f1e1bb1342e0 | |
parent | 5f896b2f66b395172c29fe7227d0f8c5efd8cb9d (diff) |
Allow updating reboot generation by patching same reboot generation
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java index 812befda432..e7a20ff54b3 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java @@ -432,10 +432,12 @@ public final class Node implements Nodelike { /** Returns a copy of this node with the current reboot generation set to the given number at the given instant */ public Node withCurrentRebootGeneration(long generation, Instant instant) { + if (generation < status.reboot().current()) + throw new IllegalArgumentException("Cannot set reboot generation to " + generation + + ": lower than current generation: " + status.reboot().current()); + Status newStatus = status().withReboot(status().reboot().withCurrent(generation)); - History newHistory = history(); - if (generation > status().reboot().current()) - newHistory = history.with(new History.Event(History.Event.Type.rebooted, Agent.system, instant)); + History newHistory = history.with(new History.Event(History.Event.Type.rebooted, Agent.system, instant)); return this.with(newStatus).with(newHistory); } |