diff options
author | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-07-04 11:10:50 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-07-04 11:24:56 +0200 |
commit | 36d91d1cf1c30b6e0e8f6aad4c449e2d75fcb3aa (patch) | |
tree | 60838f37ec800154d497568f891f1a0c40dd4c27 | |
parent | 62bacdeb10990055935375bb76e76e2f34e8e214 (diff) |
Remove metrics check config writer code
8 files changed, 4 insertions, 514 deletions
diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/metrics/DimensionMetrics.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/metrics/DimensionMetrics.java index 46a0f9b9b10..590ef207e3f 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/metrics/DimensionMetrics.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/metrics/DimensionMetrics.java @@ -1,22 +1,15 @@ // 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.dockerapi.metrics; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.TreeMap; import java.util.stream.Collectors; /** * @author freva */ public class DimensionMetrics { - private static final ObjectMapper objectMapper = new ObjectMapper(); - private static final Map<String, Object> routing = Map.of("yamas", Map.of("namespaces", List.of("Vespa"))); private final String application; private final Dimensions dimensions; @@ -30,17 +23,6 @@ public class DimensionMetrics { .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } - public String toSecretAgentReport() throws JsonProcessingException { - Map<String, Object> report = new TreeMap<>(); - report.put("application", application); - report.put("dimensions", new TreeMap<>(dimensions.asMap())); - report.put("metrics", new TreeMap<>(metrics)); - report.put("routing", routing); - report.put("timestamp", System.currentTimeMillis() / 1000); - - return objectMapper.writeValueAsString(report); - } - public String getApplication() { return application; } 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 26e4dcda88e..167ca15bdbf 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 @@ -3,17 +3,14 @@ package com.yahoo.vespa.hosted.node.admin.maintenance; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -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.docker.DockerOperations; import com.yahoo.vespa.hosted.node.admin.maintenance.coredump.CoredumpHandler; import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext; import com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder; import com.yahoo.vespa.hosted.node.admin.task.util.file.UnixPath; import com.yahoo.vespa.hosted.node.admin.task.util.process.Terminal; -import com.yahoo.vespa.hosted.node.admin.util.SecretAgentCheckConfig; import java.nio.file.Files; import java.nio.file.Path; @@ -22,11 +19,8 @@ import java.time.Duration; import java.time.Instant; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; @@ -35,7 +29,6 @@ import java.util.regex.Pattern; import static com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder.nameMatches; import static com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder.olderThan; -import static com.yahoo.vespa.hosted.node.admin.util.SecretAgentCheckConfig.nodeTypeToRole; import static com.yahoo.yolean.Exceptions.uncheck; /** @@ -47,7 +40,6 @@ public class StorageMaintainer { .ofPattern("yyyyMMddHHmmss").withZone(ZoneOffset.UTC); private final Terminal terminal; - private final DockerOperations dockerOperations; private final CoredumpHandler coredumpHandler; private final Path archiveContainerStoragePath; @@ -57,134 +49,12 @@ public class StorageMaintainer { .expireAfterWrite(5, TimeUnit.MINUTES) .build(); - public StorageMaintainer(Terminal terminal, DockerOperations dockerOperations, CoredumpHandler coredumpHandler, Path archiveContainerStoragePath) { + public StorageMaintainer(Terminal terminal, CoredumpHandler coredumpHandler, Path archiveContainerStoragePath) { this.terminal = terminal; - this.dockerOperations = dockerOperations; this.coredumpHandler = coredumpHandler; this.archiveContainerStoragePath = archiveContainerStoragePath; } - public void writeMetricsConfig(NodeAgentContext context) { - List<SecretAgentCheckConfig> configs = new ArrayList<>(); - Map<String, Object> tags = generateTags(context); - - // host-life - Path hostLifeCheckPath = context.pathInNodeUnderVespaHome("libexec/yms/yms_check_host_life"); - configs.add(new SecretAgentCheckConfig("host-life", 60, hostLifeCheckPath).withTags(tags)); - - // coredumps (except for the done coredumps which is handled by the host) - Path coredumpCheckPath = context.pathInNodeUnderVespaHome("libexec/yms/yms_check_coredumps"); - configs.add(new SecretAgentCheckConfig("system-coredumps-processing", 300, coredumpCheckPath, - "--application", "system-coredumps-processing", - "--lastmin", "129600", - "--crit", "1", - "--coredir", context.pathInNodeUnderVespaHome("var/crash/processing").toString()) - .withTags(tags)); - - // athenz certificate check - Path athenzCertExpiryCheckPath = context.pathInNodeUnderVespaHome("libexec64/yms/yms_check_athenz_certs"); - configs.add(new SecretAgentCheckConfig("athenz-certificate-expiry", 60, athenzCertExpiryCheckPath, - "--threshold", "20") - .withRunAsUser("root") - .withTags(tags)); - - if (context.nodeType() != NodeType.config) { - // vespa-health - Path vespaHealthCheckPath = context.pathInNodeUnderVespaHome("libexec/yms/yms_check_vespa_health"); - configs.add(new SecretAgentCheckConfig("vespa-health", 60, vespaHealthCheckPath, "all") - .withRunAsUser(context.vespaUser()) - .withTags(tags)); - - // vespa - Path vespaCheckPath = context.pathInNodeUnderVespaHome("libexec/yms/yms_check_vespa"); - SecretAgentCheckConfig vespaSchedule = new SecretAgentCheckConfig("vespa", 60, vespaCheckPath, "all"); - vespaSchedule.withRunAsUser(context.vespaUser()); - if (isConfigserverLike(context.nodeType())) { - Map<String, Object> tagsWithoutNameSpace = new LinkedHashMap<>(tags); - tagsWithoutNameSpace.remove("namespace"); - vespaSchedule.withTags(tagsWithoutNameSpace); - } - configs.add(vespaSchedule); - } - - if (context.nodeType() == NodeType.config || context.nodeType() == NodeType.controller) { - - // configserver/controller - Path configServerNewCheckPath = Paths.get("/usr/bin/curl"); - configs.add(new SecretAgentCheckConfig(nodeTypeToRole(context.nodeType()), 60, configServerNewCheckPath, - "-s", "localhost:19071/yamas-metrics") - .withTags(tags)); - - //zkbackupage - Path zkbackupCheckPath = context.pathInNodeUnderVespaHome("libexec/yamas2/yms_check_file_age.py"); - configs.add(new SecretAgentCheckConfig("zkbackupage", 300, zkbackupCheckPath, - "-f", context.pathInNodeUnderVespaHome("var/vespa-hosted/zkbackup.stat").toString(), - "-m", "150", - "-a", "config-zkbackupage") - .withTags(tags)); - - String appName = nodeTypeToRole(context.nodeType()) + "-logd"; - Path logdCheckPath = context.pathInNodeUnderVespaHome("libexec/yms/convert-state-metrics-2-yamas.py"); - configs.add(new SecretAgentCheckConfig(appName, 60, logdCheckPath, - appName, "http://localhost:19089/state/v1/metrics") - .withTags(tags)); - } - - if (context.nodeType() == NodeType.proxy) { - //routing-configage - Path routingAgeCheckPath = context.pathInNodeUnderVespaHome("libexec/yamas2/yms_check_file_age.py"); - configs.add(new SecretAgentCheckConfig("routing-configage", 60, routingAgeCheckPath, - "-f", context.pathInNodeUnderVespaHome("var/vespa-hosted/routing/nginx.conf.tmp").toString(), - "-m", "1", - "-a", "routing-configage", - "--ignore_file_not_found") - .withTags(tags)); - - //ssl-check - Path sslCheckPath = context.pathInNodeUnderVespaHome("libexec/yms/yms_check_ssl_status"); - configs.add(new SecretAgentCheckConfig("ssl-status", 300, sslCheckPath, - "-e", "localhost", - "-p", "4443", - "-t", "30") - .withTags(tags)); - } - - // Write config and restart yamas-agent - Path yamasAgentFolder = context.pathOnHostFromPathInNode("/etc/yamas-agent"); - configs.forEach(s -> uncheck(() -> s.writeTo(yamasAgentFolder))); - dockerOperations.executeCommandInContainerAsRoot(context, "service", "yamas-agent", "restart"); - } - - private Map<String, Object> generateTags(NodeAgentContext context) { - Map<String, String> tags = new LinkedHashMap<>(); - tags.put("namespace", "Vespa"); - tags.put("role", nodeTypeToRole(context.node().type())); - tags.put("zone", context.zone().getId().value()); - context.node().currentVespaVersion().ifPresent(version -> tags.put("vespaVersion", version.toFullString())); - - if (! isConfigserverLike(context.nodeType())) { - tags.put("state", context.node().state().toString()); - context.node().parentHostname().ifPresent(parent -> tags.put("parentHostname", parent)); - context.node().owner().ifPresent(owner -> { - tags.put("tenantName", owner.tenant()); - tags.put("app", owner.application() + "." + owner.instance()); - tags.put("applicationName", owner.application()); - tags.put("instanceName", owner.instance()); - tags.put("applicationId", owner.tenant() + "." + owner.application() + "." + owner.instance()); - }); - context.node().membership().ifPresent(membership -> { - tags.put("clustertype", membership.clusterType()); - tags.put("clusterid", membership.clusterId()); - }); - } - - return Collections.unmodifiableMap(tags); - } - - private boolean isConfigserverLike(NodeType nodeType) { - return nodeType == NodeType.config || nodeType == NodeType.controller; - } - public Optional<Long> getDiskUsageFor(NodeAgentContext context) { try { Path path = context.pathOnHostFromPathInNode("/"); 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 901a315ffb6..77c08133e82 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 @@ -399,12 +399,6 @@ public class NodeAgentImpl implements NodeAgent { currentRestartGeneration.map(current -> current < node.currentRestartGeneration().get()).orElse(false)) currentRestartGeneration = node.currentRestartGeneration(); - // 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); - } - lastNode = node; } diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/SecretAgentCheckConfig.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/SecretAgentCheckConfig.java deleted file mode 100644 index cdf67871a1a..00000000000 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/SecretAgentCheckConfig.java +++ /dev/null @@ -1,101 +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.util; - -import com.yahoo.config.provision.NodeType; -import com.yahoo.vespa.hosted.node.admin.task.util.file.FileWriter; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Helper class to generate and write the secret-agent check config files. - * - * @author freva - */ -public class SecretAgentCheckConfig { - private final String id; - private final int interval; - private final Path checkExecutable; - private final String[] arguments; - private String user = "nobody"; - private final Map<String, Object> tags = new LinkedHashMap<>(); - - public SecretAgentCheckConfig(String id, int interval, Path checkExecutable, String... arguments) { - this.id = id; - this.interval = interval; - this.checkExecutable = checkExecutable; - this.arguments = arguments; - } - - public SecretAgentCheckConfig withRunAsUser(String user) { - this.user = user; - return this; - } - - public SecretAgentCheckConfig withTag(String tagKey, Object tagValue) { - tags.put(tagKey, tagValue); - return this; - } - - public SecretAgentCheckConfig withTags(Map<String, Object> tags) { - this.tags.clear(); - this.tags.putAll(tags); - return this; - } - - public void setTags(Map<String, Object> tags) { - this.tags.clear(); - this.tags.putAll(tags); - } - - public void writeTo(Path yamasAgentDirectory) throws IOException { - Files.createDirectories(yamasAgentDirectory); - Path scheduleFilePath = yamasAgentDirectory.resolve(id + ".yaml"); - Files.write(scheduleFilePath, render().getBytes()); - } - - public FileWriter getFileWriterTo(Path destinationPath) { - return new FileWriter(destinationPath, this::render); - } - - public String render() { - StringBuilder stringBuilder = new StringBuilder() - .append("- id: ").append(id).append("\n") - .append(" interval: ").append(interval).append("\n") - .append(" user: ").append(user).append("\n") - .append(" check: ").append(checkExecutable.toFile()).append("\n"); - - if (arguments.length > 0) { - stringBuilder.append(" args:\n"); - for (String arg : arguments) { - stringBuilder.append(" - ").append(arg).append("\n"); - } - } - - if (!tags.isEmpty()) { - stringBuilder.append(" tags:\n"); - tags.forEach((key, value) -> - stringBuilder.append(" ").append(key).append(": ").append(value).append("\n")); - } - - return stringBuilder.toString(); - } - - // TODO: Change role dimension to nodeType? - public static String nodeTypeToRole(NodeType nodeType) { - switch (nodeType) { - case tenant: return "tenants"; - case host: return "docker"; - case proxy: return "routing"; - case proxyhost: return "routinghost"; - case config: return "configserver"; - case confighost: return "configserverhost"; - case controller: return "controller"; - case controllerhost: return "controllerhost"; - default: throw new IllegalArgumentException("Unknown node type " + nodeType); - } - } -} diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/package-info.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/package-info.java deleted file mode 100644 index 56cb135e723..00000000000 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.node.admin.util; - -import com.yahoo.osgi.annotation.ExportPackage; 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 57b18606def..d034d3c1cd0 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 @@ -2,21 +2,9 @@ package com.yahoo.vespa.hosted.node.admin.maintenance; import com.google.common.collect.ImmutableSet; -import com.yahoo.component.Version; -import com.yahoo.config.provision.Environment; -import com.yahoo.config.provision.NodeType; -import com.yahoo.config.provision.RegionName; -import com.yahoo.config.provision.zone.ZoneApi; -import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeMembership; -import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeOwner; -import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec; -import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeState; -import com.yahoo.vespa.hosted.node.admin.docker.DockerOperations; import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext; import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContextImpl; import com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder; -import com.yahoo.vespa.hosted.node.admin.task.util.file.UnixPath; import com.yahoo.vespa.hosted.node.admin.task.util.process.TestTerminal; import com.yahoo.vespa.test.file.TestFileSystem; import org.junit.After; @@ -35,162 +23,15 @@ import java.util.List; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; -import static com.yahoo.yolean.Exceptions.uncheck; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * @author dybis */ @RunWith(Enclosed.class) public class StorageMaintainerTest { - private static final DockerOperations docker = mock(DockerOperations.class); - - public static class SecretAgentCheckTests { - private final StorageMaintainer storageMaintainer = new StorageMaintainer(null, docker, null, null); - - @Test - public void tenant() { - Path path = executeAs(NodeType.tenant); - - assertChecks(path, "athenz-certificate-expiry", "host-life", - "system-coredumps-processing", "vespa", "vespa-health"); - - // All dimensions for vespa metrics should be set by metricsproxy - assertCheckEnds(path.resolve("vespa.yaml"), - " args:\n" + - " - all\n"); - - // For non vespa metrics, we need to set all the dimensions ourselves - assertCheckEnds(path.resolve("host-life.yaml"), - "tags:\n" + - " namespace: Vespa\n" + - " role: tenants\n" + - " zone: prod.us-north-1\n" + - " vespaVersion: 6.305.12\n" + - " state: active\n" + - " parentHostname: host123.test.domain.tld\n" + - " tenantName: tenant\n" + - " app: application.instance\n" + - " applicationName: application\n" + - " instanceName: instance\n" + - " applicationId: tenant.application.instance\n" + - " clustertype: clusterType\n" + - " clusterid: clusterId\n"); - } - - @Test - public void proxy() { - Path path = executeAs(NodeType.proxy); - - assertChecks(path, "athenz-certificate-expiry", "host-life", "routing-configage", - "ssl-status", "system-coredumps-processing", "vespa", "vespa-health"); - - // All dimensions for vespa metrics should be set by the source - assertCheckEnds(path.resolve("vespa.yaml"), - " args:\n" + - " - all\n"); - - // For non vespa metrics, we need to set all the dimensions ourselves - assertCheckEnds(path.resolve("host-life.yaml"), - "tags:\n" + - " namespace: Vespa\n" + - " role: routing\n" + - " zone: prod.us-north-1\n" + - " vespaVersion: 6.305.12\n" + - " state: active\n" + - " parentHostname: host123.test.domain.tld\n" + - " tenantName: tenant\n" + - " app: application.instance\n" + - " applicationName: application\n" + - " instanceName: instance\n" + - " applicationId: tenant.application.instance\n" + - " clustertype: clusterType\n" + - " clusterid: clusterId\n"); - } - - @Test - public void configserver() { - Path path = executeAs(NodeType.config); - - assertChecks(path, "athenz-certificate-expiry", "configserver", "configserver-logd", "host-life", - "system-coredumps-processing", "zkbackupage"); - - assertCheckEnds(path.resolve("configserver.yaml"), - " tags:\n" + - " namespace: Vespa\n" + - " role: configserver\n" + - " zone: prod.us-north-1\n" + - " vespaVersion: 6.305.12\n"); - } - - @Test - public void controller() { - Path path = executeAs(NodeType.controller); - - assertChecks(path, "athenz-certificate-expiry", "controller", "controller-logd", "host-life", - "system-coredumps-processing", "vespa", "vespa-health", "zkbackupage"); - - - // Do not set namespace for vespa metrics. WHY? - assertCheckEnds(path.resolve("vespa.yaml"), - " tags:\n" + - " role: controller\n" + - " zone: prod.us-north-1\n" + - " vespaVersion: 6.305.12\n"); - - assertCheckEnds(path.resolve("controller.yaml"), - " tags:\n" + - " namespace: Vespa\n" + - " role: controller\n" + - " zone: prod.us-north-1\n" + - " vespaVersion: 6.305.12\n"); - } - - private Path executeAs(NodeType nodeType) { - ZoneApi zone = mock(ZoneApi.class); - when(zone.getId()).thenReturn(ZoneId.from(Environment.prod, RegionName.from("us-north-1"))); - - NodeSpec nodeSpec = new NodeSpec.Builder() - .hostname("host123-5.test.domain.tld") - .type(nodeType) - .state(NodeState.active) - .parentHostname("host123.test.domain.tld") - .owner(new NodeOwner("tenant", "application", "instance")) - .membership(new NodeMembership("clusterType", "clusterId", null, 0, false)) - .currentVespaVersion(Version.fromString("6.305.12")) - .flavor("d-2-8-50") - .canonicalFlavor("d-2-8-50") - .build(); - NodeAgentContext context = new NodeAgentContextImpl.Builder(nodeSpec) - .fileSystem(TestFileSystem.create()) - .zone(zone) - .build(); - Path path = context.pathOnHostFromPathInNode("/etc/yamas-agent"); - uncheck(() -> Files.createDirectories(path)); - storageMaintainer.writeMetricsConfig(context); - return path; - } - - private void assertCheckEnds(Path checkPath, String contentsEnd) { - String contents = new UnixPath(checkPath).readUtf8File(); - assertTrue(contents, contents.endsWith(contentsEnd)); - } - - private void assertChecks(Path checksPath, String... checkNames) { - List<String> expectedChecks = Stream.of(checkNames).sorted().collect(Collectors.toList()); - List<String> actualChecks = FileFinder.files(checksPath).stream() - .map(FileFinder.FileAttributes::filename) - .map(filename -> filename.replaceAll("\\.yaml$", "")) - .sorted() - .collect(Collectors.toList()); - assertEquals(expectedChecks, actualChecks); - } - } public static class DiskUsageTests { @@ -198,7 +39,7 @@ public class StorageMaintainerTest { @Test public void testDiskUsed() throws IOException { - StorageMaintainer storageMaintainer = new StorageMaintainer(terminal, docker, null, null); + StorageMaintainer storageMaintainer = new StorageMaintainer(terminal, null, null); FileSystem fileSystem = TestFileSystem.create(); NodeAgentContext context = new NodeAgentContextImpl.Builder("host-1.domain.tld").fileSystem(fileSystem).build(); Files.createDirectories(context.pathOnHostFromPathInNode("/")); @@ -212,7 +53,7 @@ public class StorageMaintainerTest { @Test public void testNonExistingDiskUsed() { - StorageMaintainer storageMaintainer = new StorageMaintainer(terminal, docker, null, null); + StorageMaintainer storageMaintainer = new StorageMaintainer(terminal, null, null); long usedBytes = storageMaintainer.getDiskUsedInBytes(null, Paths.get("/fake/path")); assertEquals(0L, usedBytes); } @@ -244,7 +85,7 @@ public class StorageMaintainerTest { // Archive container-1 - StorageMaintainer storageMaintainer = new StorageMaintainer(null, docker, null, pathToArchiveDir); + StorageMaintainer storageMaintainer = new StorageMaintainer(null, null, pathToArchiveDir); storageMaintainer.archiveNodeStorage(context1); // container-1 should be gone from container-storage 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 f56669427ce..c0b032bc4d4 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 @@ -30,7 +30,6 @@ import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; @@ -659,8 +658,6 @@ public class NodeAgentImplTest { private NodeAgentImpl makeNodeAgent(DockerImage dockerImage, boolean isRunning) { mockGetContainer(dockerImage, isRunning); - doNothing().when(storageMaintainer).writeMetricsConfig(any()); - return new NodeAgentImpl(contextSupplier, nodeRepository, orchestrator, dockerOperations, storageMaintainer, flagSource, Optional.of(credentialsMaintainer), Optional.of(aclMaintainer), Optional.of(healthChecker)); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/SecretAgentCheckConfigTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/SecretAgentCheckConfigTest.java deleted file mode 100644 index 30263403757..00000000000 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/SecretAgentCheckConfigTest.java +++ /dev/null @@ -1,88 +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.util; - -import com.yahoo.config.provision.NodeType; -import org.junit.Test; - -import java.nio.file.Paths; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * @author freva - */ -public class SecretAgentCheckConfigTest { - - @Test - public void generateFullSecretAgentScheduleTest() { - SecretAgentCheckConfig scheduleMaker = new SecretAgentCheckConfig("system-checks", 60, - Paths.get("/some/test"), "arg1", "arg2 with space") - .withTag("tenantName", "vespa") - .withTag("applicationName", "canary-docker") - .withTag("instanceName", "default") - .withTag("applicationId", "vespa.canary-docker.default") - .withTag("app", "canary-docker.default") - .withTag("clustertype", "container") - .withTag("clusterid", "canary") - .withTag("vespaVersion", "6.13.37") - .withTag("role", "tenants") - .withTag("flavor", "docker") - .withTag("state", "active") - .withTag("zone", "test.us-west-5"); - - assertEquals( - "- id: system-checks\n" + - " interval: 60\n" + - " user: nobody\n" + - " check: /some/test\n" + - " args:\n" + - " - arg1\n" + - " - arg2 with space\n" + - " tags:\n" + - " tenantName: vespa\n" + - " applicationName: canary-docker\n" + - " instanceName: default\n" + - " applicationId: vespa.canary-docker.default\n" + - " app: canary-docker.default\n" + - " clustertype: container\n" + - " clusterid: canary\n" + - " vespaVersion: 6.13.37\n" + - " role: tenants\n" + - " flavor: docker\n" + - " state: active\n" + - " zone: test.us-west-5\n", scheduleMaker.render()); - } - - @Test - public void generateMinimalSecretAgentScheduleTest() { - SecretAgentCheckConfig scheduleMaker = new SecretAgentCheckConfig("system-checks", 60, - Paths.get("/some/test")); - - assertEquals( - "- id: system-checks\n" + - " interval: 60\n" + - " user: nobody\n" + - " check: /some/test\n", scheduleMaker.render()); - } - - @Test - public void generateSecretAgentScheduleWithDifferentUserTest() { - SecretAgentCheckConfig scheduleMaker = new SecretAgentCheckConfig("system-checks", 60, - Paths.get("/some/test")).withRunAsUser("barfoo"); - - assertEquals( - "- id: system-checks\n" + - " interval: 60\n" + - " user: barfoo\n" + - " check: /some/test\n", scheduleMaker.render()); - } - - @Test - public void supportsAllNodeTypes() { - for (NodeType nodeType : NodeType.values()) { - assertNotNull(SecretAgentCheckConfig.nodeTypeToRole(nodeType)); - } - } - -} |