summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorHÃ¥kon Hallingstad <hakon@oath.com>2017-12-22 22:37:13 +0100
committerGitHub <noreply@github.com>2017-12-22 22:37:13 +0100
commit4a68667c16cd2bd5ef44fd8916457ae9ef85e339 (patch)
tree54c97e359a4139993a31f1c53b2177b4137cfcf0 /node-admin
parentbf891a6a6facdcd2ed047bca877a136a061eeb29 (diff)
Revert "Support node admin modes"
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminConfig.java37
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminMain.java115
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/provider/NodeAdminProvider.java67
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerMock.java3
4 files changed, 58 insertions, 164 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminConfig.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminConfig.java
deleted file mode 100644
index 9caf1307aa4..00000000000
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminConfig.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.admin.nodeadmin;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.logging.Logger;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class NodeAdminConfig {
- private static final Logger logger = Logger.getLogger(NodeAdminConfig.class.getName());
- private static final ObjectMapper mapper = new ObjectMapper();
-
- enum Mode {
- tenant,
- config_server_host
- }
-
- @JsonProperty("mode")
- public Mode mode = Mode.tenant;
-
- public static NodeAdminConfig fromFile(File file) {
- if (!file.exists()) {
- return new NodeAdminConfig();
- }
-
- try {
- return mapper.readValue(file, NodeAdminConfig.class);
- } catch (IOException e) {
- throw new RuntimeException("Failed to read " + file + " as a " +
- NodeAdminConfig.class.getName(), e);
- }
- }
-}
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminMain.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminMain.java
deleted file mode 100644
index 02d63f5e5ed..00000000000
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminMain.java
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.admin.nodeadmin;
-
-import com.yahoo.concurrent.classlock.ClassLocking;
-import com.yahoo.net.HostName;
-import com.yahoo.system.ProcessExecuter;
-import com.yahoo.vespa.defaults.Defaults;
-import com.yahoo.vespa.hosted.dockerapi.Docker;
-import com.yahoo.vespa.hosted.dockerapi.metrics.MetricReceiverWrapper;
-import com.yahoo.vespa.hosted.node.admin.docker.DockerOperations;
-import com.yahoo.vespa.hosted.node.admin.docker.DockerOperationsImpl;
-import com.yahoo.vespa.hosted.node.admin.maintenance.StorageMaintainer;
-import com.yahoo.vespa.hosted.node.admin.maintenance.acl.AclMaintainer;
-import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent;
-import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentImpl;
-import com.yahoo.vespa.hosted.node.admin.noderepository.NodeRepository;
-import com.yahoo.vespa.hosted.node.admin.noderepository.NodeRepositoryImpl;
-import com.yahoo.vespa.hosted.node.admin.orchestrator.Orchestrator;
-import com.yahoo.vespa.hosted.node.admin.orchestrator.OrchestratorImpl;
-import com.yahoo.vespa.hosted.node.admin.util.ConfigServerHttpRequestExecutor;
-import com.yahoo.vespa.hosted.node.admin.util.Environment;
-
-import java.io.File;
-import java.time.Clock;
-import java.time.Duration;
-import java.util.function.Function;
-
-/**
- * NodeAdminMain is the main component of the node admin JDisc application:
- * - It will read config and check its environment to figure out its responsibilities
- * - It will "start" (only) the necessary components.
- * - Other components MUST NOT try to start (typically in constructor) since the features
- * they provide is NOT WANTED and possibly destructive, and/or the environment may be
- * incompatible. For instance, trying to contact the Docker daemon too early will
- * be fatal: the node admin may not have installed and started the docker daemon.
- */
-public class NodeAdminMain implements AutoCloseable {
- private static final Duration NODE_AGENT_SCAN_INTERVAL = Duration.ofSeconds(30);
- private static final Duration NODE_ADMIN_CONVERGE_STATE_INTERVAL = Duration.ofSeconds(30);
-
- private final Docker docker;
- private final MetricReceiverWrapper metricReceiver;
- private final ClassLocking classLocking;
-
- private NodeAdminStateUpdater nodeAdminStateUpdater;
-
- public NodeAdminMain(Docker docker, MetricReceiverWrapper metricReceiver, ClassLocking classLocking) {
- this.docker = docker;
- this.metricReceiver = metricReceiver;
- this.classLocking = classLocking;
- start();
- }
-
- @Override
- public void close() {
- nodeAdminStateUpdater.stop();
- }
-
- public NodeAdminStateUpdater getNodeAdminStateUpdater() {
- return nodeAdminStateUpdater;
- }
-
- public void start() {
- String staticConfigPath = Defaults.getDefaults().underVespaHome("conf/node-admin.json");
- NodeAdminConfig config = NodeAdminConfig.fromFile(new File(staticConfigPath));
-
- switch (config.mode) {
- case tenant:
- setupTenantHostNodeAdmin();
- break;
- case config_server_host:
- setupConfigServerHostNodeAdmin();
- break;
- default:
- throw new IllegalStateException(
- "Unknown bootstrap mode: " + config.mode.name());
- }
- }
-
- private void setupTenantHostNodeAdmin() {
- Clock clock = Clock.systemUTC();
- String dockerHostHostName = HostName.getLocalhost();
- ProcessExecuter processExecuter = new ProcessExecuter();
- Environment environment = new Environment();
-
- ConfigServerHttpRequestExecutor requestExecutor = ConfigServerHttpRequestExecutor.create(environment.getConfigServerUris());
- NodeRepository nodeRepository = new NodeRepositoryImpl(requestExecutor);
- Orchestrator orchestrator = new OrchestratorImpl(requestExecutor);
-
- docker.start();
- DockerOperations dockerOperations = new DockerOperationsImpl(docker, environment, processExecuter);
-
- StorageMaintainer storageMaintainer = new StorageMaintainer(docker, processExecuter, metricReceiver, environment, clock);
- AclMaintainer aclMaintainer = new AclMaintainer(dockerOperations, nodeRepository, dockerHostHostName);
-
- Function<String, NodeAgent> nodeAgentFactory =
- (hostName) -> new NodeAgentImpl(hostName, nodeRepository, orchestrator, dockerOperations,
- storageMaintainer, aclMaintainer, environment, clock, NODE_AGENT_SCAN_INTERVAL);
- NodeAdmin nodeAdmin = new NodeAdminImpl(dockerOperations, nodeAgentFactory, storageMaintainer, aclMaintainer,
- metricReceiver, clock);
-
- nodeAdminStateUpdater = new NodeAdminStateUpdater(nodeRepository, orchestrator, storageMaintainer, nodeAdmin,
- dockerHostHostName, clock, NODE_ADMIN_CONVERGE_STATE_INTERVAL, classLocking);
-
- nodeAdminStateUpdater.start();
- }
-
- private void setupConfigServerHostNodeAdmin() {
- // TODO:
- // - install and start docker daemon
- // - Read config that specifies which containers to start how
- // - use thin static backends for node repo, orchestrator, and others
- // - Start core node admin.
- }
-}
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/provider/NodeAdminProvider.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/provider/NodeAdminProvider.java
index ea9b38efa26..3777d7e20d1 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/provider/NodeAdminProvider.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/provider/NodeAdminProvider.java
@@ -4,29 +4,78 @@ package com.yahoo.vespa.hosted.node.admin.provider;
import com.google.inject.Inject;
import com.yahoo.concurrent.classlock.ClassLocking;
import com.yahoo.container.di.componentgraph.Provider;
+import com.yahoo.net.HostName;
+
+import com.yahoo.system.ProcessExecuter;
import com.yahoo.vespa.hosted.dockerapi.Docker;
import com.yahoo.vespa.hosted.dockerapi.metrics.MetricReceiverWrapper;
-import com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdminMain;
+import com.yahoo.vespa.hosted.node.admin.docker.DockerOperations;
+import com.yahoo.vespa.hosted.node.admin.maintenance.acl.AclMaintainer;
+import com.yahoo.vespa.hosted.node.admin.maintenance.StorageMaintainer;
+import com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdmin;
+import com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdminImpl;
import com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdminStateUpdater;
+import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent;
+import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentImpl;
+import com.yahoo.vespa.hosted.node.admin.docker.DockerOperationsImpl;
+import com.yahoo.vespa.hosted.node.admin.noderepository.NodeRepository;
+import com.yahoo.vespa.hosted.node.admin.noderepository.NodeRepositoryImpl;
+import com.yahoo.vespa.hosted.node.admin.orchestrator.Orchestrator;
+import com.yahoo.vespa.hosted.node.admin.orchestrator.OrchestratorImpl;
+import com.yahoo.vespa.hosted.node.admin.util.ConfigServerHttpRequestExecutor;
+import com.yahoo.vespa.hosted.node.admin.util.Environment;
+
+import java.time.Clock;
+import java.time.Duration;
+import java.util.function.Function;
+/**
+ * Set up node admin for production.
+ *
+ * @author dybis
+ */
public class NodeAdminProvider implements Provider<NodeAdminStateUpdater> {
- private final NodeAdminMain nodeAdminMain;
+
+ // WARNING: reducing the node agent interval will increase the load on the config servers
+ private static final Duration NODE_AGENT_SCAN_INTERVAL = Duration.ofSeconds(60);
+ private static final Duration NODE_ADMIN_CONVERGE_STATE_INTERVAL = Duration.ofSeconds(30);
+
+ private final NodeAdminStateUpdater nodeAdminStateUpdater;
@Inject
- public NodeAdminProvider(Docker docker,
- MetricReceiverWrapper metricReceiver,
- ClassLocking classLocking) {
- nodeAdminMain = new NodeAdminMain(docker, metricReceiver, classLocking);
- nodeAdminMain.start();
+ public NodeAdminProvider(Docker docker, MetricReceiverWrapper metricReceiver, ClassLocking classLocking) {
+ Clock clock = Clock.systemUTC();
+ String dockerHostHostName = HostName.getLocalhost();
+ ProcessExecuter processExecuter = new ProcessExecuter();
+ Environment environment = new Environment();
+
+ ConfigServerHttpRequestExecutor requestExecutor = ConfigServerHttpRequestExecutor.create(environment.getConfigServerUris());
+ NodeRepository nodeRepository = new NodeRepositoryImpl(requestExecutor);
+ Orchestrator orchestrator = new OrchestratorImpl(requestExecutor);
+ DockerOperations dockerOperations = new DockerOperationsImpl(docker, environment, processExecuter);
+
+ StorageMaintainer storageMaintainer = new StorageMaintainer(docker, processExecuter, metricReceiver, environment, clock);
+ AclMaintainer aclMaintainer = new AclMaintainer(dockerOperations, nodeRepository, dockerHostHostName);
+
+ Function<String, NodeAgent> nodeAgentFactory =
+ (hostName) -> new NodeAgentImpl(hostName, nodeRepository, orchestrator, dockerOperations,
+ storageMaintainer, aclMaintainer, environment, clock, NODE_AGENT_SCAN_INTERVAL);
+ NodeAdmin nodeAdmin = new NodeAdminImpl(dockerOperations, nodeAgentFactory, storageMaintainer, aclMaintainer,
+ metricReceiver, clock);
+
+ nodeAdminStateUpdater = new NodeAdminStateUpdater(nodeRepository, orchestrator, storageMaintainer, nodeAdmin,
+ dockerHostHostName, clock, NODE_ADMIN_CONVERGE_STATE_INTERVAL, classLocking);
+
+ nodeAdminStateUpdater.start();
}
@Override
public NodeAdminStateUpdater get() {
- return nodeAdminMain.getNodeAdminStateUpdater();
+ return nodeAdminStateUpdater;
}
@Override
public void deconstruct() {
- nodeAdminMain.close();
+ nodeAdminStateUpdater.stop();
}
}
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerMock.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerMock.java
index 7a5d713936d..a1cc1850d23 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerMock.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerMock.java
@@ -33,9 +33,6 @@ public class DockerMock implements Docker {
}
@Override
- public void start() { }
-
- @Override
public CreateContainerCommand createContainerCommand(
DockerImage dockerImage,
ContainerResources containerResources,