aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authormgimle <michael@gimle.io>2019-07-30 15:47:32 +0200
committermgimle <michael@gimle.io>2019-07-30 17:21:03 +0200
commit83e11b2d7824d584decc4f0f500d752c0703971f (patch)
tree861ed321b54f5fc30b7093deaada8aeab0b598bc /controller-server
parent9ede6b50bed9d10d096fc7d4fbbfebb49c3ca96b (diff)
Implemented the AwsEventFetcher, which automatically submits a ticket to JIRA containing details whenever there is an instance event at AWS.
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/AwsEventReporterMaintainer.java51
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java13
2 files changed, 59 insertions, 5 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/AwsEventReporterMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/AwsEventReporterMaintainer.java
new file mode 100644
index 00000000000..6a0c44f686a
--- /dev/null
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/AwsEventReporterMaintainer.java
@@ -0,0 +1,51 @@
+package com.yahoo.vespa.hosted.controller.maintenance;
+
+import com.yahoo.config.provision.CloudName;
+import com.yahoo.config.provision.zone.ZoneList;
+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.aws.CloudEvent;
+import com.yahoo.vespa.hosted.controller.api.integration.organization.Issue;
+import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueHandler;
+
+import java.time.Duration;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class AwsEventReporterMaintainer extends Maintainer {
+ private static final Logger log = Logger.getLogger(AwsEventReporterMaintainer.class.getName());
+
+ private final IssueHandler issueHandler;
+ private final AwsEventFetcher eventFetcher;
+ private final ZoneList cloudZones;
+
+ AwsEventReporterMaintainer(Controller controller, Duration interval, JobControl jobControl,
+ IssueHandler issueHandler, AwsEventFetcher eventFetcher) {
+ super(controller, interval, jobControl);
+ this.cloudZones = awsZones(controller);
+ this.issueHandler = issueHandler;
+ this.eventFetcher = eventFetcher;
+ }
+
+ private ZoneList awsZones(Controller controller) {
+ return controller.zoneRegistry().zones()
+ .ofCloud(CloudName.from("aws"))
+ .reachable();
+ }
+
+ @Override
+ protected void maintain() {
+ log.log(Level.INFO, "Fetching events for cloud hosts.");
+ for (var cloudZoneId : cloudZones.ids()) {
+ List<CloudEvent> events = eventFetcher.getEvents(eventFetcher.zoneToAwsRegion(cloudZoneId));
+ for (var event : events) {
+ Issue issue = eventFetcher.createIssue(event);
+ if (!issueHandler.issueExists(issue)) {
+ issueHandler.file(issue);
+ log.log(Level.INFO, String.format("Filed an issue with the title '%s'", issue.summary()));
+ }
+ }
+ }
+ }
+}
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 116ea532a11..0a894a1031f 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
@@ -5,12 +5,10 @@ import com.yahoo.component.AbstractComponent;
import com.yahoo.config.provision.zone.ZoneApi;
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.configserver.NodeRepository;
import com.yahoo.vespa.hosted.controller.api.integration.dns.NameService;
-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.OwnershipIssues;
+import com.yahoo.vespa.hosted.controller.api.integration.organization.*;
import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceSnapshotConsumer;
import com.yahoo.vespa.hosted.controller.authority.config.ApiAuthorityConfig;
import com.yahoo.vespa.hosted.controller.maintenance.config.MaintainerConfig;
@@ -55,6 +53,7 @@ public class ControllerMaintenance extends AbstractComponent {
private final ResourceMeterMaintainer resourceMeterMaintainer;
private final NameServiceDispatcher nameServiceDispatcher;
private final BillingMaintainer billingMaintainer;
+ private final AwsEventReporterMaintainer awsEventReporterMaintainer;
@SuppressWarnings("unused") // instantiated by Dependency Injection
public ControllerMaintenance(MaintainerConfig maintainerConfig, ApiAuthorityConfig apiAuthorityConfig, Controller controller, CuratorDb curator,
@@ -65,7 +64,9 @@ public class ControllerMaintenance extends AbstractComponent {
CostReportConsumer reportConsumer,
ResourceSnapshotConsumer resourceSnapshotConsumer,
Billing billing,
- SelfHostedCostConfig selfHostedCostConfig) {
+ SelfHostedCostConfig selfHostedCostConfig,
+ IssueHandler issueHandler,
+ AwsEventFetcher awsEventFetcher) {
Duration maintenanceInterval = Duration.ofMinutes(maintainerConfig.intervalMinutes());
this.jobControl = jobControl;
deploymentExpirer = new DeploymentExpirer(controller, maintenanceInterval, jobControl);
@@ -88,6 +89,7 @@ public class ControllerMaintenance extends AbstractComponent {
resourceMeterMaintainer = new ResourceMeterMaintainer(controller, Duration.ofMinutes(60), jobControl, nodeRepository, Clock.systemUTC(), metric, resourceSnapshotConsumer);
nameServiceDispatcher = new NameServiceDispatcher(controller, Duration.ofSeconds(10), jobControl, nameService);
billingMaintainer = new BillingMaintainer(controller, Duration.ofDays(3), jobControl, billing);
+ awsEventReporterMaintainer = new AwsEventReporterMaintainer(controller, Duration.ofDays(1), jobControl, issueHandler, awsEventFetcher);
}
public Upgrader upgrader() { return upgrader; }
@@ -117,6 +119,7 @@ public class ControllerMaintenance extends AbstractComponent {
resourceMeterMaintainer.deconstruct();
nameServiceDispatcher.deconstruct();
billingMaintainer.deconstruct();
+ awsEventReporterMaintainer.deconstruct();
}
/** Create one OS upgrader per cloud found in the zone registry of controller */