aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorolaaun <olaa@oath.com>2018-11-05 09:56:15 +0100
committerGitHub <noreply@github.com>2018-11-05 09:56:15 +0100
commitec877477bcb0e74e94d3fe864500db07f453baab (patch)
treed56afa177c8b6bfba676b818d241344f7b27d5ff /controller-server
parentf66014d9353f80abfd806f85182174b881be4fcb (diff)
olaa/revert maintainers (#7562)
* Revert "Whitelist APIs. Check if request succeeded (#7552)" This reverts commit 5982fb109a559f57eb8609d18360f6ded9a98760. * Revert maintainers feeding to Controller APIs
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java53
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainer.java121
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java6
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java110
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java10
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainerTest.java35
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainerTest.java37
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java166
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java2
9 files changed, 157 insertions, 383 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java
index 44f29eb6113..ac080fe15d7 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java
@@ -3,26 +3,17 @@ package com.yahoo.vespa.hosted.controller.maintenance;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ClusterSpec;
-import com.yahoo.slime.Cursor;
-import com.yahoo.slime.Slime;
-import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.api.integration.MetricsService;
+import com.yahoo.vespa.hosted.controller.application.ApplicationList;
import com.yahoo.vespa.hosted.controller.application.ClusterUtilization;
import com.yahoo.vespa.hosted.controller.application.Deployment;
-import com.yahoo.vespa.hosted.controller.authority.config.ApiAuthorityConfig;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
import java.time.Duration;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
/**
* Fetch utilization metrics and update applications with this data.
@@ -32,12 +23,10 @@ import java.util.logging.Level;
public class ClusterUtilizationMaintainer extends Maintainer {
private final Controller controller;
- private final List<String> baseUris;
- public ClusterUtilizationMaintainer(Controller controller, Duration duration, JobControl jobControl, ApiAuthorityConfig apiAuthorityConfig) {
+ public ClusterUtilizationMaintainer(Controller controller, Duration duration, JobControl jobControl) {
super(controller, duration, jobControl);
this.controller = controller;
- this.baseUris = apiAuthorityConfig.authorities();
}
private Map<ClusterSpec.Id, ClusterUtilization> getUpdatedClusterUtilizations(ApplicationId app, ZoneId zone) {
@@ -55,45 +44,15 @@ public class ClusterUtilizationMaintainer extends Maintainer {
@Override
protected void maintain() {
- try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
- String uri = baseUris.get(0) + "metricforwarding/v1/clusterutilization"; // For now, we only feed to one controller
- Slime slime = getMetricSlime();
- ByteArrayEntity entity = new ByteArrayEntity(SlimeUtils.toJsonBytes(slime));
- HttpPost httpPost = new HttpPost(uri);
- httpPost.setEntity(entity);
- httpClient.execute(httpPost);
- } catch (Exception e) {
- log.log(Level.WARNING, "Failed to update cluster utilization metrics", e);
- }
-
- }
-
- private Slime getMetricSlime() {
- Slime slime = new Slime();
- Cursor cursor = slime.setArray();
for (Application application : controller().applications().asList()) {
- Cursor applicationCursor = cursor.addObject();
- applicationCursor.setString("applicationId", application.id().serializedForm());
- Cursor deploymentArray = applicationCursor.setArray("deployments");
for (Deployment deployment : application.deployments().values()) {
- Cursor deploymentEntry = deploymentArray.addObject();
- deploymentEntry.setString("zoneId", deployment.zone().value());
- Cursor clusterArray = deploymentEntry.setArray("clusterUtil");
+
Map<ClusterSpec.Id, ClusterUtilization> clusterUtilization = getUpdatedClusterUtilizations(application.id(), deployment.zone());
- fillClusterUtilization(clusterArray, clusterUtilization);
+
+ controller().applications().lockIfPresent(application.id(), lockedApplication ->
+ controller().applications().store(lockedApplication.withClusterUtilization(deployment.zone(), clusterUtilization)));
}
}
- return slime;
}
- private void fillClusterUtilization(Cursor cursor, Map<ClusterSpec.Id, ClusterUtilization> clusterUtilization) {
- for (Map.Entry<ClusterSpec.Id, ClusterUtilization> entry : clusterUtilization.entrySet()) {
- Cursor clusterUtilCursor = cursor.addObject();
- clusterUtilCursor.setString("clusterSpecId", entry.getKey().value());
- clusterUtilCursor.setDouble("cpu", entry.getValue().getCpu());
- clusterUtilCursor.setDouble("memory", entry.getValue().getMemory());
- clusterUtilCursor.setDouble("disk", entry.getValue().getDisk());
- clusterUtilCursor.setDouble("diskBusy", entry.getValue().getDiskBusy());
- }
- }
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainer.java
index 3cf3c47a6f3..bf5743e2d3c 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainer.java
@@ -1,31 +1,17 @@
// 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.controller.maintenance;
-import com.yahoo.vespa.hosted.controller.authority.config.ApiAuthorityConfig;
import com.yahoo.config.provision.SystemName;
import com.yahoo.log.LogLevel;
-import com.yahoo.slime.ArrayTraverser;
-import com.yahoo.slime.Cursor;
-import com.yahoo.slime.Inspector;
-import com.yahoo.slime.Slime;
-import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.controller.Controller;
-import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId;
import com.yahoo.vespa.hosted.controller.api.integration.organization.Organization;
import com.yahoo.vespa.hosted.controller.api.integration.organization.User;
+import com.yahoo.vespa.hosted.controller.tenant.AthenzTenant;
import com.yahoo.vespa.hosted.controller.tenant.Contact;
+import com.yahoo.vespa.hosted.controller.tenant.Tenant;
import com.yahoo.yolean.Exceptions;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
-import java.io.IOException;
import java.time.Duration;
-import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
@@ -43,107 +29,44 @@ public class ContactInformationMaintainer extends Maintainer {
private static final Logger log = Logger.getLogger(ContactInformationMaintainer.class.getName());
private final Organization organization;
- private final List<String> baseUris;
- private CloseableHttpClient httpClient = HttpClientBuilder.create().build();
- public ContactInformationMaintainer(Controller controller, Duration interval, JobControl jobControl, Organization organization, ApiAuthorityConfig apiAuthorityConfig) {
+ public ContactInformationMaintainer(Controller controller, Duration interval, JobControl jobControl, Organization organization) {
super(controller, interval, jobControl, null, EnumSet.of(SystemName.cd, SystemName.main));
this.organization = Objects.requireNonNull(organization, "organization must be non-null");
- this.baseUris = apiAuthorityConfig.authorities();
}
- // The maintainer will eventually feed contact info to systems other than its own, determined by the baseUris list.
@Override
protected void maintain() {
- for (String baseUri : baseUris) {
- for (String tenantName : getTenantList(baseUri)) {
- Optional<PropertyId> tenantPropertyId = getPropertyId(tenantName, baseUri);
- if (!tenantPropertyId.isPresent())
- continue;
- findContact(tenantPropertyId.get()).ifPresent(contact -> {
- feedContact(tenantName, contact, baseUri);
+ for (Tenant t : controller().tenants().asList()) {
+ if (!(t instanceof AthenzTenant)) continue; // No contact information for non-Athenz tenants
+ AthenzTenant tenant = (AthenzTenant) t;
+ if (!tenant.propertyId().isPresent()) continue; // Can only update contact information if property ID is known
+ try {
+ findContact(tenant).ifPresent(contact -> {
+ controller().tenants().lockIfPresent(t.name(), lockedTenant -> controller().tenants().store(lockedTenant.with(contact)));
});
+ } catch (Exception e) {
+ log.log(LogLevel.WARNING, "Failed to update contact information for " + tenant + ": " +
+ Exceptions.toMessageString(e) + ". Retrying in " +
+ maintenanceInterval());
}
}
}
- private void feedContact(String tenantName, Contact contact, String baseUri) {
- try {
- CloseableHttpClient httpClient = HttpClientBuilder.create().build();
- String uri = baseUri + "contactinfo/v1/tenant/" + tenantName;
- HttpPost httpPost = new HttpPost(uri);
- httpPost.setEntity(contactToByteArrayEntity(contact));
- httpClient.execute(httpPost);
- } catch (Exception e) {
- log.log(LogLevel.WARNING, "Failed to update contact information for " + tenantName + ": " +
- Exceptions.toMessageString(e) + ". Retrying in " +
- maintenanceInterval());
- }
- }
-
- private ByteArrayEntity contactToByteArrayEntity(Contact contact) throws IOException {
- Slime slime = new Slime();
- Cursor cursor = slime.setObject();
- cursor.setString("url", contact.url().toString());
- cursor.setString("issueTrackerUrl", contact.issueTrackerUrl().toString());
- cursor.setString("propertyUrl", contact.propertyUrl().toString());
- Cursor personsCursor = cursor.setArray("persons");
- for (List<String> personList : contact.persons()) {
- Cursor sublist = personsCursor.addArray();
- for(String person : personList) {
- sublist.addString(person);
- }
- }
- return new ByteArrayEntity(SlimeUtils.toJsonBytes(slime));
- }
-
- private List<String> getTenantList(String baseUri) {
- List<String> tenantList = new ArrayList<>();
- HttpGet getRequest = new HttpGet(baseUri + "application/v4/tenant/");
- try {
- HttpResponse response = httpClient.execute(getRequest);
- Slime slime = SlimeUtils.jsonToSlime(EntityUtils.toByteArray(response.getEntity()));
- Inspector inspector = slime.get();
- inspector.traverse((ArrayTraverser) (index, tenant) -> {
- tenantList.add(tenant.field("tenant").asString());
- });
- } catch (IOException e) {
- log.log(LogLevel.WARNING, "Failed to get tenant list from base URI: " + baseUri.toString() +
- Exceptions.toMessageString(e) + ". Retrying in " +
- maintenanceInterval());
- }
- return tenantList;
- }
-
- private Optional<PropertyId> getPropertyId(String tenantName, String baseUri) {
- Optional<PropertyId> propertyId = Optional.empty();
- HttpGet getRequest = new HttpGet(baseUri + "application/v4/tenant/" + tenantName);
- try {
- HttpResponse response = httpClient.execute(getRequest);
- Slime slime = SlimeUtils.jsonToSlime(EntityUtils.toByteArray(response.getEntity()));
- Inspector inspector = slime.get();
- if (!inspector.field("propertyId").valid()) {
- log.log(LogLevel.WARNING, "Unable to get property id for " + tenantName);
- return Optional.empty();
- }
- propertyId = Optional.of(new PropertyId(inspector.field("propertyId").asString()));
- } catch (IOException e) {
- log.log(LogLevel.WARNING, "Unable to get property idfor " + tenantName, e);
- }
- return propertyId;
- }
-
/** Find contact information for given tenant */
- private Optional<Contact> findContact(PropertyId propertyId) {
- List<List<String>> persons = organization.contactsFor(propertyId)
+ private Optional<Contact> findContact(AthenzTenant tenant) {
+ if (!tenant.propertyId().isPresent()) {
+ return Optional.empty();
+ }
+ List<List<String>> persons = organization.contactsFor(tenant.propertyId().get())
.stream()
.map(personList -> personList.stream()
.map(User::displayName)
.collect(Collectors.toList()))
.collect(Collectors.toList());
- return Optional.of(new Contact(organization.contactsUri(propertyId),
- organization.propertyUri(propertyId),
- organization.issueCreationUri(propertyId),
+ return Optional.of(new Contact(organization.contactsUri(tenant.propertyId().get()),
+ organization.propertyUri(tenant.propertyId().get()),
+ organization.issueCreationUri(tenant.propertyId().get()),
persons));
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
index b2968270af9..7b17f38bd78 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
@@ -65,15 +65,15 @@ public class ControllerMaintenance extends AbstractComponent {
upgrader = new Upgrader(controller, maintenanceInterval, jobControl, curator);
readyJobsTrigger = new ReadyJobsTrigger(controller, Duration.ofMinutes(1), jobControl);
clusterInfoMaintainer = new ClusterInfoMaintainer(controller, Duration.ofHours(2), jobControl, nodeRepositoryClient);
- clusterUtilizationMaintainer = new ClusterUtilizationMaintainer(controller, Duration.ofHours(2), jobControl, apiAuthorityConfig);
- deploymentMetricsMaintainer = new DeploymentMetricsMaintainer(controller, Duration.ofMinutes(10), jobControl, apiAuthorityConfig);
+ clusterUtilizationMaintainer = new ClusterUtilizationMaintainer(controller, Duration.ofHours(2), jobControl);
+ deploymentMetricsMaintainer = new DeploymentMetricsMaintainer(controller, Duration.ofMinutes(10), jobControl);
applicationOwnershipConfirmer = new ApplicationOwnershipConfirmer(controller, Duration.ofHours(12), jobControl, ownershipIssues);
dnsMaintainer = new DnsMaintainer(controller, Duration.ofHours(12), jobControl, nameService);
systemUpgrader = new SystemUpgrader(controller, Duration.ofMinutes(1), jobControl);
jobRunner = new JobRunner(controller, Duration.ofMinutes(2), jobControl);
osUpgraders = osUpgraders(controller, jobControl);
osVersionStatusUpdater = new OsVersionStatusUpdater(controller, maintenanceInterval, jobControl);
- contactInformationMaintainer = new ContactInformationMaintainer(controller, Duration.ofHours(12), jobControl, organization, apiAuthorityConfig);
+ contactInformationMaintainer = new ContactInformationMaintainer(controller, Duration.ofHours(12), jobControl, organization);
}
public Upgrader upgrader() { return upgrader; }
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java
index 22d738ff98c..c17d070e92e 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java
@@ -2,27 +2,18 @@
package com.yahoo.vespa.hosted.controller.maintenance;
import com.yahoo.config.provision.HostName;
-import com.yahoo.slime.Cursor;
-import com.yahoo.slime.Slime;
-import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.ApplicationController;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.api.integration.MetricsService;
-import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
+import com.yahoo.vespa.hosted.controller.application.ApplicationList;
import com.yahoo.vespa.hosted.controller.application.Deployment;
+import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics;
import com.yahoo.vespa.hosted.controller.application.RotationStatus;
-import com.yahoo.vespa.hosted.controller.authority.config.ApiAuthorityConfig;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
+import com.yahoo.yolean.Exceptions;
-import java.io.IOException;
import java.time.Duration;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -47,12 +38,10 @@ public class DeploymentMetricsMaintainer extends Maintainer {
private static final int applicationsToUpdateInParallel = 10;
private final ApplicationController applications;
- private final List<String> baseUris;
- public DeploymentMetricsMaintainer(Controller controller, Duration duration, JobControl jobControl, ApiAuthorityConfig apiAuthorityConfig) {
+ public DeploymentMetricsMaintainer(Controller controller, Duration duration, JobControl jobControl) {
super(controller, duration, jobControl);
this.applications = controller.applications();
- baseUris = apiAuthorityConfig.authorities();
}
@Override
@@ -63,27 +52,27 @@ public class DeploymentMetricsMaintainer extends Maintainer {
// Run parallel stream inside a custom ForkJoinPool so that we can control the number of threads used
ForkJoinPool pool = new ForkJoinPool(applicationsToUpdateInParallel);
- Slime slime = new Slime();
- Cursor cursor = slime.setArray();
pool.submit(() -> {
applicationList.parallelStream().forEach(application -> {
try {
- MetricsService.ApplicationMetrics applicationMetrics = controller().metricsService()
- .getApplicationMetrics(application.id());
- Map<HostName, RotationStatus> rotationStatus = getRotationStatus(application);
- Map<ZoneId, MetricsService.DeploymentMetrics> deploymentMetrics = getDeploymentMetrics(application);
-
-
- Cursor applicationCursor = cursor.addObject();
- applicationCursor.setString("applicationId", application.id().serializedForm());
- Cursor applicationMetricsCursor = applicationCursor.setObject("applicationMetrics");
- fillApplicationMetrics(applicationMetricsCursor, applicationMetrics);
- Cursor rotationStatusCursor = applicationCursor.setArray("rotationStatus");
- fillRotationStatus(rotationStatusCursor, rotationStatus);
- Cursor deploymentArray = applicationCursor.setArray("deploymentMetrics");
- for (Map.Entry<ZoneId, MetricsService.DeploymentMetrics> entry : deploymentMetrics.entrySet()) {
- Cursor deploymentEntry = deploymentArray.addObject();
- fillDeploymentMetrics(deploymentEntry, entry.getKey().value(), entry.getValue());
+ applications.lockIfPresent(application.id(), locked ->
+ applications.store(locked.with(controller().metricsService().getApplicationMetrics(application.id()))));
+
+ applications.lockIfPresent(application.id(), locked ->
+ applications.store(locked.withRotationStatus(rotationStatus(application))));
+
+ for (Deployment deployment : application.deployments().values()) {
+ MetricsService.DeploymentMetrics deploymentMetrics = controller().metricsService()
+ .getDeploymentMetrics(application.id(), deployment.zone());
+ DeploymentMetrics newMetrics = new DeploymentMetrics(deploymentMetrics.queriesPerSecond(),
+ deploymentMetrics.writesPerSecond(),
+ deploymentMetrics.documentCount(),
+ deploymentMetrics.queryLatencyMillis(),
+ deploymentMetrics.writeLatencyMillis());
+
+ applications.lockIfPresent(application.id(), locked ->
+ applications.store(locked.with(deployment.zone(), newMetrics)
+ .recordActivityAt(controller().clock().instant(), deployment.zone())));
}
} catch (Exception e) {
failures.incrementAndGet();
@@ -91,26 +80,23 @@ public class DeploymentMetricsMaintainer extends Maintainer {
}
});
});
-
pool.shutdown();
try {
pool.awaitTermination(30, TimeUnit.MINUTES);
- feedMetrics(slime);
if (lastException.get() != null) {
- log.log(Level.WARNING, String.format("Failed to query metrics service for %d/%d applications. Retrying in %s. Stacktrace of last error: ",
+ log.log(Level.WARNING, String.format("Failed to query metrics service for %d/%d applications. Last error: %s. Retrying in %s",
failures.get(),
applicationList.size(),
- maintenanceInterval()),lastException.get());
+ Exceptions.toMessageString(lastException.get()),
+ maintenanceInterval()));
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
- } catch (IOException e) {
- log.log(Level.WARNING, "Unable to feed metrics to API", e);
}
}
/** Get global rotation status for application */
- private Map<HostName, RotationStatus> getRotationStatus(Application application) {
+ private Map<HostName, RotationStatus> rotationStatus(Application application) {
return applications.rotationRepository().getRotation(application)
.map(rotation -> controller().metricsService().getRotationStatus(rotation.name()))
.map(rotationStatus -> {
@@ -121,50 +107,6 @@ public class DeploymentMetricsMaintainer extends Maintainer {
.orElseGet(Collections::emptyMap);
}
- private Map<ZoneId, MetricsService.DeploymentMetrics> getDeploymentMetrics(Application application) {
- Map<ZoneId, MetricsService.DeploymentMetrics> deploymentMetrics = new HashMap<>();
- for (Deployment deployment : application.deployments().values()) {
- ZoneId zone = deployment.zone();
- MetricsService.DeploymentMetrics zoneDeploymentMetrics = controller().metricsService()
- .getDeploymentMetrics(application.id(), zone);
- deploymentMetrics.put(zone, zoneDeploymentMetrics);
- }
- return deploymentMetrics;
- }
-
- private void fillApplicationMetrics(Cursor applicationCursor, MetricsService.ApplicationMetrics applicationMetrics) {
- applicationCursor.setDouble("queryServiceQuality", applicationMetrics.queryServiceQuality());
- applicationCursor.setDouble("writeServiceQuality", applicationMetrics.writeServiceQuality());
- }
-
- private void fillRotationStatus(Cursor rotationStatusCursor, Map<HostName, RotationStatus> rotationStatus) {
- for (Map.Entry<HostName, RotationStatus> entry : rotationStatus.entrySet()) {
- Cursor rotationStatusEntry = rotationStatusCursor.addObject();
- rotationStatusEntry.setString("hostname", entry.getKey().value());
- rotationStatusEntry.setString("rotationStatus", entry.getValue().toString());
- }
- }
-
- private void fillDeploymentMetrics(Cursor deploymentCursor, String zone, MetricsService.DeploymentMetrics deploymentMetrics) {
- deploymentCursor.setString("zoneId", zone);
- deploymentCursor.setDouble("queriesPerSecond", deploymentMetrics.queriesPerSecond());
- deploymentCursor.setDouble("writesPerSecond", deploymentMetrics.writesPerSecond());
- deploymentCursor.setDouble("documentCount", deploymentMetrics.documentCount());
- deploymentCursor.setDouble("queryLatencyMillis", deploymentMetrics.queryLatencyMillis());
- deploymentCursor.setDouble("writeLatencyMillis", deploymentMetrics.writeLatencyMillis());
- }
-
- private void feedMetrics(Slime slime) throws IOException {
- String uri = baseUris.get(0) + "/metricforwarding/v1/deploymentmetrics"; // For now, we only feed to one controller
- CloseableHttpClient httpClient = HttpClientBuilder.create().build();
- HttpPost httpPost = new HttpPost(uri);
- httpPost.setEntity(new ByteArrayEntity(SlimeUtils.toJsonBytes(slime)));
- HttpResponse response = httpClient.execute(httpPost);
- if (response.getStatusLine().getStatusCode() != 200) {
- log.log(Level.WARNING, "Could not feed metrics. Reason: " + response.getStatusLine().getReasonPhrase());
- }
- }
-
private static RotationStatus from(com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus status) {
switch (status) {
case IN: return RotationStatus.in;
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java
index ccd943e7f0a..b1e3f8799d6 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java
@@ -81,10 +81,10 @@ public class ControllerAuthorizationFilter extends CorsRequestFilterBase {
@Override
public Optional<ErrorResponse> filterRequest(DiscFilterRequest request) {
Method method = getMethod(request);
- Path path = new Path(request.getRequestURI());
- if (isWhiteListed(method, path)) return Optional.empty();
+ if (isWhiteListedMethod(method)) return Optional.empty();
try {
+ Path path = new Path(request.getRequestURI());
AthenzPrincipal principal = getPrincipalOrThrow(request);
if (isWhiteListedOperation(path, method)) {
// no authz check
@@ -106,10 +106,8 @@ public class ControllerAuthorizationFilter extends CorsRequestFilterBase {
}
}
- private static boolean isWhiteListed(Method method, Path path) {
- return WHITELISTED_METHODS.contains(method) ||
- path.matches("/metricforwarding/v1/{*}") && method == POST ||
- path.matches("/contactinfo/v1/{*}") && method == POST;
+ private static boolean isWhiteListedMethod(Method method) {
+ return WHITELISTED_METHODS.contains(method);
}
private static boolean isWhiteListedOperation(Path path, Method method) {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainerTest.java
index 71d2690bb4a..66be2d09797 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainerTest.java
@@ -3,45 +3,24 @@ package com.yahoo.vespa.hosted.controller.maintenance;
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import com.github.tomakehurst.wiremock.stubbing.ServeEvent;
-import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.Environment;
import com.yahoo.vespa.hosted.controller.ControllerTester;
import com.yahoo.vespa.hosted.controller.application.Deployment;
-import com.yahoo.vespa.hosted.controller.authority.config.ApiAuthorityConfig;
import com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb;
import org.junit.Assert;
-import org.junit.Rule;
import org.junit.Test;
import java.time.Duration;
-import java.util.List;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.findAll;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.getAllServeEvents;
-import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.junit.Assert.assertEquals;
/**
* @author smorgrav
*/
public class ClusterUtilizationMaintainerTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(4443);
-
@Test
public void maintain() {
- wireMockRule.stubFor(post(urlEqualTo("/metricforwarding/v1/clusterutilization"))
- .willReturn(aResponse().withStatus(200)));
ControllerTester tester = new ControllerTester();
ApplicationId app = tester.createAndDeploy("tenant1", "domain1", "app1", Environment.dev, 123).id();
@@ -49,16 +28,12 @@ public class ClusterUtilizationMaintainerTest {
Deployment deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get();
Assert.assertEquals(0, deployment.clusterUtils().size());
- ApiAuthorityConfig.Builder apiAuthorityConfigBuilder = new ApiAuthorityConfig.Builder().authorities("http://localhost:4443/");
- ApiAuthorityConfig apiAuthorityConfig = new ApiAuthorityConfig(apiAuthorityConfigBuilder);
- ClusterUtilizationMaintainer maintainer = new ClusterUtilizationMaintainer(tester.controller(), Duration.ofHours(1), new JobControl(new MockCuratorDb()), apiAuthorityConfig);
- maintainer.maintain();
+ ClusterUtilizationMaintainer mainainer = new ClusterUtilizationMaintainer(tester.controller(), Duration.ofHours(1), new JobControl(new MockCuratorDb()));
+ mainainer.maintain();
- List<ServeEvent> allServeEvents = getAllServeEvents();
- assertEquals(allServeEvents.size(), 1);
- LoggedRequest request = findAll(postRequestedFor(urlEqualTo("/metricforwarding/v1/clusterutilization"))).get(0);
- String expectedBody = "[{\"applicationId\":\"tenant1:app1:default\",\"deployments\":[{\"zoneId\":\"dev.us-east-1\",\"clusterUtil\":[{\"clusterSpecId\":\"default\",\"cpu\":0.5554,\"memory\":0.6990000000000001,\"disk\":0.34590000000000004,\"diskBusy\":0.0}]}]}]";
- assertEquals(expectedBody, new String(request.getBody()));
+ deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get();
+ Assert.assertEquals(1, deployment.clusterUtils().size());
+ Assert.assertEquals(0.5554, deployment.clusterUtils().get(ClusterSpec.Id.from("default")).getCpu(), Double.MIN_VALUE);
}
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainerTest.java
index a46215eaf22..cbaa37b15e3 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ContactInformationMaintainerTest.java
@@ -1,17 +1,13 @@
// 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.controller.maintenance;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.hosted.controller.ControllerTester;
-import com.yahoo.vespa.hosted.controller.authority.config.ApiAuthorityConfig;
import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId;
import com.yahoo.vespa.hosted.controller.api.integration.organization.User;
import com.yahoo.vespa.hosted.controller.tenant.AthenzTenant;
import com.yahoo.vespa.hosted.controller.tenant.Contact;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import java.net.URI;
@@ -22,16 +18,9 @@ import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.findAll;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* @author mpolden
@@ -40,27 +29,13 @@ public class ContactInformationMaintainerTest {
private ControllerTester tester;
private ContactInformationMaintainer maintainer;
- private String contactInfoPath = "/contactinfo/v1/tenant/tenant1";
- private String tenantPath = "/application/v4/tenant/";
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(4443);
-
@Before
public void before() {
tester = new ControllerTester();
- ApiAuthorityConfig.Builder apiAuthorityConfigBuilder = new ApiAuthorityConfig.Builder().authorities("http://localhost:4443/");
- ApiAuthorityConfig apiAuthorityConfig = new ApiAuthorityConfig(apiAuthorityConfigBuilder);
maintainer = new ContactInformationMaintainer(tester.controller(), Duration.ofDays(1),
new JobControl(tester.controller().curator()),
- tester.organization(), apiAuthorityConfig);
- wireMockRule.stubFor(post(urlEqualTo(contactInfoPath))
- .willReturn(aResponse().withStatus(200)));
- wireMockRule.stubFor(get(urlEqualTo(tenantPath))
- .willReturn(okJson("[{\"tenant\":\"tenant1\"}]")));
- wireMockRule.stubFor(get(urlEqualTo(tenantPath + "tenant1"))
- .willReturn(okJson("{\"tenant\":\"tenant1\", \"athensDomain\":\"domain\", \"property\":\"property\", \"propertyId\":\"1\"}")));
+ tester.organization());
}
@Test
@@ -69,13 +44,13 @@ public class ContactInformationMaintainerTest {
TenantName name = tester.createTenant("tenant1", "domain1", propertyId);
Supplier<AthenzTenant> tenant = () -> tester.controller().tenants().requireAthenzTenant(name);
assertFalse("No contact information initially", tenant.get().contact().isPresent());
+
Contact contact = testContact();
registerContact(propertyId, contact);
maintainer.run();
- verify(1, postRequestedFor(urlEqualTo(contactInfoPath)));
- LoggedRequest request = findAll(postRequestedFor(urlEqualTo(contactInfoPath))).get(0);
- String expectedBody = "{\"url\":\"http://contact1.test\",\"issueTrackerUrl\":\"http://issue-tracker1.test\",\"propertyUrl\":\"http://property1.test\",\"persons\":[[\"alice\"],[\"bob\"]]}";
- assertEquals(expectedBody, new String(request.getBody()));
+
+ assertTrue("Contact information added", tenant.get().contact().isPresent());
+ assertEquals(contact, tenant.get().contact().get());
}
private void registerContact(long propertyId, Contact contact) {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java
index fc43a7f9411..e11440a372c 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java
@@ -1,38 +1,27 @@
// 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.controller.maintenance;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import com.github.tomakehurst.wiremock.stubbing.ServeEvent;
-import com.github.tomakehurst.wiremock.verification.LoggedRequest;
+import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Environment;
-import com.yahoo.slime.ArrayTraverser;
-import com.yahoo.slime.Inspector;
-import com.yahoo.slime.Slime;
-import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.controller.Application;
-import com.yahoo.vespa.hosted.controller.api.integration.MetricsService;
+import com.yahoo.vespa.hosted.controller.Controller;
+import com.yahoo.vespa.hosted.controller.ControllerTester;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
-import com.yahoo.vespa.hosted.controller.authority.config.ApiAuthorityConfig;
+import com.yahoo.vespa.hosted.controller.application.Deployment;
+import com.yahoo.vespa.hosted.controller.application.RotationStatus;
import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
import com.yahoo.vespa.hosted.controller.integration.MetricsServiceMock;
-import org.junit.Rule;
import org.junit.Test;
import java.time.Duration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.findAll;
-import static com.github.tomakehurst.wiremock.client.WireMock.getAllServeEvents;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
+import java.time.Instant;
+import java.util.function.Supplier;
+
+import static java.time.temporal.ChronoUnit.MILLIS;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
/**
* @author smorgrav
@@ -40,18 +29,69 @@ import static org.junit.Assert.assertEquals;
*/
public class DeploymentMetricsMaintainerTest {
- private static final double DELTA = 0.0000001;
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort(), true);
+ @Test
+ public void updates_metrics() {
+ ControllerTester tester = new ControllerTester();
+ ApplicationId appId = tester.createAndDeploy("tenant1", "domain1", "app1",
+ Environment.dev, 123).id();
+ DeploymentMetricsMaintainer maintainer = maintainer(tester.controller());
+ Supplier<Application> app = tester.application(appId);
+ Supplier<Deployment> deployment = () -> app.get().deployments().values().stream().findFirst().get();
+
+ // No metrics gathered yet
+ assertEquals(0, app.get().metrics().queryServiceQuality(), 0);
+ assertEquals(0, deployment.get().metrics().documentCount(), 0);
+ assertFalse("Never received any queries", deployment.get().activity().lastQueried().isPresent());
+ assertFalse("Never received any writes", deployment.get().activity().lastWritten().isPresent());
+
+ // Metrics are gathered and saved to application
+ maintainer.maintain();
+ assertEquals(0.5, app.get().metrics().queryServiceQuality(), Double.MIN_VALUE);
+ assertEquals(0.7, app.get().metrics().writeServiceQuality(), Double.MIN_VALUE);
+ assertEquals(1, deployment.get().metrics().queriesPerSecond(), Double.MIN_VALUE);
+ assertEquals(2, deployment.get().metrics().writesPerSecond(), Double.MIN_VALUE);
+ assertEquals(3, deployment.get().metrics().documentCount(), Double.MIN_VALUE);
+ assertEquals(4, deployment.get().metrics().queryLatencyMillis(), Double.MIN_VALUE);
+ assertEquals(5, deployment.get().metrics().writeLatencyMillis(), Double.MIN_VALUE);
+ Instant t1 = tester.clock().instant().truncatedTo(MILLIS);
+ assertEquals(t1, deployment.get().activity().lastQueried().get());
+ assertEquals(t1, deployment.get().activity().lastWritten().get());
+
+ // Time passes. Activity is updated as app is still receiving traffic
+ tester.clock().advance(Duration.ofHours(1));
+ Instant t2 = tester.clock().instant().truncatedTo(MILLIS);
+ maintainer.maintain();
+ assertEquals(t2, deployment.get().activity().lastQueried().get());
+ assertEquals(t2, deployment.get().activity().lastWritten().get());
+ assertEquals(1, deployment.get().activity().lastQueriesPerSecond().getAsDouble(), Double.MIN_VALUE);
+ assertEquals(2, deployment.get().activity().lastWritesPerSecond().getAsDouble(), Double.MIN_VALUE);
+
+ // Query traffic disappears. Query activity stops updating
+ tester.clock().advance(Duration.ofHours(1));
+ Instant t3 = tester.clock().instant().truncatedTo(MILLIS);
+ tester.metricsService().setMetric("queriesPerSecond", 0D);
+ tester.metricsService().setMetric("writesPerSecond", 5D);
+ maintainer.maintain();
+ assertEquals(t2, deployment.get().activity().lastQueried().get());
+ assertEquals(t3, deployment.get().activity().lastWritten().get());
+ assertEquals(1, deployment.get().activity().lastQueriesPerSecond().getAsDouble(), Double.MIN_VALUE);
+ assertEquals(5, deployment.get().activity().lastWritesPerSecond().getAsDouble(), Double.MIN_VALUE);
+
+ // Feed traffic disappears. Feed activity stops updating
+ tester.clock().advance(Duration.ofHours(1));
+ tester.metricsService().setMetric("writesPerSecond", 0D);
+ maintainer.maintain();
+ assertEquals(t2, deployment.get().activity().lastQueried().get());
+ assertEquals(t3, deployment.get().activity().lastWritten().get());
+ assertEquals(1, deployment.get().activity().lastQueriesPerSecond().getAsDouble(), Double.MIN_VALUE);
+ assertEquals(5, deployment.get().activity().lastWritesPerSecond().getAsDouble(), Double.MIN_VALUE);
+ }
@Test
- public void maintain() {
+ public void updates_rotation_status() {
DeploymentTester tester = new DeploymentTester();
MetricsServiceMock metricsService = tester.controllerTester().metricsService();
- ApiAuthorityConfig.Builder apiAuthorityConfigBuilder = new ApiAuthorityConfig.Builder().authorities("http://localhost:" + wireMockRule.port() + "/");
- ApiAuthorityConfig apiAuthorityConfig = new ApiAuthorityConfig(apiAuthorityConfigBuilder);
- DeploymentMetricsMaintainer maintainer = new DeploymentMetricsMaintainer(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()), apiAuthorityConfig);
+ DeploymentMetricsMaintainer maintainer = maintainer(tester.controller());
Application application = tester.createApplication("app1", "tenant1", 1, 1L);
ZoneId zone1 = ZoneId.from("prod", "us-west-1");
ZoneId zone2 = ZoneId.from("prod", "us-east-3");
@@ -65,68 +105,32 @@ public class DeploymentMetricsMaintainerTest {
.build();
tester.deployCompletely(application, applicationPackage);
+ Supplier<Application> app = () -> tester.application(application.id());
+ Supplier<Deployment> deployment1 = () -> app.get().deployments().get(zone1);
+ Supplier<Deployment> deployment2 = () -> app.get().deployments().get(zone2);
String assignedRotation = "rotation-fqdn-01";
tester.controllerTester().metricsService().addRotation(assignedRotation);
+ // No status gathered yet
+ assertEquals(RotationStatus.unknown, app.get().rotationStatus(deployment1.get()));
+ assertEquals(RotationStatus.unknown, app.get().rotationStatus(deployment2.get()));
+
// One rotation out, one in
metricsService.setZoneIn(assignedRotation, "proxy.prod.us-west-1.vip.test");
metricsService.setZoneOut(assignedRotation,"proxy.prod.us-east-3.vip.test");
-
- wireMockRule.stubFor(post(urlEqualTo("/metricforwarding/v1/deploymentmetrics"))
- .willReturn(aResponse().withStatus(200)));
maintainer.maintain();
+ assertEquals(RotationStatus.in, app.get().rotationStatus(deployment1.get()));
+ assertEquals(RotationStatus.out, app.get().rotationStatus(deployment2.get()));
- List<ServeEvent> allServeEvents = getAllServeEvents();
- assertEquals(1, allServeEvents.size());
- LoggedRequest request = findAll(postRequestedFor(urlEqualTo("/metricforwarding/v1/deploymentmetrics"))).get(0);
-
- Slime slime = SlimeUtils.jsonToSlime(request.getBody());
- Inspector inspector = slime.get().entry(0);
- assertEquals("tenant1:app1:default", inspector.field("applicationId").asString());
- MetricsService.ApplicationMetrics applicationMetrics = applicationMetricsFromInspector(inspector.field("applicationMetrics"));
- assertEquals(0.5, applicationMetrics.queryServiceQuality(), DELTA);
- assertEquals(0.7, applicationMetrics.writeServiceQuality(), DELTA);
-
- Map<String, String> rotationStatus = rotationsStatusFromInspector(inspector.field("rotationStatus"));
- assertEquals("in", rotationStatus.get("proxy.prod.us-west-1.vip.test"));
- assertEquals("out", rotationStatus.get("proxy.prod.us-east-3.vip.test"));
-
- Map<String, MetricsService.DeploymentMetrics> deploymentMetricsByZone = deploymentMetricsFromInspector(inspector.field("deploymentMetrics"));
- MetricsService.DeploymentMetrics deploymentMetrics = deploymentMetricsByZone.get("prod.us-west-1");
- assertEquals(1.0, deploymentMetrics.queriesPerSecond(), DELTA);
- assertEquals(2.0, deploymentMetrics.writesPerSecond(), DELTA);
- assertEquals(3.0, deploymentMetrics.documentCount(), DELTA);
- assertEquals(4.0, deploymentMetrics.queryLatencyMillis(), DELTA);
- assertEquals(5.0, deploymentMetrics.writeLatencyMillis(), DELTA);
-
- deploymentMetrics = deploymentMetricsByZone.get("prod.us-east-3");
- assertEquals(1.0, deploymentMetrics.queriesPerSecond(), DELTA);
- assertEquals(2.0, deploymentMetrics.writesPerSecond(), DELTA);
- assertEquals(3.0, deploymentMetrics.documentCount(), DELTA);
- assertEquals(4.0, deploymentMetrics.queryLatencyMillis(), DELTA);
- assertEquals(5.0, deploymentMetrics.writeLatencyMillis(), DELTA);
- }
-
- private MetricsService.ApplicationMetrics applicationMetricsFromInspector(Inspector inspector) {
- return new MetricsService.ApplicationMetrics(inspector.field("queryServiceQuality").asDouble(), inspector.field("writeServiceQuality").asDouble());
+ // All rotations in
+ metricsService.setZoneIn(assignedRotation,"proxy.prod.us-east-3.vip.test");
+ maintainer.maintain();
+ assertEquals(RotationStatus.in, app.get().rotationStatus(deployment1.get()));
+ assertEquals(RotationStatus.in, app.get().rotationStatus(deployment2.get()));
}
- private Map<String, String> rotationsStatusFromInspector(Inspector inspector) {
- HashMap<String, String> rotationStatus = new HashMap<>();
- inspector.traverse((ArrayTraverser) (index, entry) -> {
- rotationStatus.put(entry.field("hostname").asString(), entry.field("rotationStatus").asString());
- });
- return rotationStatus;
+ private static DeploymentMetricsMaintainer maintainer(Controller controller) {
+ return new DeploymentMetricsMaintainer(controller, Duration.ofDays(1), new JobControl(controller.curator()));
}
- private Map<String, MetricsService.DeploymentMetrics> deploymentMetricsFromInspector(Inspector inspector) {
- Map<String, MetricsService.DeploymentMetrics> deploymentMetricByZone = new HashMap<>();
- inspector.traverse((ArrayTraverser) (index, entry) -> {
- String zone = entry.field("zoneId").asString();
- MetricsService.DeploymentMetrics deploymentMetrics = new MetricsService.DeploymentMetrics(entry.field("queriesPerSecond").asDouble(), entry.field("writesPerSecond").asDouble(),
- entry.field("documentCount").asLong(), entry.field("queryLatencyMillis").asDouble(), entry.field("writeLatencyMillis").asDouble());
- deploymentMetricByZone.put(zone, deploymentMetrics);
- });
- return deploymentMetricByZone;
- }
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java
index 6dce576e8a4..19aa247edb4 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java
@@ -58,8 +58,6 @@ public class ControllerAuthorizationFilterTest {
ControllerAuthorizationFilter filter = createFilter(new ControllerTester());
assertIsAllowed(invokeFilter(filter, createRequest(PUT, "/application/v4/user", USER)));
assertIsAllowed(invokeFilter(filter, createRequest(POST, "/application/v4/tenant/john", USER)));
- assertIsAllowed(invokeFilter(filter, createRequest(POST, "/metricforwarding/v1/deploymentmetrics", USER)));
- assertIsAllowed(invokeFilter(filter, createRequest(POST, "/contactinfo/v1/tenant/john/etc", USER)));
}
@Test