diff options
author | Valerij Fredriksen <valerijf@oath.com> | 2018-10-24 14:45:52 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@oath.com> | 2018-10-24 14:45:52 +0200 |
commit | 89866e5877884e17743d58b39b406526f449a68c (patch) | |
tree | e8f8e8fc6f19c499c456640e89778016fefd349a /node-admin/src | |
parent | 2843cdfc2a70f4355016d7d6a8f35f5d07a732ff (diff) |
Implement container reboot
Diffstat (limited to 'node-admin/src')
2 files changed, 36 insertions, 0 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 d85344dffd2..a220557ca9c 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 @@ -358,6 +358,11 @@ public class NodeAgentImpl implements NodeAgent { wantedContainerResources + ", actual: " + existingContainer.resources); } + if (node.getCurrentRebootGeneration() < node.getWantedRebootGeneration()) { + return Optional.of(String.format("Container reboot wanted. Current: %d, Wanted: %d", + node.getCurrentRebootGeneration(), node.getWantedRebootGeneration())); + } + if (containerState == STARTING) return Optional.of("Container failed to start"); return Optional.empty(); } 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 648d1f96094..0e72ef15f6a 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 @@ -292,6 +292,37 @@ public class NodeAgentImplTest { } @Test + public void recreatesContainerIfRebootWanted() { + final long wantedRebootGeneration = 2; + final long currentRebootGeneration = 1; + final NodeSpec node = nodeBuilder + .wantedDockerImage(dockerImage) + .currentDockerImage(dockerImage) + .state(Node.State.active) + .wantedVespaVersion(vespaVersion) + .vespaVersion(vespaVersion) + .wantedRebootGeneration(wantedRebootGeneration) + .currentRebootGeneration(currentRebootGeneration) + .build(); + + NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true); + + when(nodeRepository.getOptionalNode(hostName)).thenReturn(Optional.of(node)); + when(dockerOperations.pullImageAsyncIfNeeded(eq(dockerImage))).thenReturn(false); + when(storageMaintainer.getDiskUsageFor(eq(context))).thenReturn(Optional.of(201326592000L)); + + nodeAgent.converge(); + + verify(orchestrator, times(1)).suspend(eq(hostName)); + verify(dockerOperations, times(1)).removeContainer(eq(context), any()); + verify(dockerOperations, times(1)).createContainer(eq(context), eq(node), any()); + verify(dockerOperations, times(1)).startContainer(eq(context)); + verify(orchestrator, times(1)).resume(eq(hostName)); + verify(nodeRepository, times(1)).updateNodeAttributes(eq(hostName), eq(new NodeAttributes() + .withRebootGeneration(wantedRebootGeneration))); + } + + @Test public void failedNodeRunningContainerShouldStillBeRunning() { final NodeSpec node = nodeBuilder .wantedDockerImage(dockerImage) |