diff options
author | valerijf <valerijf@yahoo-inc.com> | 2017-04-04 11:38:24 +0200 |
---|---|---|
committer | valerijf <valerijf@yahoo-inc.com> | 2017-04-04 11:39:33 +0200 |
commit | 237e75ee446a3e004d952fce1434df26393d1790 (patch) | |
tree | ea81a29bfc3292390bdf2c6c9c1b07b3d31bbc61 /node-admin | |
parent | 9b43f1a3707664da3ab78e4fb4692ce6e924e2cf (diff) |
Properly initialize ContainerState
Diffstat (limited to 'node-admin')
2 files changed, 10 insertions, 4 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 f9c98184b4a..883c3e8d0a4 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 @@ -80,7 +80,7 @@ public class NodeAgentImpl implements NodeAgent { RUNNING_HOWEVER_RESUME_SCRIPT_NOT_RUN, RUNNING } - private ContainerState containerState = RUNNING_HOWEVER_RESUME_SCRIPT_NOT_RUN; + private ContainerState containerState = ABSENT; // The attributes of the last successful node repo attribute update for this node. Used to avoid redundant calls. private NodeAttributes lastAttributesSet = null; @@ -114,10 +114,12 @@ public class NodeAgentImpl implements NodeAgent { // If the container is already running, initialize vespaVersion and lastCpuMetric lastCpuMetric = new CpuUsageReporter(clock.instant()); dockerOperations.getContainer(containerName) - .filter(container -> container.state.isRunning()) .ifPresent(container -> { - vespaVersion = dockerOperations.getVespaVersion(container.name); - lastCpuMetric = new CpuUsageReporter(container.created); + if (container.state.isRunning()) { + 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 667771a35d5..2ebfb6a6618 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 @@ -261,7 +261,11 @@ public class NodeAgentImplTest { when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(nodeSpec)); nodeAgent.converge(); + nodeAgent.converge(); + nodeAgent.converge(); + // Should only be called once, when we initialize + verify(dockerOperations, times(1)).getContainer(eq(containerName)); verify(dockerOperations, never()).removeContainer(any()); verify(dockerOperations, never()).startContainer(eq(containerName), eq(nodeSpec)); verify(orchestrator, never()).resume(any(String.class)); |