diff options
author | Harald Musum <musum@verizonmedia.com> | 2019-08-14 09:54:39 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2019-08-14 09:54:39 +0200 |
commit | 5bb8a2070aa8b228815e260c3109674be4fcc41c (patch) | |
tree | e8150c722d4b4540a1a768269f940208bab89072 /node-repository | |
parent | f7c7eecd2c0dd0ef6c16413775437a199f6be02c (diff) |
Do not try to deploy after operator changes on all config servers
If application is not deployed locally on a config server, the last deployment
time used will be epoch. Change this so that deployment will only be attempted
on the server where the application has been deployed locally.
Diffstat (limited to 'node-repository')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java index ab7a565688e..0a8556530e0 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/OperatorChangeApplicationMaintainer.java @@ -10,9 +10,11 @@ import com.yahoo.vespa.hosted.provision.node.Agent; import com.yahoo.vespa.hosted.provision.node.History; import java.time.Duration; +import java.time.Instant; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -40,11 +42,7 @@ public class OperatorChangeApplicationMaintainer extends ApplicationMaintainer { .collect(Collectors.groupingBy(node -> node.allocation().get().owner(), Collectors.toList())); return nodesByApplication.entrySet().stream() - .filter(entry -> entry.getValue().stream() - .flatMap(node -> node.history().events().stream()) - .filter(event -> event.agent() == Agent.operator) - .map(History.Event::at) - .anyMatch(getLastDeployTime(entry.getKey())::isBefore)) + .filter(entry -> hasNodesWithChanges(entry.getKey(), entry.getValue())) .map(Map.Entry::getKey) .collect(Collectors.toCollection(LinkedHashSet::new)); } @@ -60,4 +58,15 @@ public class OperatorChangeApplicationMaintainer extends ApplicationMaintainer { " as a manual change was made to its nodes"); } + private boolean hasNodesWithChanges(ApplicationId applicationId, List<Node> nodes) { + Optional<Instant> lastDeployTime = deployer().lastDeployTime(applicationId); + if (lastDeployTime.isEmpty()) return false; + + return nodes.stream() + .flatMap(node -> node.history().events().stream()) + .filter(event -> event.agent() == Agent.operator) + .map(History.Event::at) + .anyMatch(e -> lastDeployTime.get().isBefore(e)); + } + } |