diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-07-16 09:45:26 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-07-16 09:54:12 +0200 |
commit | f820d4442bcf87dcce0b17db81a638db21404fa1 (patch) | |
tree | f7f72f7de6459b3f6d41aa3e300278b0a28e273a | |
parent | 51d3f222baeb36bfbec3e1d56016b68d129f82b0 (diff) |
Remove unused method from CloudEventFetcher
9 files changed, 45 insertions, 59 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java index fdd66c037d9..4714b74ba94 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.api.integration; import com.yahoo.vespa.hosted.controller.api.integration.archive.ArchiveService; import com.yahoo.vespa.hosted.controller.api.integration.athenz.AccessControlService; import com.yahoo.vespa.hosted.controller.api.integration.aws.RoleService; -import com.yahoo.vespa.hosted.controller.api.integration.aws.AwsEventFetcher; +import com.yahoo.vespa.hosted.controller.api.integration.aws.CloudEventFetcher; import com.yahoo.vespa.hosted.controller.api.integration.aws.ResourceTagger; import com.yahoo.vespa.hosted.controller.api.integration.billing.BillingController; import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificateProvider; @@ -68,7 +68,7 @@ public interface ServiceRegistry { CostReportConsumer costReportConsumer(); - AwsEventFetcher eventFetcherService(); + CloudEventFetcher eventFetcherService(); ArtifactRepository artifactRepository(); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsEventFetcher.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/CloudEventFetcher.java index 42c7e3c2590..1085897f22b 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsEventFetcher.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/CloudEventFetcher.java @@ -1,16 +1,13 @@ // Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.aws; -import com.yahoo.vespa.hosted.controller.api.integration.organization.Issue; - import java.util.List; /** * @author freva */ -public interface AwsEventFetcher { +public interface CloudEventFetcher { - List<CloudEvent> getEvents(String awsRegionName); - Issue createIssue(CloudEvent event); + List<CloudEvent> getEvents(String regionName); } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockAwsEventFetcher.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockAwsEventFetcher.java deleted file mode 100644 index 056d5bec223..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockAwsEventFetcher.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.aws; - -import com.yahoo.vespa.hosted.controller.api.integration.organization.Issue; -import com.yahoo.vespa.hosted.controller.api.integration.organization.User; - -import java.util.List; -import java.util.Map; -import java.util.HashMap; -import java.util.ArrayList; -import java.util.Optional; - -/** - * @author freva - */ -public class MockAwsEventFetcher implements AwsEventFetcher { - - private final Map<String, List<CloudEvent>> mockedEvents = new HashMap<>(); - - @Override - public List<CloudEvent> getEvents(String awsRegionName) { - return mockedEvents.getOrDefault(awsRegionName, new ArrayList<>()); - } - - @Override - public Issue createIssue(CloudEvent event) { - return new Issue("summary", event.affectedInstances.toString(), "VESPA", Optional.empty()).with(User.from(event.awsRegionName)); - } - - public void addEvent(String awsRegionName, CloudEvent cloudEvent) { - mockedEvents.computeIfAbsent(awsRegionName, i -> new ArrayList<>()).add(cloudEvent); - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockCloudEventFetcher.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockCloudEventFetcher.java new file mode 100644 index 00000000000..c2d803caaf5 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockCloudEventFetcher.java @@ -0,0 +1,25 @@ +// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.aws; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author freva + */ +public class MockCloudEventFetcher implements CloudEventFetcher { + + private final Map<String, List<CloudEvent>> mockedEvents = new HashMap<>(); + + @Override + public List<CloudEvent> getEvents(String regionName) { + return mockedEvents.getOrDefault(regionName, new ArrayList<>()); + } + + public void addEvent(String regionName, CloudEvent cloudEvent) { + mockedEvents.computeIfAbsent(regionName, i -> new ArrayList<>()).add(cloudEvent); + } + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventTracker.java index a8089555ffc..2758eb52608 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventReporter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventTracker.java @@ -5,7 +5,7 @@ import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.text.Text; 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.CloudEventFetcher; import com.yahoo.vespa.hosted.controller.api.integration.aws.CloudEvent; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository; @@ -17,21 +17,19 @@ import java.util.logging.Logger; import java.util.stream.Collectors; /** - * Automatically fetches and handles scheduled events from AWS: - * 1. Deprovisions the affected hosts if applicable - * 2. Submits an issue detailing the event if some hosts are not processed by 1. + * This tracks maintenance events from cloud providers and deprovisions any affected hosts. * * @author mgimle */ -public class CloudEventReporter extends ControllerMaintainer { +public class CloudEventTracker extends ControllerMaintainer { - private static final Logger log = Logger.getLogger(CloudEventReporter.class.getName()); + private static final Logger log = Logger.getLogger(CloudEventTracker.class.getName()); - private final AwsEventFetcher eventFetcher; + private final CloudEventFetcher eventFetcher; private final Map<String, List<ZoneApi>> zonesByCloudNativeRegion; private final NodeRepository nodeRepository; - CloudEventReporter(Controller controller, Duration interval) { + CloudEventTracker(Controller controller, Duration interval) { super(controller, interval); this.eventFetcher = controller.serviceRegistry().eventFetcherService(); this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); 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 668ca0f4ee1..924116e04c0 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 @@ -57,7 +57,7 @@ public class ControllerMaintenance extends AbstractComponent { maintainers.add(new NameServiceDispatcher(controller, intervals.nameServiceDispatcher)); maintainers.add(new CostReportMaintainer(controller, intervals.costReportMaintainer, controller.serviceRegistry().costReportConsumer())); maintainers.add(new ResourceMeterMaintainer(controller, intervals.resourceMeterMaintainer, metric, controller.serviceRegistry().meteringService())); - maintainers.add(new CloudEventReporter(controller, intervals.cloudEventReporter)); + maintainers.add(new CloudEventTracker(controller, intervals.cloudEventReporter)); maintainers.add(new ResourceTagMaintainer(controller, intervals.resourceTagMaintainer, controller.serviceRegistry().resourceTagger())); maintainers.add(new SystemRoutingPolicyMaintainer(controller, intervals.systemRoutingPolicyMaintainer)); maintainers.add(new ApplicationMetaDataGarbageCollector(controller, intervals.applicationMetaDataGarbageCollector)); 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 a4ce0316e25..6ddf0ec76ed 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 @@ -13,7 +13,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.athenz.AccessControlSer import com.yahoo.vespa.hosted.controller.api.integration.athenz.MockAccessControlService; import com.yahoo.vespa.hosted.controller.api.integration.aws.MockRoleService; import com.yahoo.vespa.hosted.controller.api.integration.aws.RoleService; -import com.yahoo.vespa.hosted.controller.api.integration.aws.MockAwsEventFetcher; +import com.yahoo.vespa.hosted.controller.api.integration.aws.MockCloudEventFetcher; import com.yahoo.vespa.hosted.controller.api.integration.aws.MockResourceTagger; import com.yahoo.vespa.hosted.controller.api.integration.aws.ResourceTagger; import com.yahoo.vespa.hosted.controller.api.integration.billing.BillingController; @@ -63,7 +63,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg private final MemoryEntityService memoryEntityService = new MemoryEntityService(); private final DummySystemMonitor systemMonitor = new DummySystemMonitor(); private final CostReportConsumerMock costReportConsumerMock = new CostReportConsumerMock(); - private final MockAwsEventFetcher mockAwsEventFetcher = new MockAwsEventFetcher(); + private final MockCloudEventFetcher mockAwsEventFetcher = new MockCloudEventFetcher(); private final ArtifactRepositoryMock artifactRepositoryMock = new ArtifactRepositoryMock(); private final MockTesterCloud mockTesterCloud; private final ApplicationStoreMock applicationStoreMock = new ApplicationStoreMock(); @@ -159,7 +159,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg } @Override - public MockAwsEventFetcher eventFetcherService() { + public MockCloudEventFetcher eventFetcherService() { return mockAwsEventFetcher; } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventTrackerTest.java index bb10f29de72..17852547a0b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventTrackerTest.java @@ -6,7 +6,7 @@ import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.integration.aws.CloudEvent; -import com.yahoo.vespa.hosted.controller.api.integration.aws.MockAwsEventFetcher; +import com.yahoo.vespa.hosted.controller.api.integration.aws.MockCloudEventFetcher; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock; import org.junit.Test; @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; /** * @author olaa */ -public class CloudEventReporterTest { +public class CloudEventTrackerTest { private final ControllerTester tester = new ControllerTester(); private final ZoneApiMock unsupportedZone = createZone("prod.zone3", "region-1", "other"); @@ -41,20 +41,20 @@ public class CloudEventReporterTest { @Test public void maintain() { setUpZones(); - CloudEventReporter cloudEventReporter = new CloudEventReporter(tester.controller(), Duration.ofMinutes(15)); + CloudEventTracker cloudEventTracker = new CloudEventTracker(tester.controller(), Duration.ofMinutes(15)); assertEquals(Set.of("host1.com", "host2.com", "host3.com"), hostsNotDeprovisioning(unsupportedZone.getId())); assertEquals(Set.of("host1.com", "host2.com", "host3.com"), hostsNotDeprovisioning(zone1.getId())); assertEquals(Set.of("host4.com", "host5.com", "confighost.com"), hostsNotDeprovisioning(zone2.getId())); mockEvents(); - cloudEventReporter.maintain(); + cloudEventTracker.maintain(); assertEquals(Set.of("host1.com", "host2.com", "host3.com"), hostsNotDeprovisioning(unsupportedZone.getId())); assertEquals(Set.of("host3.com"), hostsNotDeprovisioning(zone1.getId())); assertEquals(Set.of("host4.com"), hostsNotDeprovisioning(zone2.getId())); } private void mockEvents() { - MockAwsEventFetcher eventFetcher = (MockAwsEventFetcher) tester.controller().serviceRegistry().eventFetcherService(); + MockCloudEventFetcher eventFetcher = (MockCloudEventFetcher) tester.controller().serviceRegistry().eventFetcherService(); Date date = new Date(); CloudEvent event1 = new CloudEvent("event 1", 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 3a7e6e63574..be51312186b 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 @@ -16,7 +16,7 @@ "name": "ChangeRequestMaintainer" }, { - "name": "CloudEventReporter" + "name": "CloudEventTracker" }, { "name": "CloudTrialExpirer" |