summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@oath.com>2019-01-09 15:29:45 +0100
committerValerij Fredriksen <valerijf@oath.com>2019-01-09 18:50:56 +0100
commit006571441a46020ecdef746cb12b76a056cd0948 (patch)
tree2506cc45ce18fecd20f569d0cf58bfbae17c2c92 /node-admin
parent5ce5a17409e60a47fdd07493f4b37f3f57ba9992 (diff)
Do not pass NodeSpec when passing NodeAgentContext
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java3
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java19
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java39
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java84
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java11
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java30
6 files changed, 91 insertions, 95 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java
index c65d59a79dc..af8dfb1fd27 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java
@@ -7,7 +7,6 @@ import com.yahoo.vespa.hosted.dockerapi.ContainerStats;
import com.yahoo.vespa.hosted.dockerapi.DockerImage;
import com.yahoo.vespa.hosted.dockerapi.ProcessResult;
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;
import java.util.List;
@@ -15,7 +14,7 @@ import java.util.Optional;
public interface DockerOperations {
- void createContainer(NodeAgentContext context, NodeSpec node, ContainerData containerData);
+ void createContainer(NodeAgentContext context, ContainerData containerData);
void startContainer(NodeAgentContext context);
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 89ab2e60b63..e1b77b6a41b 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
@@ -13,7 +13,6 @@ 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.nodeagent.NodeAgentContext;
-import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec;
import com.yahoo.vespa.hosted.node.admin.nodeagent.ContainerData;
import com.yahoo.vespa.hosted.node.admin.task.util.network.IPAddresses;
@@ -55,19 +54,19 @@ public class DockerOperationsImpl implements DockerOperations {
}
@Override
- public void createContainer(NodeAgentContext context, NodeSpec node, ContainerData containerData) {
+ public void createContainer(NodeAgentContext context, ContainerData containerData) {
context.log(logger, "Creating container");
// IPv6 - Assume always valid
- Inet6Address ipV6Address = ipAddresses.getIPv6Address(node.getHostname()).orElseThrow(
- () -> new RuntimeException("Unable to find a valid IPv6 address for " + node.getHostname() +
+ Inet6Address ipV6Address = ipAddresses.getIPv6Address(context.node().getHostname()).orElseThrow(
+ () -> new RuntimeException("Unable to find a valid IPv6 address for " + context.node().getHostname() +
". Missing an AAAA DNS entry?"));
Docker.CreateContainerCommand command = docker.createContainerCommand(
- node.getWantedDockerImage().get(),
- ContainerResources.from(node.getMinCpuCores(), node.getMinMainMemoryAvailableGb()),
+ context.node().getWantedDockerImage().get(),
+ ContainerResources.from(context.node().getMinCpuCores(), context.node().getMinMainMemoryAvailableGb()),
context.containerName(),
- node.getHostname())
+ context.node().getHostname())
.withManagedBy(MANAGER_NAME)
.withUlimit("nofile", 262_144, 262_144)
// The nproc aka RLIMIT_NPROC resource limit works as follows:
@@ -100,20 +99,20 @@ public class DockerOperationsImpl implements DockerOperations {
command.withIpAddress(ipV6Local);
// IPv4 - Only present for some containers
- Optional<InetAddress> ipV4Local = ipAddresses.getIPv4Address(node.getHostname())
+ Optional<InetAddress> ipV4Local = ipAddresses.getIPv4Address(context.node().getHostname())
.map(ipV4Address -> {
InetAddress ipV4Prefix = InetAddresses.forString(IPV4_NPT_PREFIX);
return IPAddresses.prefixTranslate(ipV4Address, ipV4Prefix, 2);
});
ipV4Local.ifPresent(command::withIpAddress);
- addEtcHosts(containerData, node.getHostname(), ipV4Local, ipV6Local);
+ addEtcHosts(containerData, context.node().getHostname(), ipV4Local, ipV6Local);
}
addMounts(context, command);
// TODO: Enforce disk constraints
- long minMainMemoryAvailableMb = (long) (node.getMinMainMemoryAvailableGb() * 1024);
+ long minMainMemoryAvailableMb = (long) (context.node().getMinMainMemoryAvailableGb() * 1024);
if (minMainMemoryAvailableMb > 0) {
// VESPA_TOTAL_MEMORY_MB is used to make any jdisc container think the machine
// only has this much physical memory (overrides total memory reported by `free -m`).
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java
index 2fd40a1b486..0cd50a649b1 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java
@@ -7,7 +7,6 @@ import com.yahoo.config.provision.NodeType;
import com.yahoo.log.LogLevel;
import com.yahoo.vespa.hosted.dockerapi.Container;
import com.yahoo.vespa.hosted.node.admin.component.TaskContext;
-import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec;
import com.yahoo.vespa.hosted.node.admin.docker.DockerOperations;
import com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoredumpHandler;
import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext;
@@ -65,9 +64,9 @@ public class StorageMaintainer {
this.archiveContainerStoragePath = archiveContainerStoragePath;
}
- public void writeMetricsConfig(NodeAgentContext context, NodeSpec node) {
+ public void writeMetricsConfig(NodeAgentContext context) {
List<SecretAgentCheckConfig> configs = new ArrayList<>();
- Map<String, Object> tags = generateTags(context, node);
+ Map<String, Object> tags = generateTags(context);
// host-life
Path hostLifeCheckPath = context.pathInNodeUnderVespaHome("libexec/yms/yms_check_host_life");
@@ -154,26 +153,26 @@ public class StorageMaintainer {
dockerOperations.executeCommandInContainerAsRoot(context, "service", "yamas-agent", "restart");
}
- private Map<String, Object> generateTags(NodeAgentContext context, NodeSpec node) {
+ private Map<String, Object> generateTags(NodeAgentContext context) {
Map<String, String> tags = new LinkedHashMap<>();
tags.put("namespace", "Vespa");
- tags.put("role", nodeTypeToRole(node.getNodeType()));
+ tags.put("role", nodeTypeToRole(context.node().getNodeType()));
tags.put("zone", String.format("%s.%s", context.zoneId().environment().value(), context.zoneId().regionName().value()));
- node.getVespaVersion().ifPresent(version -> tags.put("vespaVersion", version));
+ context.node().getVespaVersion().ifPresent(version -> tags.put("vespaVersion", version));
if (! isConfigserverLike(context.nodeType())) {
- tags.put("flavor", node.getFlavor());
- tags.put("canonicalFlavor", node.getCanonicalFlavor());
- tags.put("state", node.getState().toString());
- node.getParentHostname().ifPresent(parent -> tags.put("parentHostname", parent));
- node.getOwner().ifPresent(owner -> {
+ tags.put("flavor", context.node().getFlavor());
+ tags.put("canonicalFlavor", context.node().getCanonicalFlavor());
+ tags.put("state", context.node().getState().toString());
+ context.node().getParentHostname().ifPresent(parent -> tags.put("parentHostname", parent));
+ context.node().getOwner().ifPresent(owner -> {
tags.put("tenantName", owner.getTenant());
tags.put("app", owner.getApplication() + "." + owner.getInstance());
tags.put("applicationName", owner.getApplication());
tags.put("instanceName", owner.getInstance());
tags.put("applicationId", owner.getTenant() + "." + owner.getApplication() + "." + owner.getInstance());
});
- node.getMembership().ifPresent(membership -> {
+ context.node().getMembership().ifPresent(membership -> {
tags.put("clustertype", membership.getClusterType());
tags.put("clusterid", membership.getClusterId());
});
@@ -253,23 +252,23 @@ public class StorageMaintainer {
}
/** Checks if container has any new coredumps, reports and archives them if so */
- public void handleCoreDumpsForContainer(NodeAgentContext context, NodeSpec node, Optional<Container> container) {
- final Map<String, Object> nodeAttributes = getCoredumpNodeAttributes(context, node, container);
+ public void handleCoreDumpsForContainer(NodeAgentContext context, Optional<Container> container) {
+ final Map<String, Object> nodeAttributes = getCoredumpNodeAttributes(context, container);
coredumpHandler.converge(context, nodeAttributes);
}
- private Map<String, Object> getCoredumpNodeAttributes(NodeAgentContext context, NodeSpec node, Optional<Container> container) {
+ private Map<String, Object> getCoredumpNodeAttributes(NodeAgentContext context, Optional<Container> container) {
Map<String, String> attributes = new HashMap<>();
- attributes.put("hostname", node.getHostname());
+ attributes.put("hostname", context.node().getHostname());
attributes.put("region", context.zoneId().regionName().value());
attributes.put("environment", context.zoneId().environment().value());
- attributes.put("flavor", node.getFlavor());
+ attributes.put("flavor", context.node().getFlavor());
attributes.put("kernel_version", System.getProperty("os.version"));
container.map(c -> c.image).ifPresent(image -> attributes.put("docker_image", image.asString()));
- node.getParentHostname().ifPresent(parent -> attributes.put("parent_hostname", parent));
- node.getVespaVersion().ifPresent(version -> attributes.put("vespa_version", version));
- node.getOwner().ifPresent(owner -> {
+ context.node().getParentHostname().ifPresent(parent -> attributes.put("parent_hostname", parent));
+ context.node().getVespaVersion().ifPresent(version -> attributes.put("vespa_version", version));
+ context.node().getOwner().ifPresent(owner -> {
attributes.put("tenant", owner.getTenant());
attributes.put("application", owner.getApplication());
attributes.put("instance", owner.getInstance());
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 ce1acea7d39..0bfff82a055 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
@@ -176,10 +176,10 @@ public class NodeAgentImpl implements NodeAgent {
}
}
- void resumeNodeIfNeeded(NodeAgentContext context, NodeSpec node) {
+ void resumeNodeIfNeeded(NodeAgentContext context) {
if (!hasResumedNode) {
if (!currentFilebeatRestarter.isPresent()) {
- storageMaintainer.writeMetricsConfig(context, node);
+ storageMaintainer.writeMetricsConfig(context);
currentFilebeatRestarter = Optional.of(filebeatRestarter.scheduleWithFixedDelay(
() -> serviceRestarter.accept("filebeat"), 1, 1, TimeUnit.DAYS));
}
@@ -190,24 +190,24 @@ public class NodeAgentImpl implements NodeAgent {
}
}
- private void updateNodeRepoWithCurrentAttributes(NodeAgentContext context, NodeSpec node) {
+ private void updateNodeRepoWithCurrentAttributes(NodeAgentContext context) {
final NodeAttributes currentNodeAttributes = new NodeAttributes();
final NodeAttributes newNodeAttributes = new NodeAttributes();
- if (node.getWantedRestartGeneration().isPresent() &&
- !Objects.equals(node.getCurrentRestartGeneration(), currentRestartGeneration)) {
- currentNodeAttributes.withRestartGeneration(node.getCurrentRestartGeneration());
+ if (context.node().getWantedRestartGeneration().isPresent() &&
+ !Objects.equals(context.node().getCurrentRestartGeneration(), currentRestartGeneration)) {
+ currentNodeAttributes.withRestartGeneration(context.node().getCurrentRestartGeneration());
newNodeAttributes.withRestartGeneration(currentRestartGeneration);
}
- if (!Objects.equals(node.getCurrentRebootGeneration(), currentRebootGeneration)) {
- currentNodeAttributes.withRebootGeneration(node.getCurrentRebootGeneration());
+ if (!Objects.equals(context.node().getCurrentRebootGeneration(), currentRebootGeneration)) {
+ currentNodeAttributes.withRebootGeneration(context.node().getCurrentRebootGeneration());
newNodeAttributes.withRebootGeneration(currentRebootGeneration);
}
- Optional<DockerImage> actualDockerImage = node.getWantedDockerImage().filter(n -> containerState == UNKNOWN);
- if (!Objects.equals(node.getCurrentDockerImage(), actualDockerImage)) {
- currentNodeAttributes.withDockerImage(node.getCurrentDockerImage().orElse(new DockerImage("")));
+ Optional<DockerImage> actualDockerImage = context.node().getWantedDockerImage().filter(n -> containerState == UNKNOWN);
+ if (!Objects.equals(context.node().getCurrentDockerImage(), actualDockerImage)) {
+ currentNodeAttributes.withDockerImage(context.node().getCurrentDockerImage().orElse(new DockerImage("")));
newNodeAttributes.withDockerImage(actualDockerImage.orElse(new DockerImage("")));
}
@@ -222,9 +222,9 @@ public class NodeAgentImpl implements NodeAgent {
}
}
- private void startContainer(NodeAgentContext context, NodeSpec node) {
- ContainerData containerData = createContainerData(context, node);
- dockerOperations.createContainer(context, node, containerData);
+ private void startContainer(NodeAgentContext context) {
+ ContainerData containerData = createContainerData(context);
+ dockerOperations.createContainer(context, containerData);
dockerOperations.startContainer(context);
lastCpuMetric = new CpuUsageReporter();
@@ -234,14 +234,14 @@ public class NodeAgentImpl implements NodeAgent {
}
private Optional<Container> removeContainerIfNeededUpdateContainerState(
- NodeAgentContext context, NodeSpec node, Optional<Container> existingContainer) {
+ NodeAgentContext context, Optional<Container> existingContainer) {
return existingContainer
- .flatMap(container -> removeContainerIfNeeded(context, node, container))
+ .flatMap(container -> removeContainerIfNeeded(context, container))
.map(container -> {
- shouldRestartServices(node).ifPresent(restartReason -> {
+ shouldRestartServices(context.node()).ifPresent(restartReason -> {
context.log(logger, "Will restart services: " + restartReason);
- restartServices(context, node, container);
- currentRestartGeneration = node.getWantedRestartGeneration();
+ restartServices(context, container);
+ currentRestartGeneration = context.node().getWantedRestartGeneration();
});
return container;
});
@@ -258,8 +258,8 @@ public class NodeAgentImpl implements NodeAgent {
return Optional.empty();
}
- private void restartServices(NodeAgentContext context, NodeSpec node, Container existingContainer) {
- if (existingContainer.state.isRunning() && node.getState() == Node.State.active) {
+ private void restartServices(NodeAgentContext context, Container existingContainer) {
+ if (existingContainer.state.isRunning() && context.node().getState() == Node.State.active) {
context.log(logger, "Restarting services");
// Since we are restarting the services we need to suspend the node.
orchestratorSuspendNode(context);
@@ -326,18 +326,18 @@ public class NodeAgentImpl implements NodeAgent {
return Optional.empty();
}
- private Optional<Container> removeContainerIfNeeded(NodeAgentContext context, NodeSpec node, Container existingContainer) {
- Optional<String> removeReason = shouldRemoveContainer(node, existingContainer);
+ private Optional<Container> removeContainerIfNeeded(NodeAgentContext context, Container existingContainer) {
+ Optional<String> removeReason = shouldRemoveContainer(context.node(), existingContainer);
if (removeReason.isPresent()) {
context.log(logger, "Will remove container: " + removeReason.get());
if (existingContainer.state.isRunning()) {
- if (node.getState() == Node.State.active) {
+ if (context.node().getState() == Node.State.active) {
orchestratorSuspendNode(context);
}
try {
- if (node.getState() != Node.State.dirty) {
+ if (context.node().getState() != Node.State.dirty) {
suspend();
}
stopServices();
@@ -346,9 +346,9 @@ public class NodeAgentImpl implements NodeAgent {
}
}
stopFilebeatSchedulerIfNeeded();
- storageMaintainer.handleCoreDumpsForContainer(context, node, Optional.of(existingContainer));
+ storageMaintainer.handleCoreDumpsForContainer(context, Optional.of(existingContainer));
dockerOperations.removeContainer(context, existingContainer);
- currentRebootGeneration = node.getWantedRebootGeneration();
+ currentRebootGeneration = context.node().getWantedRebootGeneration();
containerState = ABSENT;
context.log(logger, "Container successfully removed, new containerState is " + containerState);
return Optional.empty();
@@ -404,7 +404,7 @@ public class NodeAgentImpl implements NodeAgent {
// Every time the node spec changes, we should clear the metrics for this container as the dimensions
// will change and we will be reporting duplicate metrics.
if (container.map(c -> c.state.isRunning()).orElse(false)) {
- storageMaintainer.writeMetricsConfig(context, node);
+ storageMaintainer.writeMetricsConfig(context);
}
lastNode = node;
@@ -415,11 +415,11 @@ public class NodeAgentImpl implements NodeAgent {
case reserved:
case parked:
case failed:
- removeContainerIfNeededUpdateContainerState(context, node, container);
- updateNodeRepoWithCurrentAttributes(context, node);
+ removeContainerIfNeededUpdateContainerState(context, container);
+ updateNodeRepoWithCurrentAttributes(context);
break;
case active:
- storageMaintainer.handleCoreDumpsForContainer(context, node, container);
+ storageMaintainer.handleCoreDumpsForContainer(context, container);
storageMaintainer.getDiskUsageFor(context)
.map(diskUsage -> (double) diskUsage / BYTES_IN_GB / node.getMinDiskAvailableGb())
@@ -431,17 +431,17 @@ public class NodeAgentImpl implements NodeAgent {
context.log(logger, LogLevel.DEBUG, "Waiting for image to download " + imageBeingDownloaded.asString());
return;
}
- container = removeContainerIfNeededUpdateContainerState(context, node, container);
+ container = removeContainerIfNeededUpdateContainerState(context, container);
athenzCredentialsMaintainer.ifPresent(maintainer -> maintainer.converge(context));
if (! container.isPresent()) {
containerState = STARTING;
- startContainer(context, node);
+ startContainer(context);
containerState = UNKNOWN;
aclMaintainer.ifPresent(AclMaintainer::converge);
}
startServicesIfNeeded(context);
- resumeNodeIfNeeded(context, node);
+ resumeNodeIfNeeded(context);
healthChecker.ifPresent(checker -> checker.verifyHealth(context));
// Because it's more important to stop a bad release from rolling out in prod,
@@ -454,23 +454,23 @@ public class NodeAgentImpl implements NodeAgent {
// has been successfully rolled out.
// - Slobrok and internal orchestrator state is used to determine whether
// to allow upgrade (suspend).
- updateNodeRepoWithCurrentAttributes(context, node);
+ updateNodeRepoWithCurrentAttributes(context);
context.log(logger, "Call resume against Orchestrator");
orchestrator.resume(context.hostname().value());
break;
case inactive:
- removeContainerIfNeededUpdateContainerState(context, node, container);
- updateNodeRepoWithCurrentAttributes(context, node);
+ removeContainerIfNeededUpdateContainerState(context, container);
+ updateNodeRepoWithCurrentAttributes(context);
break;
case provisioned:
nodeRepository.setNodeState(context.hostname().value(), Node.State.dirty);
break;
case dirty:
- removeContainerIfNeededUpdateContainerState(context, node, container);
+ removeContainerIfNeededUpdateContainerState(context, container);
context.log(logger, "State is " + node.getState() + ", will delete application storage and mark node as ready");
athenzCredentialsMaintainer.ifPresent(maintainer -> maintainer.clearCredentials(context));
storageMaintainer.archiveNodeStorage(context);
- updateNodeRepoWithCurrentAttributes(context, node);
+ updateNodeRepoWithCurrentAttributes(context);
nodeRepository.setNodeState(context.hostname().value(), Node.State.ready);
break;
default:
@@ -478,7 +478,7 @@ public class NodeAgentImpl implements NodeAgent {
}
}
- private void logChangesToNodeSpec(NodeAgentContext context, NodeSpec lastNode, NodeSpec node) {
+ private static void logChangesToNodeSpec(NodeAgentContext context, NodeSpec lastNode, NodeSpec node) {
StringBuilder builder = new StringBuilder();
appendIfDifferent(builder, "state", lastNode, node, NodeSpec::getState);
if (builder.length() > 0) {
@@ -490,7 +490,7 @@ public class NodeAgentImpl implements NodeAgent {
return value == null ? "[absent]" : value.toString();
}
- private <T> void appendIfDifferent(StringBuilder builder, String name, NodeSpec oldNode, NodeSpec newNode, Function<NodeSpec, T> getter) {
+ private static <T> void appendIfDifferent(StringBuilder builder, String name, NodeSpec oldNode, NodeSpec newNode, Function<NodeSpec, T> getter) {
T oldValue = oldNode == null ? null : getter.apply(oldNode);
T newValue = getter.apply(newNode);
if (!Objects.equals(oldValue, newValue)) {
@@ -667,7 +667,7 @@ public class NodeAgentImpl implements NodeAgent {
orchestrator.suspend(context.hostname().value());
}
- protected ContainerData createContainerData(NodeAgentContext context, NodeSpec node) {
+ protected ContainerData createContainerData(NodeAgentContext context) {
return (pathInContainer, data) -> {
throw new UnsupportedOperationException("addFile not implemented");
};
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java
index 9ea5c87511b..05b9c413594 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java
@@ -152,12 +152,8 @@ public class StorageMaintainerTest {
}
private Path executeAs(NodeType nodeType) {
- NodeAgentContext context = new NodeAgentContextImpl.Builder("host123-5.test.domain.tld")
- .nodeType(nodeType)
- .fileSystem(TestFileSystem.create())
- .zoneId(new ZoneId(SystemName.dev, Environment.prod, RegionName.from("us-north-1"))).build();
NodeSpec nodeSpec = new NodeSpec.Builder()
- .hostname(context.hostname().value())
+ .hostname("host123-5.test.domain.tld")
.nodeType(nodeType)
.state(Node.State.active)
.parentHostname("host123.test.domain.tld")
@@ -167,9 +163,12 @@ public class StorageMaintainerTest {
.flavor("d-2-8-50")
.canonicalFlavor("d-2-8-50")
.build();
+ NodeAgentContext context = new NodeAgentContextImpl.Builder(nodeSpec)
+ .fileSystem(TestFileSystem.create())
+ .zoneId(new ZoneId(SystemName.dev, Environment.prod, RegionName.from("us-north-1"))).build();
Path path = context.pathOnHostFromPathInNode("/etc/yamas-agent");
uncheck(() -> Files.createDirectories(path));
- storageMaintainer.writeMetricsConfig(context, nodeSpec);
+ storageMaintainer.writeMetricsConfig(context);
return path;
}
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 aa1b72aa210..e392ac34414 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
@@ -194,7 +194,7 @@ public class NodeAgentImplTest {
final InOrder inOrder = inOrder(dockerOperations, orchestrator, nodeRepository, aclMaintainer, healthChecker);
inOrder.verify(dockerOperations, times(1)).pullImageAsyncIfNeeded(eq(dockerImage));
- inOrder.verify(dockerOperations, times(1)).createContainer(eq(context), eq(node), any());
+ inOrder.verify(dockerOperations, times(1)).createContainer(eq(context), any());
inOrder.verify(dockerOperations, times(1)).startContainer(eq(context));
inOrder.verify(aclMaintainer, times(1)).converge();
inOrder.verify(dockerOperations, times(1)).resumeNode(eq(context));
@@ -258,7 +258,7 @@ public class NodeAgentImplTest {
inOrder.verify(orchestrator).resume(any(String.class));
inOrder.verify(orchestrator).suspend(any(String.class));
inOrder.verify(dockerOperations).removeContainer(eq(thirdContext), any());
- inOrder.verify(dockerOperations, times(1)).createContainer(eq(thirdContext), eq(thirdContext.node()), any());
+ inOrder.verify(dockerOperations, times(1)).createContainer(eq(thirdContext), any());
inOrder.verify(dockerOperations).startContainer(eq(thirdContext));
inOrder.verify(orchestrator).resume(any(String.class));
}
@@ -286,7 +286,7 @@ public class NodeAgentImplTest {
fail("Expected to throw an exception");
} catch (OrchestratorException ignored) { }
- verify(dockerOperations, never()).createContainer(eq(context), eq(node), any());
+ verify(dockerOperations, never()).createContainer(eq(context), any());
verify(dockerOperations, never()).startContainer(eq(context));
verify(orchestrator, never()).resume(any(String.class));
verify(nodeRepository, never()).updateNodeAttributes(any(String.class), any(NodeAttributes.class));
@@ -322,7 +322,7 @@ public class NodeAgentImplTest {
// First time we fail to resume because health verification fails
verify(orchestrator, times(1)).suspend(eq(hostName));
verify(dockerOperations, times(1)).removeContainer(eq(context), any());
- verify(dockerOperations, times(1)).createContainer(eq(context), eq(node), any());
+ verify(dockerOperations, times(1)).createContainer(eq(context), any());
verify(dockerOperations, times(1)).startContainer(eq(context));
verify(orchestrator, never()).resume(eq(hostName));
verify(nodeRepository, never()).updateNodeAttributes(any(), any());
@@ -331,7 +331,7 @@ public class NodeAgentImplTest {
// Do not reboot the container again
verify(dockerOperations, times(1)).removeContainer(eq(context), any());
- verify(dockerOperations, times(1)).createContainer(eq(context), eq(node), any());
+ verify(dockerOperations, times(1)).createContainer(eq(context), any());
verify(orchestrator, times(1)).resume(eq(hostName));
verify(nodeRepository, times(1)).updateNodeAttributes(eq(hostName), eq(new NodeAttributes()
.withRebootGeneration(wantedRebootGeneration)));
@@ -377,7 +377,7 @@ public class NodeAgentImplTest {
// Should only be called once, when we initialize
verify(dockerOperations, times(1)).getContainer(eq(context));
verify(dockerOperations, never()).removeContainer(eq(context), any());
- verify(dockerOperations, never()).createContainer(eq(context), eq(node), any());
+ verify(dockerOperations, never()).createContainer(eq(context), any());
verify(dockerOperations, never()).startContainer(eq(context));
verify(orchestrator, never()).resume(any(String.class));
verify(nodeRepository, never()).updateNodeAttributes(eq(hostName), any());
@@ -445,12 +445,12 @@ public class NodeAgentImplTest {
final InOrder inOrder = inOrder(storageMaintainer, dockerOperations, nodeRepository);
inOrder.verify(dockerOperations, times(1)).stopServices(eq(context));
- inOrder.verify(storageMaintainer, times(1)).handleCoreDumpsForContainer(eq(context), eq(node), any());
+ inOrder.verify(storageMaintainer, times(1)).handleCoreDumpsForContainer(eq(context), any());
inOrder.verify(dockerOperations, times(1)).removeContainer(eq(context), any());
inOrder.verify(storageMaintainer, times(1)).archiveNodeStorage(eq(context));
inOrder.verify(nodeRepository, times(1)).setNodeState(eq(hostName), eq(Node.State.ready));
- verify(dockerOperations, never()).createContainer(eq(context), any(), any());
+ verify(dockerOperations, never()).createContainer(eq(context), any());
verify(dockerOperations, never()).startContainer(eq(context));
verify(dockerOperations, never()).suspendNode(eq(context));
verify(dockerOperations, times(1)).stopServices(eq(context));
@@ -504,7 +504,7 @@ public class NodeAgentImplTest {
nodeAgent.doConverge(context);
verify(dockerOperations, times(1)).removeContainer(eq(context), any());
- verify(dockerOperations, times(1)).createContainer(eq(context), eq(node), any());
+ verify(dockerOperations, times(1)).createContainer(eq(context), any());
verify(dockerOperations, times(1)).startContainer(eq(context));
}
@@ -566,9 +566,9 @@ public class NodeAgentImplTest {
} catch (DockerException ignored) { }
verify(dockerOperations, never()).removeContainer(eq(context), any());
- verify(dockerOperations, times(1)).createContainer(eq(context), eq(node), any());
+ verify(dockerOperations, times(1)).createContainer(eq(context), any());
verify(dockerOperations, times(1)).startContainer(eq(context));
- verify(nodeAgent, never()).resumeNodeIfNeeded(any(), any());
+ verify(nodeAgent, never()).resumeNodeIfNeeded(any());
// The docker container was actually started and is running, but subsequent exec calls to set up
// networking failed
@@ -576,9 +576,9 @@ public class NodeAgentImplTest {
nodeAgent.doConverge(context);
verify(dockerOperations, times(1)).removeContainer(eq(context), any());
- verify(dockerOperations, times(2)).createContainer(eq(context), eq(node), any());
+ verify(dockerOperations, times(2)).createContainer(eq(context), any());
verify(dockerOperations, times(2)).startContainer(eq(context));
- verify(nodeAgent, times(1)).resumeNodeIfNeeded(any(), any());
+ verify(nodeAgent, times(1)).resumeNodeIfNeeded(any());
}
@Test
@@ -686,7 +686,7 @@ public class NodeAgentImplTest {
final InOrder inOrder = inOrder(dockerOperations, orchestrator, nodeRepository, aclMaintainer);
inOrder.verify(dockerOperations, times(1)).pullImageAsyncIfNeeded(eq(dockerImage));
- inOrder.verify(dockerOperations, times(1)).createContainer(eq(context), eq(node), any());
+ inOrder.verify(dockerOperations, times(1)).createContainer(eq(context), any());
inOrder.verify(dockerOperations, times(1)).startContainer(eq(context));
inOrder.verify(aclMaintainer, times(1)).converge();
inOrder.verify(dockerOperations, times(1)).resumeNode(eq(context));
@@ -699,7 +699,7 @@ public class NodeAgentImplTest {
mockGetContainer(dockerImage, isRunning);
when(dockerOperations.getContainerStats(any())).thenReturn(Optional.of(emptyContainerStats));
- doNothing().when(storageMaintainer).writeMetricsConfig(any(), any());
+ doNothing().when(storageMaintainer).writeMetricsConfig(any());
return new NodeAgentImpl(contextSupplier, nodeRepository, orchestrator, dockerOperations,
storageMaintainer, Optional.of(athenzCredentialsMaintainer), Optional.of(aclMaintainer),