summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@oath.com>2018-10-12 14:50:35 +0200
committerValerij Fredriksen <valerijf@oath.com>2018-10-12 15:04:19 +0200
commit56557e7014cf825bd1205b99158f1ba5abdd3fb0 (patch)
treeaf75dbbb140ff838b343eba36a5c13979bd0d8ed /node-admin
parente19aeb84a1313754e6263861bfd0af86c4f1171f (diff)
Remove DockerOperations from NodeAdmin
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImpl.java18
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java2
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImplTest.java7
3 files changed, 9 insertions, 18 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImpl.java
index 644ac587c34..d436e214266 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImpl.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.hosted.node.admin.nodeadmin;
import com.yahoo.concurrent.ThreadFactoryFactory;
-import com.yahoo.vespa.hosted.dockerapi.Container;
import com.yahoo.vespa.hosted.dockerapi.metrics.CounterWrapper;
import com.yahoo.vespa.hosted.dockerapi.metrics.Dimensions;
import com.yahoo.vespa.hosted.dockerapi.metrics.GaugeWrapper;
@@ -39,7 +38,6 @@ public class NodeAdminImpl implements NodeAdmin {
private final ScheduledExecutorService metricsScheduler =
Executors.newScheduledThreadPool(1, ThreadFactoryFactory.getDaemonThreadFactory("metricsscheduler"));
- private final DockerOperations dockerOperations;
private final Function<String, NodeAgent> nodeAgentFactory;
private final Runnable aclMaintainer;
@@ -58,7 +56,13 @@ public class NodeAdminImpl implements NodeAdmin {
Runnable aclMaintainer,
MetricReceiverWrapper metricReceiver,
Clock clock) {
- this.dockerOperations = dockerOperations;
+ this(nodeAgentFactory, aclMaintainer, metricReceiver, clock);
+ }
+
+ public NodeAdminImpl(Function<String, NodeAgent> nodeAgentFactory,
+ Runnable aclMaintainer,
+ MetricReceiverWrapper metricReceiver,
+ Clock clock) {
this.nodeAgentFactory = nodeAgentFactory;
this.aclMaintainer = aclMaintainer;
@@ -203,9 +207,6 @@ public class NodeAdminImpl implements NodeAdmin {
}
void synchronizeNodesToNodeAgents(Set<String> hostnamesToRun) {
- Map<String, Container> runningContainersByHostname = dockerOperations.getAllManagedContainers().stream()
- .collect(Collectors.toMap(c -> c.hostname, c -> c));
-
// Stop and remove NodeAgents that should no longer be running
diff(nodeAgentsByHostname.keySet(), hostnamesToRun)
.forEach(hostname -> nodeAgentsByHostname.remove(hostname).stop());
@@ -213,11 +214,6 @@ public class NodeAdminImpl implements NodeAdmin {
// Start NodeAgent for hostnames that should be running, but aren't yet
diff(hostnamesToRun, nodeAgentsByHostname.keySet())
.forEach(this::startNodeAgent);
-
- // Remove containers that are running, but have no NodeAgent managing it (and after the previous steps,
- // these containers shouldn't be running, otherwise a NodeAgent would have been created)
- diff(runningContainersByHostname.keySet(), nodeAgentsByHostname.keySet())
- .forEach(hostname -> dockerOperations.removeContainer(runningContainersByHostname.get(hostname)));
}
private void startNodeAgent(String hostname) {
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java
index 3c316de94eb..ef369a21c37 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java
@@ -100,7 +100,7 @@ public class DockerTester implements AutoCloseable {
Function<String, NodeAgent> nodeAgentFactory = (hostName) -> new NodeAgentImpl(
NodeAgentContextImplTest.nodeAgentFromHostname(fileSystem, hostName), nodeRepositoryMock,
orchestratorMock, dockerOperations, storageMaintainer, aclMaintainer, environment, clock, NODE_AGENT_SCAN_INTERVAL, athenzCredentialsMaintainer);
- nodeAdmin = new NodeAdminImpl(dockerOperations, nodeAgentFactory, aclMaintainer, mr, Clock.systemUTC());
+ nodeAdmin = new NodeAdminImpl(nodeAgentFactory, aclMaintainer, mr, Clock.systemUTC());
nodeAdminStateUpdater = new NodeAdminStateUpdaterImpl(nodeRepositoryMock, orchestratorMock, storageMaintainer,
nodeAdmin, DOCKER_HOST_HOSTNAME, clock, NODE_ADMIN_CONVERGE_STATE_INTERVAL,
Optional.of(new ClassLocking()));
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImplTest.java
index 065b039c7fd..2431433b17f 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImplTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminImplTest.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.hosted.node.admin.nodeadmin;
import com.yahoo.metrics.simple.MetricReceiver;
import com.yahoo.test.ManualClock;
import com.yahoo.vespa.hosted.dockerapi.metrics.MetricReceiverWrapper;
-import com.yahoo.vespa.hosted.node.admin.docker.DockerOperations;
import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent;
import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentImpl;
import org.junit.Test;
@@ -37,12 +36,11 @@ import static org.mockito.Mockito.when;
public class NodeAdminImplTest {
// Trick to allow mocking of typed interface without casts/warnings.
private interface NodeAgentFactory extends Function<String, NodeAgent> {}
- private final DockerOperations dockerOperations = mock(DockerOperations.class);
private final Function<String, NodeAgent> nodeAgentFactory = mock(NodeAgentFactory.class);
private final Runnable aclMaintainer = mock(Runnable.class);
private final ManualClock clock = new ManualClock();
- private final NodeAdminImpl nodeAdmin = new NodeAdminImpl(dockerOperations, nodeAgentFactory, aclMaintainer,
+ private final NodeAdminImpl nodeAdmin = new NodeAdminImpl(nodeAgentFactory, aclMaintainer,
new MetricReceiverWrapper(MetricReceiver.nullImplementation), clock);
@Test
@@ -53,7 +51,6 @@ public class NodeAdminImplTest {
final NodeAgent nodeAgent2 = mock(NodeAgentImpl.class);
when(nodeAgentFactory.apply(eq(hostName1))).thenReturn(nodeAgent1);
when(nodeAgentFactory.apply(eq(hostName2))).thenReturn(nodeAgent2);
- when(dockerOperations.getAllManagedContainers()).thenReturn(Collections.emptyList());
final InOrder inOrder = inOrder(nodeAgentFactory, nodeAgent1, nodeAgent2);
@@ -91,8 +88,6 @@ public class NodeAdminImplTest {
@Test
public void testSetFrozen() {
- when(dockerOperations.getAllManagedContainers()).thenReturn(Collections.emptyList());
-
List<NodeAgent> nodeAgents = new ArrayList<>();
Set<String> existingContainerHostnames = new HashSet<>();
for (int i = 0; i < 3; i++) {