summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2019-04-30 09:15:25 +0200
committerMartin Polden <mpolden@mpolden.no>2019-04-30 09:15:25 +0200
commit141f7976be4cc43cce142e95bd32a3478d31f341 (patch)
treee9d0e5090cc3e3684f770bb7826c17db74556398
parent8850e4fcfa0ca5a7ea586d57cdf57cf0c3b17419 (diff)
Report metric for queued name service requests
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java7
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java10
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java23
3 files changed, 39 insertions, 1 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java
index 037e7d8ced6..449b8c51acd 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java
@@ -43,6 +43,7 @@ public class MetricsReporter extends Maintainer {
public static final String DEPLOYMENT_BUILD_AGE_SECONDS = "deployment.buildAgeSeconds";
public static final String DEPLOYMENT_WARNINGS = "deployment.warnings";
public static final String REMAINING_ROTATIONS = "remaining_rotations";
+ public static final String NAME_SERVICE_REQUESTS_QUEUED = "dns.queuedRequests";
private final Metric metric;
private final Chef chefClient;
@@ -68,6 +69,7 @@ public class MetricsReporter extends Maintainer {
reportChefMetrics();
reportDeploymentMetrics();
reportRemainingRotations();
+ reportQueuedNameServiceRequests();
}
private void reportRemainingRotations() {
@@ -146,6 +148,11 @@ public class MetricsReporter extends Maintainer {
controller().clock().instant().getEpochSecond() - buildTime.getEpochSecond(),
metric.createContext(dimensions(application.id()))));
}
+
+ private void reportQueuedNameServiceRequests() {
+ metric.set(NAME_SERVICE_REQUESTS_QUEUED, controller().curator().readNameServiceQueue().requests().size(),
+ metric.createContext(Map.of()));
+ }
private static double deploymentFailRatio(ApplicationList applicationList) {
List<Application> applications = applicationList.asList();
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
index 1594c3c3613..b6c7e369f07 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
@@ -53,13 +53,19 @@ public class DeploymentTester {
private final OutstandingChangeDeployer outstandingChangeDeployer;
private final ReadyJobsTrigger readyJobTrigger;
private final NameServiceDispatcher nameServiceDispatcher;
+ private final boolean updateDnsAutomatically;
public DeploymentTester() {
this(new ControllerTester());
}
public DeploymentTester(ControllerTester tester) {
+ this(tester, true);
+ }
+
+ public DeploymentTester(ControllerTester tester, boolean updateDnsAutomatically) {
this.tester = tester;
+ this.updateDnsAutomatically = updateDnsAutomatically;
tester.curator().writeUpgradesPerMinute(100);
JobControl jobControl = new JobControl(tester.curator());
@@ -218,7 +224,9 @@ public class DeploymentTester {
} else {
assertFalse(applications().require(application.id()).change().hasTargets());
}
- updateDns();
+ if (updateDnsAutomatically) {
+ updateDns();
+ }
}
public void completeUpgrade(Application application, Version version, String upgradePolicy) {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java
index 7a54936191a..b18c39f4042 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java
@@ -237,6 +237,29 @@ public class MetricsReporterTest {
getMetric(MetricsReporter.DEPLOYMENT_BUILD_AGE_SECONDS, tester.app()));
}
+ @Test
+ public void test_name_service_queue_size_metric() {
+ DeploymentTester tester = new DeploymentTester(new ControllerTester(), false);
+ ApplicationPackage applicationPackage = new ApplicationPackageBuilder()
+ .environment(Environment.prod)
+ .globalServiceId("default")
+ .region("us-west-1")
+ .region("us-east-3")
+ .build();
+ MetricsReporter reporter = createReporter(tester.controller(), metrics, SystemName.main);
+ Application application = tester.createApplication("app1", "tenant1", 1, 11L);
+ reporter.maintain();
+ assertEquals("Queue is empty initially", 0, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue());
+
+ tester.deployCompletely(application, applicationPackage);
+ reporter.maintain();
+ assertEquals("Deployment queues name services requests", 6, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue());
+
+ tester.updateDns();
+ reporter.maintain();
+ assertEquals("Queue consumed", 0, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue());
+ }
+
private Duration getAverageDeploymentDuration(Application application) {
return Duration.ofSeconds(getMetric(MetricsReporter.DEPLOYMENT_AVERAGE_DURATION, application).longValue());
}