diff options
Diffstat (limited to 'controller-server')
29 files changed, 165 insertions, 305 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java index 6e3870e6715..5d3ae7cb753 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java @@ -19,7 +19,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.ArtifactRepo import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud; import com.yahoo.vespa.hosted.controller.api.integration.maven.MavenRepository; import com.yahoo.vespa.hosted.controller.api.integration.metrics.MetricsService; -import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient; import com.yahoo.vespa.hosted.controller.api.integration.user.Roles; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry; import com.yahoo.vespa.hosted.controller.api.role.ApplicationRole; @@ -79,7 +78,6 @@ public class Controller extends AbstractComponent { private final FlagSource flagSource; private final NameServiceForwarder nameServiceForwarder; private final MavenRepository mavenRepository; - private final MeteringClient meteringClient; /** * Creates a controller @@ -93,12 +91,12 @@ public class Controller extends AbstractComponent { ArtifactRepository artifactRepository, ApplicationStore applicationStore, TesterCloud testerCloud, BuildService buildService, RunDataStore runDataStore, FlagSource flagSource, MavenRepository mavenRepository, - MeteringClient meteringClient, ServiceRegistry serviceRegistry) { + ServiceRegistry serviceRegistry) { this(curator, rotationsConfig, zoneRegistry, metricsService, Clock.systemUTC(), accessControl, artifactRepository, applicationStore, testerCloud, buildService, runDataStore, com.yahoo.net.HostName::getLocalhost, flagSource, - mavenRepository, meteringClient, serviceRegistry); + mavenRepository, serviceRegistry); } public Controller(CuratorDb curator, RotationsConfig rotationsConfig, @@ -109,7 +107,6 @@ public class Controller extends AbstractComponent { ArtifactRepository artifactRepository, ApplicationStore applicationStore, TesterCloud testerCloud, BuildService buildService, RunDataStore runDataStore, Supplier<String> hostnameSupplier, FlagSource flagSource, MavenRepository mavenRepository, - MeteringClient meteringClient, ServiceRegistry serviceRegistry) { this.hostnameSupplier = Objects.requireNonNull(hostnameSupplier, "HostnameSupplier cannot be null"); @@ -120,7 +117,6 @@ public class Controller extends AbstractComponent { this.clock = Objects.requireNonNull(clock, "Clock cannot be null"); this.flagSource = Objects.requireNonNull(flagSource, "FlagSource cannot be null"); this.mavenRepository = Objects.requireNonNull(mavenRepository, "MavenRepository cannot be null"); - this.meteringClient = Objects.requireNonNull(meteringClient, "MeteringClient cannot be null"); nameServiceForwarder = new NameServiceForwarder(curator); jobController = new JobController(this, runDataStore, Objects.requireNonNull(testerCloud)); @@ -286,10 +282,6 @@ public class Controller extends AbstractComponent { return auditLogger; } - public MeteringClient meteringClient() { - return meteringClient; - } - /** Returns all other roles the given tenant role implies. */ public Set<Role> impliedRoles(TenantRole role) { return Stream.concat(Roles.tenantRoles(role.tenant()).stream(), diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java index b9be68f6de1..03d084cd9e3 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java @@ -75,6 +75,7 @@ public class Deployment { } /** Returns utilization of the clusters allocated to this */ + // TODO(mpolden): No longer updated. Remove this and associated serialization public Map<Id, ClusterUtilization> clusterUtils() { return clusterUtilization; } 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 deleted file mode 100644 index 865084064a2..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java +++ /dev/null @@ -1,59 +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.controller.maintenance; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.ClusterSpec; -import com.yahoo.config.provision.SystemName; -import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; -import com.yahoo.vespa.hosted.controller.Controller; -import com.yahoo.vespa.hosted.controller.api.integration.metrics.MetricsService; -import com.yahoo.vespa.hosted.controller.application.ClusterUtilization; -import com.yahoo.vespa.hosted.controller.application.Deployment; - -import java.time.Duration; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Predicate; - -/** - * Fetch utilization metrics and update applications with this data. - * - * @author smorgrav - */ -public class ClusterUtilizationMaintainer extends Maintainer { - - private final Controller controller; - - public ClusterUtilizationMaintainer(Controller controller, Duration duration, JobControl jobControl) { - super(controller, duration, jobControl, null, SystemName.allOf(Predicate.not(SystemName::isPublic))); - this.controller = controller; - } - - private Map<ClusterSpec.Id, ClusterUtilization> getUpdatedClusterUtilizations(ApplicationId app, ZoneId zone) { - Map<String, MetricsService.SystemMetrics> systemMetrics = controller.metricsService().getSystemMetrics(app, zone); - - Map<ClusterSpec.Id, ClusterUtilization> utilizationMap = new HashMap<>(); - for (Map.Entry<String, MetricsService.SystemMetrics> metrics : systemMetrics.entrySet()) { - MetricsService.SystemMetrics systemMetric = metrics.getValue(); - ClusterUtilization utilization = new ClusterUtilization(systemMetric.memUtil() / 100, systemMetric.cpuUtil() / 100, systemMetric.diskUtil() / 100, 0); - utilizationMap.put(new ClusterSpec.Id(metrics.getKey()), utilization); - } - - return utilizationMap; - } - - @Override - protected void maintain() { - for (Application application : controller().applications().asList()) { - for (Deployment deployment : application.deployments().values()) { - - Map<ClusterSpec.Id, ClusterUtilization> clusterUtilization = getUpdatedClusterUtilizations(application.id(), deployment.zone()); - - controller().applications().lockIfPresent(application.id(), lockedApplication -> - controller().applications().store(lockedApplication.withClusterUtilization(deployment.zone(), clusterUtilization))); - } - } - } - -} 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 0080d7c23c2..cbe9d8c70c1 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 @@ -11,7 +11,6 @@ import com.yahoo.vespa.hosted.controller.tenant.Tenant; import com.yahoo.yolean.Exceptions; import java.time.Duration; -import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; import java.util.logging.Logger; @@ -27,9 +26,9 @@ public class ContactInformationMaintainer extends Maintainer { private final ContactRetriever contactRetriever; - public ContactInformationMaintainer(Controller controller, Duration interval, JobControl jobControl, ContactRetriever contactRetriever) { + public ContactInformationMaintainer(Controller controller, Duration interval, JobControl jobControl) { super(controller, interval, jobControl, null, SystemName.allOf(Predicate.not(SystemName::isPublic))); - this.contactRetriever = Objects.requireNonNull(contactRetriever, "organization must be non-null"); + this.contactRetriever = controller.serviceRegistry().contactRetriever(); } @Override 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 7c3188d9d28..2fdee305f3d 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 @@ -7,16 +7,9 @@ import com.yahoo.jdisc.Metric; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.aws.AwsEventFetcher; import com.yahoo.vespa.hosted.controller.api.integration.organization.Billing; -import com.yahoo.vespa.hosted.controller.api.integration.organization.ContactRetriever; -import com.yahoo.vespa.hosted.controller.api.integration.organization.DeploymentIssues; -import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueHandler; -import com.yahoo.vespa.hosted.controller.api.integration.organization.OwnershipIssues; -import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient; import com.yahoo.vespa.hosted.controller.authority.config.ApiAuthorityConfig; import com.yahoo.vespa.hosted.controller.maintenance.config.MaintainerConfig; import com.yahoo.vespa.hosted.controller.persistence.CuratorDb; -import com.yahoo.vespa.hosted.controller.restapi.cost.CostReportConsumer; -import com.yahoo.vespa.hosted.controller.restapi.cost.config.SelfHostedCostConfig; import java.time.Duration; import java.util.Collections; @@ -42,7 +35,6 @@ public class ControllerMaintenance extends AbstractComponent { private final Upgrader upgrader; private final ReadyJobsTrigger readyJobsTrigger; private final ClusterInfoMaintainer clusterInfoMaintainer; - private final ClusterUtilizationMaintainer clusterUtilizationMaintainer; private final DeploymentMetricsMaintainer deploymentMetricsMaintainer; private final ApplicationOwnershipConfirmer applicationOwnershipConfirmer; private final SystemUpgrader systemUpgrader; @@ -58,39 +50,36 @@ public class ControllerMaintenance extends AbstractComponent { private final RotationStatusUpdater rotationStatusUpdater; @SuppressWarnings("unused") // instantiated by Dependency Injection - public ControllerMaintenance(MaintainerConfig maintainerConfig, ApiAuthorityConfig apiAuthorityConfig, Controller controller, CuratorDb curator, - JobControl jobControl, Metric metric, - DeploymentIssues deploymentIssues, OwnershipIssues ownershipIssues, - ContactRetriever contactRetriever, - CostReportConsumer reportConsumer, - MeteringClient meteringClient, + public ControllerMaintenance(MaintainerConfig maintainerConfig, + ApiAuthorityConfig apiAuthorityConfig, + Controller controller, + CuratorDb curator, + JobControl jobControl, + Metric metric, Billing billing, - SelfHostedCostConfig selfHostedCostConfig, - IssueHandler issueHandler, AwsEventFetcher awsEventFetcher) { Duration maintenanceInterval = Duration.ofMinutes(maintainerConfig.intervalMinutes()); this.jobControl = jobControl; deploymentExpirer = new DeploymentExpirer(controller, maintenanceInterval, jobControl); - deploymentIssueReporter = new DeploymentIssueReporter(controller, deploymentIssues, maintenanceInterval, jobControl); + deploymentIssueReporter = new DeploymentIssueReporter(controller, controller.serviceRegistry().deploymentIssues(), maintenanceInterval, jobControl); metricsReporter = new MetricsReporter(controller, metric, jobControl); outstandingChangeDeployer = new OutstandingChangeDeployer(controller, Duration.ofMinutes(1), jobControl); versionStatusUpdater = new VersionStatusUpdater(controller, Duration.ofMinutes(1), jobControl); upgrader = new Upgrader(controller, maintenanceInterval, jobControl, curator); readyJobsTrigger = new ReadyJobsTrigger(controller, Duration.ofMinutes(1), jobControl); clusterInfoMaintainer = new ClusterInfoMaintainer(controller, Duration.ofHours(2), jobControl); - clusterUtilizationMaintainer = new ClusterUtilizationMaintainer(controller, Duration.ofHours(2), jobControl); deploymentMetricsMaintainer = new DeploymentMetricsMaintainer(controller, Duration.ofMinutes(5), jobControl); - applicationOwnershipConfirmer = new ApplicationOwnershipConfirmer(controller, Duration.ofHours(12), jobControl, ownershipIssues); + applicationOwnershipConfirmer = new ApplicationOwnershipConfirmer(controller, Duration.ofHours(12), jobControl, controller.serviceRegistry().ownershipIssues()); 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, contactRetriever); + contactInformationMaintainer = new ContactInformationMaintainer(controller, Duration.ofHours(12), jobControl); nameServiceDispatcher = new NameServiceDispatcher(controller, Duration.ofSeconds(10), jobControl); - costReportMaintainer = new CostReportMaintainer(controller, Duration.ofHours(2), reportConsumer, jobControl, selfHostedCostConfig); - resourceMeterMaintainer = new ResourceMeterMaintainer(controller, Duration.ofMinutes(30), jobControl, metric, meteringClient); + costReportMaintainer = new CostReportMaintainer(controller, Duration.ofHours(2), jobControl, controller.serviceRegistry().costReportConsumer()); + resourceMeterMaintainer = new ResourceMeterMaintainer(controller, Duration.ofMinutes(30), jobControl, metric, controller.serviceRegistry().meteringService()); billingMaintainer = new BillingMaintainer(controller, Duration.ofDays(3), jobControl, billing); - awsEventReporterMaintainer = new AwsEventReporterMaintainer(controller, Duration.ofDays(1), jobControl, issueHandler, awsEventFetcher); + awsEventReporterMaintainer = new AwsEventReporterMaintainer(controller, Duration.ofDays(1), jobControl, controller.serviceRegistry().issueHandler(), awsEventFetcher); rotationStatusUpdater = new RotationStatusUpdater(controller, maintenanceInterval, jobControl); } @@ -108,7 +97,6 @@ public class ControllerMaintenance extends AbstractComponent { versionStatusUpdater.deconstruct(); upgrader.deconstruct(); readyJobsTrigger.deconstruct(); - clusterUtilizationMaintainer.deconstruct(); clusterInfoMaintainer.deconstruct(); deploymentMetricsMaintainer.deconstruct(); applicationOwnershipConfirmer.deconstruct(); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java index 20339b814a8..9c70f734baf 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java @@ -1,14 +1,12 @@ // Copyright 2019 Oath Inc. 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.google.inject.Inject; import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.SystemName; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository; +import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportConsumer; import com.yahoo.vespa.hosted.controller.restapi.cost.CostCalculator; -import com.yahoo.vespa.hosted.controller.restapi.cost.CostReportConsumer; -import com.yahoo.vespa.hosted.controller.restapi.cost.config.SelfHostedCostConfig; import java.time.Clock; import java.time.Duration; @@ -25,24 +23,18 @@ public class CostReportMaintainer extends Maintainer { private final CostReportConsumer consumer; private final NodeRepository nodeRepository; private final Clock clock; - private final SelfHostedCostConfig selfHostedCostConfig; - @Inject - @SuppressWarnings("WeakerAccess") public CostReportMaintainer(Controller controller, Duration interval, - CostReportConsumer consumer, - JobControl jobControl, - SelfHostedCostConfig selfHostedCostConfig) { + JobControl jobControl, CostReportConsumer costReportConsumer) { super(controller, interval, jobControl, "CostReportMaintainer", EnumSet.of(SystemName.main)); - this.consumer = consumer; + this.consumer = costReportConsumer; this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); this.clock = controller.clock(); - this.selfHostedCostConfig = selfHostedCostConfig; } @Override protected void maintain() { - consumer.Consume(CostCalculator.resourceShareByPropertyToCsv(nodeRepository, controller(), clock, selfHostedCostConfig, CloudName.from("yahoo"))); + consumer.consume(CostCalculator.resourceShareByPropertyToCsv(nodeRepository, controller(), clock, consumer.fixedAllocations(), CloudName.from("yahoo"))); } } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index fbc8f06bd38..5edc78c2005 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -809,7 +809,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { Slime slime = new Slime(); Cursor root = slime.setObject(); - MeteringInfo meteringInfo = controller.meteringClient().getResourceSnapshots(tenant, application); + MeteringInfo meteringInfo = controller.serviceRegistry().meteringService().getResourceSnapshots(tenant, application); ResourceAllocation currentSnapshot = meteringInfo.getCurrentSnapshot(); Cursor currentRate = root.setObject("currentrate"); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiHandler.java index e048c963641..61e5dc359d2 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiHandler.java @@ -9,6 +9,7 @@ import com.yahoo.restapi.Path; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; import com.yahoo.vespa.athenz.api.AthenzDomain; +import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; import com.yahoo.vespa.hosted.controller.api.integration.entity.EntityService; @@ -35,10 +36,10 @@ public class AthenzApiHandler extends LoggingRequestHandler { private final AthenzFacade athenz; private final EntityService properties; - public AthenzApiHandler(Context parentCtx, AthenzFacade athenz, EntityService properties) { + public AthenzApiHandler(Context parentCtx, AthenzFacade athenz, Controller controller) { super(parentCtx); this.athenz = athenz; - this.properties = properties; + this.properties = controller.serviceRegistry().entityService(); } @Override diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiHandler.java index ee633a19bfc..6ed9db7455c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiHandler.java @@ -7,9 +7,9 @@ import com.yahoo.container.jdisc.LoggingRequestHandler; import com.yahoo.restapi.Path; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository; +import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportConsumer; import com.yahoo.vespa.hosted.controller.restapi.ErrorResponse; import com.yahoo.vespa.hosted.controller.restapi.StringResponse; -import com.yahoo.vespa.hosted.controller.restapi.cost.config.SelfHostedCostConfig; import java.time.Clock; import java.util.Optional; @@ -23,13 +23,13 @@ public class CostApiHandler extends LoggingRequestHandler { private final Controller controller; private final NodeRepository nodeRepository; - private final SelfHostedCostConfig selfHostedCostConfig; + private final CostReportConsumer costReportConsumer; - public CostApiHandler(Context ctx, Controller controller, SelfHostedCostConfig selfHostedCostConfig) { + public CostApiHandler(Context ctx, Controller controller) { super(ctx); this.controller = controller; this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); - this.selfHostedCostConfig = selfHostedCostConfig; + this.costReportConsumer = controller.serviceRegistry().costReportConsumer(); } @Override @@ -43,7 +43,7 @@ public class CostApiHandler extends LoggingRequestHandler { if (path.matches("/cost/v1/csv")) { Optional<String> cloudProperty = Optional.ofNullable(request.getProperty("cloud")); CloudName cloud = cloudProperty.map(CloudName::from).orElse(CloudName.defaultName()); - return new StringResponse(CostCalculator.resourceShareByPropertyToCsv(nodeRepository, controller, Clock.systemUTC(), selfHostedCostConfig, cloud)); + return new StringResponse(CostCalculator.resourceShareByPropertyToCsv(nodeRepository, controller, Clock.systemUTC(), costReportConsumer.fixedAllocations(), cloud)); } return ErrorResponse.notFoundError("Nothing at " + path); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostCalculator.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostCalculator.java index 50c7732bf76..5cce865eb30 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostCalculator.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostCalculator.java @@ -7,7 +7,6 @@ import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository; import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceAllocation; -import com.yahoo.vespa.hosted.controller.restapi.cost.config.SelfHostedCostConfig; import com.yahoo.vespa.hosted.controller.tenant.AthenzTenant; import com.yahoo.vespa.hosted.controller.tenant.Tenant; @@ -32,7 +31,7 @@ public class CostCalculator { public static String resourceShareByPropertyToCsv(NodeRepository nodeRepository, Controller controller, Clock clock, - SelfHostedCostConfig selfHostedCostConfig, + Map<Property, ResourceAllocation> fixedAllocations, CloudName cloudName) { var date = new SimpleDateFormat("yyyy-MM-dd").format(Date.from(clock.instant())); @@ -62,14 +61,12 @@ public class CostCalculator { // Add fixed allocations from config if (cloudName.equals(CloudName.from("yahoo"))) { - for (var propertyEntry : selfHostedCostConfig.properties()) { - var property = new Property(propertyEntry.name()); + for (var kv : fixedAllocations.entrySet()) { + var property = kv.getKey(); var allocation = allocationByProperty.getOrDefault(property, ResourceAllocation.ZERO); - var fixedAllocation = new ResourceAllocation(propertyEntry.cpuCores() * SELF_HOSTED_DISCOUNT, - propertyEntry.memoryGb() * SELF_HOSTED_DISCOUNT, - propertyEntry.diskGb() * SELF_HOSTED_DISCOUNT); - allocationByProperty.put(property, allocation.plus(fixedAllocation)); - totalAllocation = totalAllocation.plus(fixedAllocation); + var discountedFixedAllocation = kv.getValue().multiply(SELF_HOSTED_DISCOUNT); + allocationByProperty.put(property, allocation.plus(discountedFixedAllocation)); + totalAllocation = totalAllocation.plus(discountedFixedAllocation); } } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostReportConsumer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostReportConsumer.java deleted file mode 100644 index 51a664160ab..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostReportConsumer.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.yahoo.vespa.hosted.controller.restapi.cost; - -public interface CostReportConsumer { - void Consume(String csv); -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostReportConsumerMock.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostReportConsumerMock.java new file mode 100644 index 00000000000..5c16560b509 --- /dev/null +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostReportConsumerMock.java @@ -0,0 +1,38 @@ +package com.yahoo.vespa.hosted.controller.restapi.cost; + +import com.yahoo.vespa.hosted.controller.api.identifiers.Property; +import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportConsumer; +import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceAllocation; + +import java.util.Map; +import java.util.function.Consumer; + +/** + * @author ldalves + */ +public class CostReportConsumerMock implements CostReportConsumer { + + private final Consumer<String> csvConsumer; + private final Map<Property, ResourceAllocation> fixedAllocations; + + public CostReportConsumerMock() { + this.csvConsumer = (ignored) -> {}; + this.fixedAllocations = Map.of(); + } + + public CostReportConsumerMock(Consumer<String> csvConsumer, Map<Property, ResourceAllocation> fixedAllocations) { + this.csvConsumer = csvConsumer; + this.fixedAllocations = Map.copyOf(fixedAllocations); + } + + @Override + public void consume(String csv) { + csvConsumer.accept(csv); + } + + @Override + public Map<Property, ResourceAllocation> fixedAllocations() { + return fixedAllocations; + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/NoopCostReportConsumer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/NoopCostReportConsumer.java deleted file mode 100644 index f1406da1d4b..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/NoopCostReportConsumer.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.yahoo.vespa.hosted.controller.restapi.cost; - -import com.google.inject.Inject; -import com.yahoo.component.AbstractComponent; - -public class NoopCostReportConsumer implements CostReportConsumer { - - @Inject - public NoopCostReportConsumer() {} - - @Override - public void Consume(String csv) { - // discard into the void - } -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java index c32ab6726e9..7a76f13392d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java @@ -14,7 +14,6 @@ import com.yahoo.slime.Inspector; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; import com.yahoo.vespa.hosted.controller.api.integration.user.Roles; -import com.yahoo.vespa.hosted.controller.api.integration.user.User; import com.yahoo.vespa.hosted.controller.api.integration.user.UserId; import com.yahoo.vespa.hosted.controller.api.integration.user.UserManagement; import com.yahoo.vespa.hosted.controller.api.role.Role; @@ -130,11 +129,11 @@ public class UserApiHandler extends LoggingRequestHandler { for (Role role : roles) rolesArray.addString(valueOf(role)); - Map<User, List<Role>> memberships = new LinkedHashMap<>(); + Map<UserId, List<Role>> memberships = new LinkedHashMap<>(); List<Role> allRoles = new ArrayList<>(superRoles); // Membership in a super role may imply membership in a role. allRoles.addAll(roles); for (Role role : allRoles) - for (User user : users.listUsers(role)) { + for (UserId user : users.listUsers(role)) { memberships.putIfAbsent(user, new ArrayList<>()); memberships.get(user).add(role); } @@ -142,15 +141,7 @@ public class UserApiHandler extends LoggingRequestHandler { Cursor usersArray = root.setArray("users"); memberships.forEach((user, userRoles) -> { Cursor userObject = usersArray.addObject(); - userObject.setString("name", user.name()); - userObject.setString("email", user.email()); - if (user.nickname() != null) { - userObject.setString("nickname", user.nickname()); - } - if (user.picture()!= null) { - userObject.setString("picture", user.picture()); - } - + userObject.setString("name", user.value()); Cursor rolesObject = userObject.setObject("roles"); for (Role role : roles) { Cursor roleObject = rolesObject.setObject(valueOf(role)); @@ -183,14 +174,12 @@ public class UserApiHandler extends LoggingRequestHandler { String roleName = require("roleName", Inspector::asString, requestObject); UserId user = new UserId(require("user", Inspector::asString, requestObject)); Role role = Roles.toRole(TenantName.from(tenantName), roleName); - List<User> currentUsers = users.listUsers(role); - if (role.definition() == RoleDefinition.tenantOwner - && currentUsers.size() == 1 - && currentUsers.get(0).email().equals(user.value())) + if ( role.definition() == RoleDefinition.tenantOwner + && users.listUsers(role).equals(List.of(user))) throw new IllegalArgumentException("Can't remove the last owner of a tenant."); users.removeUsers(role, List.of(user)); - return new MessageResponse(user+" is no longer a member of "+role); + return new MessageResponse(user + " is no longer a member of " + role); } private HttpResponse removeApplicationRoleMember(String tenantName, String applicationName, HttpRequest request) { diff --git a/controller-server/src/main/resources/configdefinitions/self-hosted-cost.def b/controller-server/src/main/resources/configdefinitions/self-hosted-cost.def deleted file mode 100644 index 059af1558a4..00000000000 --- a/controller-server/src/main/resources/configdefinitions/self-hosted-cost.def +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -namespace=vespa.hosted.controller.restapi.cost.config - -properties[].name string -properties[].cpuCores int -properties[].memoryGb int -properties[].diskGb int
\ No newline at end of file diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java index 19a152a5ba0..9d04d6950f7 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java @@ -26,10 +26,8 @@ import com.yahoo.vespa.hosted.controller.api.integration.dns.MemoryNameService; import com.yahoo.vespa.hosted.controller.api.integration.dns.Record; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName; import com.yahoo.vespa.hosted.controller.api.integration.organization.Contact; -import com.yahoo.vespa.hosted.controller.api.integration.organization.MockContactRetriever; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockBuildService; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMavenRepository; -import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockRunDataStore; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockTesterCloud; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; @@ -83,7 +81,6 @@ public final class ControllerTester { private final ApplicationStoreMock applicationStore; private final MockBuildService buildService; private final MetricsServiceMock metricsService; - private final MockContactRetriever contactRetriever; private Controller controller; @@ -98,7 +95,6 @@ public final class ControllerTester { new ApplicationStoreMock(), new MockBuildService(), metricsService, - new MockContactRetriever(), new ServiceRegistryMock()); } @@ -124,7 +120,6 @@ public final class ControllerTester { ArtifactRepositoryMock artifactRepository, ApplicationStoreMock appStoreMock, MockBuildService buildService, MetricsServiceMock metricsService, - MockContactRetriever contactRetriever, ServiceRegistryMock serviceRegistry) { this.athenzDb = athenzDb; this.clock = clock; @@ -136,7 +131,6 @@ public final class ControllerTester { this.applicationStore = appStoreMock; this.buildService = buildService; this.metricsService = metricsService; - this.contactRetriever = contactRetriever; this.controller = createController(curator, rotationsConfig, clock, zoneRegistry, athenzDb, artifactRepository, appStoreMock, buildService, metricsService, serviceRegistry); @@ -185,10 +179,6 @@ public final class ControllerTester { public MetricsServiceMock metricsService() { return metricsService; } - public MockContactRetriever contactRetriever() { - return contactRetriever; - } - public Optional<Record> findCname(String name) { return serviceRegistry.nameService().findRecords(Record.Type.CNAME, RecordName.from(name)).stream().findFirst(); } @@ -346,7 +336,6 @@ public final class ControllerTester { () -> "test-controller", new InMemoryFlagSource(), new MockMavenRepository(), - new MockMeteringClient(), serviceRegistry); // Calculate initial versions controller.updateVersionStatus(VersionStatus.compute(controller)); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ApplicationCertificateMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ApplicationCertificateMock.java deleted file mode 100644 index f3bee70db4c..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ApplicationCertificateMock.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.integration; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificate; -import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificateProvider; - -import java.util.UUID; - -/** - * @author tokle - */ -public class ApplicationCertificateMock implements ApplicationCertificateProvider { - - @Override - public ApplicationCertificate requestCaSignedCertificate(ApplicationId applicationId) { - return new ApplicationCertificate(String.format("vespa.tls.%s.%s@%s", applicationId.tenant(), - applicationId.application(), - UUID.randomUUID().toString())); - } - -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/MetricsServiceMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/MetricsServiceMock.java index a310854fcdf..2eae50cbf9f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/MetricsServiceMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/MetricsServiceMock.java @@ -3,10 +3,8 @@ package com.yahoo.vespa.hosted.controller.integration; import com.yahoo.component.AbstractComponent; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; -import com.yahoo.vespa.hosted.controller.api.integration.metrics.MetricsService; -import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; import com.yahoo.config.provision.zone.ZoneId; +import com.yahoo.vespa.hosted.controller.api.integration.metrics.MetricsService; import java.util.HashMap; import java.util.Map; @@ -38,17 +36,4 @@ public class MetricsServiceMock extends AbstractComponent implements MetricsServ metrics.getOrDefault("writeLatencyMillis", 5D)); } - @Override - public Map<String, SystemMetrics> getSystemMetrics(ApplicationId application, ZoneId zone) { - Map<String, SystemMetrics> result = new HashMap<>(); - SystemMetrics system = new SystemMetrics(55.54, 69.90, 34.59); - result.put("default", system); - return result; - } - - @Override - public Map<HostName, RotationStatus> getRotationStatus(String rotationName) { - return Map.of(); - } - } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java index 19b359c3851..4aba394da4a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java @@ -3,15 +3,30 @@ package com.yahoo.vespa.hosted.controller.integration; import com.yahoo.component.AbstractComponent; import com.yahoo.vespa.hosted.controller.api.integration.ServiceRegistry; +import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificateMock; import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificateProvider; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer; import com.yahoo.vespa.hosted.controller.api.integration.dns.MemoryNameService; import com.yahoo.vespa.hosted.controller.api.integration.dns.NameService; +import com.yahoo.vespa.hosted.controller.api.integration.entity.EntityService; +import com.yahoo.vespa.hosted.controller.api.integration.entity.MemoryEntityService; +import com.yahoo.vespa.hosted.controller.api.integration.organization.ContactRetriever; +import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueHandler; +import com.yahoo.vespa.hosted.controller.api.integration.organization.DeploymentIssues; import com.yahoo.vespa.hosted.controller.api.integration.organization.Mailer; +import com.yahoo.vespa.hosted.controller.api.integration.organization.MockContactRetriever; +import com.yahoo.vespa.hosted.controller.api.integration.organization.MockIssueHandler; +import com.yahoo.vespa.hosted.controller.api.integration.organization.OwnershipIssues; +import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportConsumer; +import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient; import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService; import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService; import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator; +import com.yahoo.vespa.hosted.controller.api.integration.stubs.DummyOwnershipIssues; +import com.yahoo.vespa.hosted.controller.api.integration.stubs.LoggingDeploymentIssues; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMailer; +import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient; +import com.yahoo.vespa.hosted.controller.restapi.cost.CostReportConsumerMock; /** * A mock implementation of a {@link ServiceRegistry} for testing purposes. @@ -27,6 +42,13 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg private final RoutingGeneratorMock routingGeneratorMock = new RoutingGeneratorMock(); private final MockMailer mockMailer = new MockMailer(); private final ApplicationCertificateMock applicationCertificateMock = new ApplicationCertificateMock(); + private final MockMeteringClient mockMeteringClient = new MockMeteringClient(); + private final MockContactRetriever mockContactRetriever = new MockContactRetriever(); + private final MockIssueHandler mockIssueHandler = new MockIssueHandler(); + private final DummyOwnershipIssues dummyOwnershipIssues = new DummyOwnershipIssues(); + private final LoggingDeploymentIssues loggingDeploymentIssues = new LoggingDeploymentIssues(); + private final MemoryEntityService memoryEntityService = new MemoryEntityService(); + private final CostReportConsumerMock costReportConsumerMock = new CostReportConsumerMock(); @Override public ConfigServer configServer() { @@ -54,6 +76,41 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg } @Override + public MeteringClient meteringService() { + return mockMeteringClient; + } + + @Override + public ContactRetriever contactRetriever() { + return mockContactRetriever; + } + + @Override + public IssueHandler issueHandler() { + return mockIssueHandler; + } + + @Override + public OwnershipIssues ownershipIssues() { + return dummyOwnershipIssues; + } + + @Override + public DeploymentIssues deploymentIssues() { + return loggingDeploymentIssues; + } + + @Override + public EntityService entityService() { + return memoryEntityService; + } + + @Override + public CostReportConsumer costReportConsumer() { + return costReportConsumerMock; + } + + @Override public NameService nameService() { return memoryNameService; } @@ -78,4 +135,8 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg return routingGeneratorMock; } + public MockContactRetriever contactRetrieverMock() { + return mockContactRetriever; + } + } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java index 9eedc49022c..f9c8b66acda 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java @@ -41,7 +41,7 @@ public class ApplicationOwnershipConfirmerTest { @Test public void testConfirmation() { - Optional<Contact> contact = Optional.of(tester.controllerTester().contactRetriever().contact()); + Optional<Contact> contact = Optional.of(tester.controllerTester().serviceRegistry().contactRetrieverMock().contact()); TenantName property = tester.controllerTester().createTenant("property", "domain", 1L, contact); tester.createAndDeploy(property, "application", 1, "default"); Supplier<Application> propertyApp = () -> tester.controller().applications().require(ApplicationId.from("property", "application", "default")); @@ -69,7 +69,7 @@ public class ApplicationOwnershipConfirmerTest { assertEquals("Confirmation issue has been filed for property owned application.", issueId, propertyApp.get().ownershipIssueId()); assertEquals("Confirmation issue has been filed for user owned application.", issueId, userApp.get().ownershipIssueId()); assertTrue(issues.escalatedToTerminator); - assertTrue("Both applications have had their responses ensured.", issues.escalatedToContact && issues.escalatedToTerminator); + assertTrue("Both applications have had their responses ensured.", issues.escalatedToContact); // No new issue is created, so return empty now. issues.response = Optional.empty(); 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 deleted file mode 100644 index 66be2d09797..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainerTest.java +++ /dev/null @@ -1,39 +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.controller.maintenance; - -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -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.persistence.MockCuratorDb; -import org.junit.Assert; -import org.junit.Test; - -import java.time.Duration; - -/** - * @author smorgrav - */ -public class ClusterUtilizationMaintainerTest { - - @Test - public void maintain() { - ControllerTester tester = new ControllerTester(); - ApplicationId app = tester.createAndDeploy("tenant1", "domain1", "app1", Environment.dev, 123).id(); - - // Precondition: no cluster info attached to the deployments - Deployment deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get(); - Assert.assertEquals(0, deployment.clusterUtils().size()); - - ClusterUtilizationMaintainer mainainer = new ClusterUtilizationMaintainer(tester.controller(), Duration.ofHours(1), new JobControl(new MockCuratorDb())); - mainainer.maintain(); - - 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 a794940c8c1..0db718080c2 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 @@ -32,8 +32,7 @@ public class ContactInformationMaintainerTest { public void before() { tester = new ControllerTester(); maintainer = new ContactInformationMaintainer(tester.controller(), Duration.ofDays(1), - new JobControl(tester.controller().curator()), - tester.contactRetriever()); + new JobControl(tester.controller().curator())); } @Test @@ -53,7 +52,7 @@ public class ContactInformationMaintainerTest { private void registerContact(long propertyId, Contact contact) { PropertyId p = new PropertyId(String.valueOf(propertyId)); - tester.contactRetriever().addContact(p, contact); + tester.serviceRegistry().contactRetrieverMock().addContact(p, contact); } private static Contact testContact() { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java index 892da281667..bc68491d8dd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainerTest.java @@ -1,13 +1,15 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.vespa.hosted.controller.ControllerTester; +import com.yahoo.vespa.hosted.controller.api.identifiers.Property; +import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceAllocation; import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock; -import com.yahoo.vespa.hosted.controller.restapi.cost.CostReportConsumer; -import com.yahoo.vespa.hosted.controller.restapi.cost.config.SelfHostedCostConfig; +import com.yahoo.vespa.hosted.controller.restapi.cost.CostReportConsumerMock; import org.junit.Test; import java.time.Duration; import java.time.Instant; +import java.util.Map; import static org.junit.Assert.assertEquals; @@ -28,21 +30,15 @@ public class CostReportMaintainerTest { ZoneApiMock.newBuilder().withId("prod.eu-west-1").withCloud("yahoo").build()); addNodes(); - CostReportConsumer mockConsumer = csv -> assertEquals( - "Date,Property,Reserved Cpu Cores,Reserved Memory GB,Reserved Disk Space GB,Usage Fraction\n" + + CostReportConsumerMock costReportConsumer = new CostReportConsumerMock( + (csv) -> assertEquals( + "Date,Property,Reserved Cpu Cores,Reserved Memory GB,Reserved Disk Space GB,Usage Fraction\n" + "1970-01-01,Property1,96.0,96.0,2000.0,0.3055555555555555\n" + "1970-01-01,Property3,128.0,96.0,2000.0,0.3333333333333333\n" + "1970-01-01,Property2,160.0,96.0,2000.0,0.3611111111111111", - csv); - - SelfHostedCostConfig costConfig = new SelfHostedCostConfig.Builder() - .properties( - new SelfHostedCostConfig.Properties.Builder() - .name("Property3") - .cpuCores(256) - .memoryGb(192) - .diskGb(4000)) - .build(); + csv), + Map.of(new Property("Property3"), new ResourceAllocation(256, 192, 4000)) + ); tester.createTenant("tenant1", "app1", 1L); @@ -50,9 +46,8 @@ public class CostReportMaintainerTest { CostReportMaintainer maintainer = new CostReportMaintainer( tester.controller(), Duration.ofDays(1), - mockConsumer, new JobControl(tester.curator()), - costConfig); + costReportConsumer); maintainer.maintain(); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java index 264d28fa056..7da1064cb23 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java @@ -72,7 +72,7 @@ public class DeploymentIssueReporterTest { tester.upgradeSystem(Version.fromString("6.2")); - Optional<Contact> contact = Optional.of(tester.controllerTester().contactRetriever().contact()); + Optional<Contact> contact = Optional.of(tester.controllerTester().serviceRegistry().contactRetrieverMock().contact()); tester.controllerTester().createTenant("tenant1", "domain1", 1L, contact); tester.controllerTester().createTenant("tenant2", "domain2", 1L, contact); tester.controllerTester().createTenant("tenant3", "domain3", 1L, contact); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java index 6411fbe5cbf..d1c7ac5d363 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java @@ -64,16 +64,9 @@ public class ControllerContainerTest { " <component id='com.yahoo.vespa.curator.mock.MockCurator'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.athenz.mock.AthenzClientFactoryMock'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.entity.MemoryEntityService'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.LoggingDeploymentIssues'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.restapi.cost.NoopCostReportConsumer'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.DummyOwnershipIssues'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.MockRunDataStore'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.organization.MockContactRetriever'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.organization.MockIssueHandler'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.aws.MockAwsEventFetcher' />\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.organization.MockBilling'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.integration.ServiceRegistryMock'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.Controller'/>\n" + diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 9db289ae054..102e05ff923 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -34,7 +34,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.metrics.MetricsService.ApplicationMetrics; import com.yahoo.vespa.hosted.controller.api.integration.organization.Contact; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; -import com.yahoo.vespa.hosted.controller.api.integration.organization.MockContactRetriever; import com.yahoo.vespa.hosted.controller.api.integration.organization.User; import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringInfo; import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceAllocation; @@ -928,7 +927,7 @@ public class ApplicationApiTest extends ControllerContainerTest { @Test public void testMeteringResponses() { - MockMeteringClient mockMeteringClient = (MockMeteringClient) controllerTester.controller().meteringClient(); + MockMeteringClient mockMeteringClient = (MockMeteringClient) controllerTester.containerTester().serviceRegistry().meteringService(); // Mock response for MeteringClient ResourceAllocation currentSnapshot = new ResourceAllocation(1, 2, 3); @@ -1727,10 +1726,6 @@ public class ApplicationApiTest extends ControllerContainerTest { return (ServiceRegistryMock) tester.container().components().getComponent(ServiceRegistryMock.class.getName()); } - private MockContactRetriever contactRetriever() { - return (MockContactRetriever) tester.container().components().getComponent(MockContactRetriever.class.getName()); - } - private void setZoneInRotation(String rotationName, ZoneId zone) { serviceRegistry().globalRoutingServiceMock().setStatus(rotationName, zone, com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus.IN); new RotationStatusUpdater(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator())).run(); @@ -1759,11 +1754,12 @@ public class ApplicationApiTest extends ControllerContainerTest { private void registerContact(long propertyId) { PropertyId p = new PropertyId(String.valueOf(propertyId)); - contactRetriever().addContact(p, new Contact(URI.create("www.issues.tld/" + p.id()), - URI.create("www.contacts.tld/" + p.id()), - URI.create("www.properties.tld/" + p.id()), - List.of(Collections.singletonList("alice"), - Collections.singletonList("bob")), "queue", Optional.empty())); + serviceRegistry().contactRetrieverMock().addContact(p, new Contact(URI.create("www.issues.tld/" + p.id()), + URI.create("www.contacts.tld/" + p.id()), + URI.create("www.properties.tld/" + p.id()), + List.of(Collections.singletonList("alice"), + Collections.singletonList("bob")), + "queue", Optional.empty())); } private static class RequestBuilder implements Supplier<Request> { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json index c8ab8a92583..4dfd6dcfaad 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json @@ -13,9 +13,6 @@ "name": "ClusterInfoMaintainer" }, { - "name": "ClusterUtilizationMaintainer" - }, - { "name": "ContactInformationMaintainer" }, { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/application-roles.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/application-roles.json index e23ab918135..45a5df5f6ce 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/application-roles.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/application-roles.json @@ -10,7 +10,6 @@ "users": [ { "name": "owner@tenant", - "email":"owner@tenant", "roles": { "applicationAdmin": { "explicit": false, @@ -32,7 +31,6 @@ }, { "name": "operator@tenant", - "email":"operator@tenant", "roles": { "applicationAdmin": { "explicit": true, @@ -54,7 +52,6 @@ }, { "name": "reader@app", - "email":"reader@app", "roles": { "applicationAdmin": { "explicit": false, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-roles.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-roles.json index fa528fe2ab7..74e5196db6e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-roles.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/user/responses/tenant-roles.json @@ -8,7 +8,6 @@ "users": [ { "name": "owner@tenant", - "email":"owner@tenant", "roles": { "tenantOwner": { "explicit": true, @@ -26,7 +25,6 @@ }, { "name": "operator@tenant", - "email":"operator@tenant", "roles": { "tenantOwner": { "explicit": false, |