diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-01-31 10:35:25 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-01-31 10:35:25 +0100 |
commit | 58077cf31d05a5b0f805cbb2e40137d5643ef595 (patch) | |
tree | 0e227b812e1c159525bc31dfd9d95d37aefba190 /node-repository | |
parent | 3445515b19fb8796d4e9dbd6645380839ab03a58 (diff) |
Set suspendedSeconds even if zero
If suspendedSeconds is not set the previous value is kept, which is wrong as it
is logically 0 at that time, and is especially confusing in staging where a
single node is reused often, and therefore may have multiple applications with
a supendedSeconds>0 at any given time.
Diffstat (limited to 'node-repository')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java index 6092cd54b40..ed6e7cc71ef 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java @@ -129,17 +129,15 @@ public class MetricsReporter extends Maintainer { metric.set("wantToDeprovision", node.status().wantToDeprovision() ? 1 : 0, context); metric.set("failReport", NodeFailer.reasonsToFailParentHost(node).isEmpty() ? 0 : 1, context); - orchestrator.apply(new HostName(node.hostname())) - .ifPresent(info -> { - int suspended = info.status().isSuspended() ? 1 : 0; - metric.set("suspended", suspended, context); - metric.set("allowedToBeDown", suspended, context); // remove summer 2020. - - info.suspendedSince().ifPresent(suspendedSince -> { - Duration duration = Duration.between(suspendedSince, clock.instant()); - metric.set("suspendedSeconds", duration.getSeconds(), context); - }); - }); + orchestrator.apply(new HostName(node.hostname())).ifPresent(info -> { + int suspended = info.status().isSuspended() ? 1 : 0; + metric.set("suspended", suspended, context); + metric.set("allowedToBeDown", suspended, context); // remove summer 2020. + long suspendedSeconds = info.suspendedSince() + .map(suspendedSince -> Duration.between(suspendedSince, clock.instant()).getSeconds()) + .orElse(0L); + metric.set("suspendedSeconds", suspendedSeconds, context); + }); long numberOfServices; HostName hostName = new HostName(node.hostname()); |