summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@yahooinc.com>2023-07-25 11:28:08 +0200
committerGitHub <noreply@github.com>2023-07-25 11:28:08 +0200
commit91838767dcbb3e044e5bf06165d12b84891aa191 (patch)
treee43d0249905f7b8b15e948f8d90e2d93173045f6 /controller-server
parent54e59e36e7487142ded21fa56e844b639b45a7de (diff)
parentd678b4e8fe80c25118fd5aa1cf6353ef7a327eb7 (diff)
Merge pull request #27582 from vespa-engine/ogronnesby/billing-reporting
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.java3
-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, 0 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 84746887d54..fa67e20f53f 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
@@ -84,6 +84,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));
+ maintainers.add(new BillingReportMaintainer(controller, intervals.billingReportMaintainer));
}
public Upgrader upgrader() { return upgrader; }
@@ -145,6 +146,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);
@@ -181,6 +183,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 d90344ceb1f..f2c827478c0 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"
},
{