diff options
author | Harald Musum <musum@verizonmedia.com> | 2019-11-14 15:49:04 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2019-11-14 15:49:04 +0100 |
commit | d0a9eee3307420b19ccf57e75235251b0ac1c335 (patch) | |
tree | 265c7216fe8f02f8fdcfb2e2afaa812e6ed7cc7b /node-admin | |
parent | 41bfadcf36d8498bdaec702c1c4c0b9970cd1507 (diff) |
Add a stopServicesIfNeeded method
Diffstat (limited to 'node-admin')
2 files changed, 10 insertions, 1 deletions
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 59a8e3ec99e..6d3f2c32d12 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 @@ -249,6 +249,11 @@ public class NodeAgentImpl implements NodeAgent { } } + private void stopServicesIfNeeded(NodeAgentContext context) { + if (hasStartedServices) + stopServices(context); + } + private void stopServices(NodeAgentContext context) { context.log(logger, "Stopping services"); if (containerState == ABSENT) return; @@ -409,7 +414,7 @@ public class NodeAgentImpl implements NodeAgent { break; case parked: updateNodeRepoWithCurrentAttributes(context); - stopServices(context); + stopServicesIfNeeded(context); break; case active: storageMaintainer.handleCoreDumpsForContainer(context, container); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java index 236e9499f89..4a1c71fb847 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java @@ -674,6 +674,10 @@ public class NodeAgentImplTest { verify(dockerOperations, never()).removeContainer(eq(context), any()); verify(dockerOperations, never()).createContainer(eq(context), any(), any()); verify(dockerOperations, times(1)).stopServices(eq(context)); + + nodeAgent.doConverge(context); + // Should not be called more than once, have already been stopped + verify(dockerOperations, times(1)).stopServices(eq(context)); } private NodeAgentImpl makeNodeAgent(DockerImage dockerImage, boolean isRunning) { |