diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2018-11-14 16:33:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 16:33:57 +0100 |
commit | 8310eefdc557d71c0e6d2591a51364017c673738 (patch) | |
tree | d9dc955fa16afd19b2cc6ee14887575c23143585 /node-admin | |
parent | 7c5dfda951dff3a79927e7ec4b184e590dc8cd5d (diff) | |
parent | cb8738a83dd8fbc15ab0cf4cd217d9c249d94090 (diff) |
Merge pull request #7619 from vespa-engine/freva/remove-container-environment-resolver
Remove ContainerEnvironmentResolver
Diffstat (limited to 'node-admin')
5 files changed, 3 insertions, 68 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/ConfigServerInfo.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/ConfigServerInfo.java index ec911cc5600..7c5ea0d5f99 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/ConfigServerInfo.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/ConfigServerInfo.java @@ -17,14 +17,12 @@ import static java.util.stream.Collectors.toMap; * @author hakon */ public class ConfigServerInfo { - private final List<String> configServerHostNames; private final URI loadBalancerEndpoint; private final Map<String, URI> configServerURIs; private final AthenzService configServerIdentity; public ConfigServerInfo(String loadBalancerHostName, List<String> configServerHostNames, String scheme, int port, AthenzService configServerAthenzIdentity) { - this.configServerHostNames = configServerHostNames; this.configServerURIs = createConfigServerUris(scheme, configServerHostNames, port); this.loadBalancerEndpoint = createLoadBalancerEndpoint(loadBalancerHostName, scheme, port); this.configServerIdentity = configServerAthenzIdentity; @@ -34,10 +32,6 @@ public class ConfigServerInfo { return URI.create(scheme + "://" + loadBalancerHost + ":" + port); } - public List<String> getConfigServerHostNames() { - return configServerHostNames; - } - public List<URI> getConfigServerUris() { return new ArrayList<>(configServerURIs.values()); } diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/ContainerEnvironmentResolver.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/ContainerEnvironmentResolver.java deleted file mode 100644 index f1218efa67c..00000000000 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/ContainerEnvironmentResolver.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2018 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.component; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec; - -import java.util.HashMap; -import java.util.Map; - -/** - * For creating environment variables that should be available inside a Docker container. - * An environment variable CONTAINER_ENVIRONMENT_SETTINGS with the settings here will be - * available inside the container. Serializing happens in ContainerEnvironmentSetting in this interface. - * - * @author hmusum - */ -@FunctionalInterface -public interface ContainerEnvironmentResolver { - - String createSettings(NodeSpec node); - - class ContainerEnvironmentSettings { - - @JsonProperty(value = "environmentVariables") - private final Map<String, Object> variables = new HashMap<>(); - - public ContainerEnvironmentSettings set(String argument, Object value) { - variables.put(argument, value); - return this; - } - - public String build() { - ObjectMapper objectMapper = new ObjectMapper(); - try { - return objectMapper.writeValueAsString(this); - } catch (JsonProcessingException e) { - throw new IllegalArgumentException("Could not write " + this, e); - } - } - } - -} diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java index 26d162fd1a0..4b8c3a222c2 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java @@ -12,7 +12,6 @@ import com.yahoo.vespa.hosted.dockerapi.ContainerStats; import com.yahoo.vespa.hosted.dockerapi.Docker; import com.yahoo.vespa.hosted.dockerapi.DockerImage; import com.yahoo.vespa.hosted.dockerapi.ProcessResult; -import com.yahoo.vespa.hosted.node.admin.component.ContainerEnvironmentResolver; import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext; import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec; import com.yahoo.vespa.hosted.node.admin.nodeagent.ContainerData; @@ -47,17 +46,11 @@ public class DockerOperationsImpl implements DockerOperations { private final Docker docker; private final ProcessExecuter processExecuter; - private final ContainerEnvironmentResolver containerEnvironmentResolver; - private final List<String> configServerHostnames; private final IPAddresses ipAddresses; - public DockerOperationsImpl(Docker docker, ProcessExecuter processExecuter, - ContainerEnvironmentResolver containerEnvironmentResolver, - List<String> configServerHostnames, IPAddresses ipAddresses) { + public DockerOperationsImpl(Docker docker, ProcessExecuter processExecuter, IPAddresses ipAddresses) { this.docker = docker; this.processExecuter = processExecuter; - this.containerEnvironmentResolver = containerEnvironmentResolver; - this.configServerHostnames = configServerHostnames; this.ipAddresses = ipAddresses; } @@ -70,16 +63,12 @@ public class DockerOperationsImpl implements DockerOperations { () -> new RuntimeException("Unable to find a valid IPv6 address for " + node.getHostname() + ". Missing an AAAA DNS entry?")); - String configServers = String.join(",", configServerHostnames); - Docker.CreateContainerCommand command = docker.createContainerCommand( node.getWantedDockerImage().get(), ContainerResources.from(node.getMinCpuCores(), node.getMinMainMemoryAvailableGb()), context.containerName(), node.getHostname()) .withManagedBy(MANAGER_NAME) - .withEnvironment("VESPA_CONFIGSERVERS", configServers) - .withEnvironment("CONTAINER_ENVIRONMENT_SETTINGS", containerEnvironmentResolver.createSettings(node)) .withUlimit("nofile", 262_144, 262_144) // The nproc aka RLIMIT_NPROC resource limit works as follows: // - A process has a (soft) nproc limit, either inherited by the parent or changed with setrlimit(2). diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java index 6e8cfce6c37..99b3fde4eb1 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java @@ -9,7 +9,6 @@ import com.yahoo.vespa.hosted.dockerapi.ContainerName; import com.yahoo.vespa.hosted.dockerapi.Docker; import com.yahoo.vespa.hosted.dockerapi.DockerImage; import com.yahoo.vespa.hosted.dockerapi.ProcessResult; -import com.yahoo.vespa.hosted.node.admin.component.ContainerEnvironmentResolver; import com.yahoo.vespa.hosted.node.admin.nodeagent.ContainerData; import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext; import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContextImpl; @@ -21,7 +20,6 @@ import org.mockito.InOrder; import java.io.IOException; import java.net.InetAddress; import java.nio.file.Paths; -import java.util.Collections; import java.util.Optional; import java.util.OptionalLong; @@ -39,10 +37,9 @@ import static org.mockito.Mockito.when; public class DockerOperationsImplTest { private final Docker docker = mock(Docker.class); private final ProcessExecuter processExecuter = mock(ProcessExecuter.class); - private final ContainerEnvironmentResolver containerEnvironmentResolver = node -> ""; private final IPAddresses ipAddresses = new IPAddressesMock(); private final DockerOperationsImpl dockerOperations = new DockerOperationsImpl( - docker, processExecuter, containerEnvironmentResolver, Collections.emptyList(), ipAddresses); + docker, processExecuter, ipAddresses); @Test public void processResultFromNodeProgramWhenSuccess() { 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 e22606104f1..b9592c9787d 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 @@ -29,7 +29,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.time.Clock; import java.time.Duration; -import java.util.Collections; import java.util.Optional; import java.util.function.Function; import java.util.logging.Logger; @@ -90,7 +89,7 @@ public class DockerTester implements AutoCloseable { Clock clock = Clock.systemUTC(); FileSystem fileSystem = TestFileSystem.create(); - DockerOperations dockerOperations = new DockerOperationsImpl(docker, processExecuter, node -> "", Collections.emptyList(), ipAddresses); + DockerOperations dockerOperations = new DockerOperationsImpl(docker, processExecuter, ipAddresses); MetricReceiverWrapper mr = new MetricReceiverWrapper(MetricReceiver.nullImplementation); Function<String, NodeAgent> nodeAgentFactory = (hostName) -> new NodeAgentImpl( |