diff options
author | Martin Polden <mpolden@mpolden.no> | 2019-09-23 09:20:38 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2019-09-24 09:29:30 +0200 |
commit | 76bc54dc3de81c560df16b25b50ad8632bb87128 (patch) | |
tree | 5ca3c0ebf7c13e8245d370f15885d970d609af3f /node-repository/src/main/java/com/yahoo/vespa | |
parent | a975345f861f8560def95fa3e92364ecaa0bd225 (diff) |
Write osUpgraded event
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java | 12 | ||||
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java | 2 |
2 files changed, 13 insertions, 1 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 bdcb96c1861..61d5909ce6f 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 @@ -1,6 +1,7 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision; +import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.Flavor; @@ -287,6 +288,17 @@ public final class Node { return this.with(newStatus).with(newHistory); } + /** Returns a copy of this node with the current OS version set to the given version at the given instant */ + public Node withCurrentOsVersion(Version version, Instant instant) { + var newStatus = status.withOsVersion(version); + var newHistory = history(); + // Only update history if version has changed + if (status.osVersion().isEmpty() || !status.osVersion().get().equals(version)) { + newHistory = history.with(new History.Event(History.Event.Type.osUpgraded, Agent.system, instant)); + } + return this.with(newStatus).with(newHistory); + } + /** Returns a copy of this node with the given history. */ public Node with(History history) { return new Node(id, ipConfig, hostname, parentHostname, flavor, status, state, allocation, history, type, reports, modelName); 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 8dcf3c260f5..8ec21a246bc 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 @@ -120,7 +120,7 @@ public class NodePatcher { case "currentVespaVersion" : return node.with(node.status().withVespaVersion(Version.fromString(asString(value)))); case "currentOsVersion" : - return node.with(node.status().withOsVersion(Version.fromString(asString(value)))); + return node.withCurrentOsVersion(Version.fromString(asString(value)), clock.instant()); case "currentFirmwareCheck": return node.with(node.status().withFirmwareVerifiedAt(Instant.ofEpochMilli(asLong(value)))); case "failCount" : |