diff options
author | Harald Musum <musum@oath.com> | 2018-09-26 09:20:45 +0200 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2018-09-26 09:20:45 +0200 |
commit | d23570fa5142ac95461ea1e934c6a458e876aa62 (patch) | |
tree | 6e36f58540cf3eb3b7ba069e6b17d0fc7ca5a645 /node-admin/src/main | |
parent | 0246064bbfb9657515f516e2fea12d593cd13016 (diff) |
Do not suspend unnecessarily before stopping serices in dirty state
Diffstat (limited to 'node-admin/src/main')
3 files changed, 24 insertions, 2 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java index 4a19e5fe215..cdfefa6a184 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java @@ -38,7 +38,7 @@ public interface DockerOperations { /** * Try to suspend node. Suspending a node means the node should be taken offline, - * such that maintenance can be done of the node (upgrading, rebooting, etc), + * such that maintenance of the node can be done (upgrading, rebooting, etc), * and such that we will start serving again as soon as possible afterwards. */ void trySuspendNode(ContainerName containerName); diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java index 92c44969d5e..9b759b208eb 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java @@ -18,9 +18,18 @@ public interface NodeAgent { */ boolean setFrozen(boolean frozen); + /** + * Stop services running on node. Depending on the state of the node, {@link #suspend()} might need to be + * called before calling this method. + */ void stopServices(); /** + * Suspend node. Take node offline (e.g. take node out of VIP, drain traffic, prepare for restart etc.) + */ + void suspend(); + + /** * Returns a map containing all relevant NodeAgent variables and their current values. */ Map<String, Object> debugInfo(); diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java index ad38306547d..43e3051ce84 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java @@ -302,13 +302,23 @@ public class NodeAgentImpl implements NodeAgent { logger.info("Stopping services"); if (containerState == ABSENT) return; try { - dockerOperations.trySuspendNode(containerName); dockerOperations.stopServicesOnNode(containerName); } catch (ContainerNotFoundException e) { containerState = ABSENT; } } + @Override + public void suspend() { + logger.info("Suspending services on node"); + if (containerState == ABSENT) return; + try { + dockerOperations.trySuspendNode(containerName); + } catch (ContainerNotFoundException e) { + containerState = ABSENT; + } + } + private Optional<String> shouldRemoveContainer(NodeSpec node, Container existingContainer) { final Node.State nodeState = node.getState(); if (nodeState == Node.State.dirty || nodeState == Node.State.provisioned) { @@ -344,6 +354,9 @@ public class NodeAgentImpl implements NodeAgent { } try { + if (node.getState() != Node.State.dirty) { + suspend(); + } stopServices(); } catch (Exception e) { logger.info("Failed stopping services, ignoring", e); |