diff options
author | valerijf <valerijf@yahoo-inc.com> | 2017-04-03 09:24:04 +0200 |
---|---|---|
committer | valerijf <valerijf@yahoo-inc.com> | 2017-04-03 09:24:04 +0200 |
commit | 30575e3b7a2b8c543e22d843a958f538320c95ec (patch) | |
tree | 766ef262506df25c531bdd4d0069ff2ba68588ae /node-admin | |
parent | 70aa236eade721b0d9fabdece9921c7d2069779e (diff) |
Fix container restart after node-admin restart
Diffstat (limited to 'node-admin')
2 files changed, 23 insertions, 2 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 fcd0cb8b8af..49375836a1c 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 @@ -82,7 +82,7 @@ public class NodeAgentImpl implements NodeAgent { RUNNING_HOWEVER_RESUME_SCRIPT_NOT_RUN, RUNNING } - private ContainerState containerState = ABSENT; + private ContainerState containerState = RUNNING_HOWEVER_RESUME_SCRIPT_NOT_RUN; // The attributes of the last successful node repo attribute update for this node. Used to avoid redundant calls. private NodeAttributes lastAttributesSet = null; @@ -119,7 +119,6 @@ public class NodeAgentImpl implements NodeAgent { .ifPresent(container -> { vespaVersion = dockerOperations.getVespaVersion(container.name); lastCpuMetric = new CpuUsageReporter(container.created); - containerState = RUNNING_HOWEVER_RESUME_SCRIPT_NOT_RUN; }); } 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 f59ec0d1250..1855c2d96c2 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 @@ -24,6 +24,7 @@ import org.junit.Test; import org.mockito.InOrder; import java.io.File; +import java.io.IOException; import java.nio.file.Files; import java.time.Duration; import java.util.Collections; @@ -360,6 +361,27 @@ public class NodeAgentImplTest { } @Test + public void testRestartDeadContainerAfterNodeAdminRestart() throws IOException { + final ContainerNodeSpec nodeSpec = nodeSpecBuilder + .wantedDockerImage(dockerImage) + .nodeState(Node.State.active) + .vespaVersion(vespaVersion) + .build(); + + NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, false); + + when(nodeRepository.getContainerNodeSpec(eq(hostName))).thenReturn(Optional.of(nodeSpec)); + when(dockerOperations.shouldScheduleDownloadOfImage(eq(dockerImage))).thenReturn(false); + when(pathResolver.getApplicationStoragePathForNodeAdmin()).thenReturn(Files.createTempDirectory("foo")); + + nodeAgent.tick(); + + verify(dockerOperations, times(1)).removeContainer(any()); + verify(dockerOperations, times(1)).startContainer(eq(containerName), eq(nodeSpec)); + + } + + @Test public void resumeProgramRunsUntilSuccess() throws Exception { final long restartGeneration = 1; final ContainerNodeSpec nodeSpec = nodeSpecBuilder |