summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@yahooinc.com>2023-06-29 14:23:41 +0200
committerØyvind Grønnesby <oyving@yahooinc.com>2023-06-29 15:31:24 +0200
commitb4126b644d2214564a9ed76c1c006b09454dbb6f (patch)
tree28f2f47539f27890b64508e63368ac696853e614 /controller-server
parent3a066100ef96ffd3ac73d1d06096c98da077f296 (diff)
New maintainer to report usage
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/BillingReportMaintainer.java24
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java6
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json3
4 files changed, 36 insertions, 1 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/BillingReportMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/BillingReportMaintainer.java
new file mode 100644
index 00000000000..d10e38fd990
--- /dev/null
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/BillingReportMaintainer.java
@@ -0,0 +1,24 @@
+// Copyright Yahoo. 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.SystemName;
+import com.yahoo.vespa.hosted.controller.Controller;
+import com.yahoo.vespa.hosted.controller.api.integration.billing.BillingReporter;
+
+import java.time.Duration;
+import java.util.Set;
+
+public class BillingReportMaintainer extends ControllerMaintainer {
+
+ private final BillingReporter reporter;
+
+ public BillingReportMaintainer(Controller controller, Duration interval) {
+ super(controller, interval, null, Set.of(SystemName.PublicCd));
+ this.reporter = controller.serviceRegistry().billingReporter();
+ }
+
+ @Override
+ protected double maintain() {
+ return this.reporter.maintain();
+ }
+}
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 65ca2028c5f..a7d3a37b913 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
@@ -17,7 +17,6 @@ import java.time.temporal.TemporalUnit;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
-import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
@@ -86,6 +85,7 @@ public class ControllerMaintenance extends AbstractComponent {
maintainers.add(new MeteringMonitorMaintainer(controller, intervals.meteringMonitorMaintainer, controller.serviceRegistry().resourceDatabase(), metric));
maintainers.add(new EnclaveAccessMaintainer(controller, intervals.defaultInterval));
maintainers.add(new CertificatePoolMaintainer(controller, metric, intervals.certificatePoolMaintainer, new SecureRandom()));
+ maintainers.add(new BillingReportMaintainer(controller, intervals.billingReportMaintainer));
}
public Upgrader upgrader() { return upgrader; }
@@ -147,6 +147,7 @@ public class ControllerMaintenance extends AbstractComponent {
private final Duration billingDatabaseMaintainer;
private final Duration meteringMonitorMaintainer;
private final Duration certificatePoolMaintainer;
+ private final Duration billingReportMaintainer;
public Intervals(SystemName system) {
this.system = Objects.requireNonNull(system);
@@ -183,6 +184,7 @@ public class ControllerMaintenance extends AbstractComponent {
this.billingDatabaseMaintainer = duration(5, MINUTES);
this.meteringMonitorMaintainer = duration(30, MINUTES);
this.certificatePoolMaintainer = duration(15, MINUTES);
+ this.billingReportMaintainer = duration(60, MINUTES);
}
private Duration duration(long amount, TemporalUnit unit) {
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 02b4d6de5ac..cba620987f0 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
@@ -21,6 +21,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.aws.MockRoleService;
import com.yahoo.vespa.hosted.controller.api.integration.billing.BillingController;
import com.yahoo.vespa.hosted.controller.api.integration.billing.BillingDatabaseClient;
import com.yahoo.vespa.hosted.controller.api.integration.billing.BillingDatabaseClientMock;
+import com.yahoo.vespa.hosted.controller.api.integration.billing.BillingReporter;
import com.yahoo.vespa.hosted.controller.api.integration.billing.MockBillingController;
import com.yahoo.vespa.hosted.controller.api.integration.billing.PlanRegistry;
import com.yahoo.vespa.hosted.controller.api.integration.billing.PlanRegistryMock;
@@ -312,4 +313,9 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
}
public GcpSecretStore gcpSecretStore() { return new NoopGcpSecretStore(); }
+
+ @Override
+ public BillingReporter billingReporter() {
+ return () -> 0.0;
+ }
}
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 7a0316dfec0..eb376a95c74 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
@@ -25,6 +25,9 @@
"name": "BillingDatabaseMaintainer"
},
{
+ "name": "BillingReportMaintainer"
+ },
+ {
"name": "CertificatePoolMaintainer"
},
{