diff options
author | andreer <andreer@verizonmedia.com> | 2021-05-07 12:05:52 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerij92@gmail.com> | 2021-05-07 13:19:40 +0200 |
commit | fc2143cf9a43df57bea11cdac3a92905170e1fa1 (patch) | |
tree | 6c6a7ffb68c025174ad36796d813de150c81d892 /controller-server | |
parent | 69a56ad6265b1bc1a1d330580a5795c0f48e9eb5 (diff) |
remove SYNC_HOST_LOGS_TO_S3_BUCKET feature flag
Diffstat (limited to 'controller-server')
5 files changed, 12 insertions, 37 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java index 39d1fe1da57..bb38dd612db 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDb.java @@ -3,9 +3,6 @@ package com.yahoo.vespa.hosted.controller.archive; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.flags.FetchVector; -import com.yahoo.vespa.flags.Flags; -import com.yahoo.vespa.flags.StringFlag; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.archive.ArchiveBucket; import com.yahoo.vespa.hosted.controller.api.integration.archive.ArchiveService; @@ -42,25 +39,20 @@ public class CuratorArchiveBucketDb { private final ArchiveService archiveService; private final CuratorDb curatorDb; - private final StringFlag bucketNameFlag; + private final boolean enabled; public CuratorArchiveBucketDb(Controller controller) { this.archiveService = controller.serviceRegistry().archiveService(); this.curatorDb = controller.curator(); - this.bucketNameFlag = Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.bindTo(controller.flagSource()); + this.enabled = controller.zoneRegistry().system().isPublic(); } public Optional<URI> archiveUriFor(ZoneId zoneId, TenantName tenant) { - String bucketName = bucketNameFlag - .with(FetchVector.Dimension.ZONE_ID, zoneId.value()) - .with(FetchVector.Dimension.TENANT_ID, tenant.value()) - .value(); - - if (bucketName.isBlank()) return Optional.empty(); - - if ("auto".equals(bucketName)) bucketName = findOrAssignBucket(zoneId, tenant); - - return Optional.of(URI.create(String.format("s3://%s/%s/", bucketName, tenant.value()))); + if (enabled) { + return Optional.of(URI.create(String.format("s3://%s/%s/", findOrAssignBucket(zoneId, tenant), tenant.value()))); + } else { + return Optional.empty(); + } } private String findOrAssignBucket(ZoneId zoneId, TenantName tenant) { @@ -125,5 +117,4 @@ public class CuratorArchiveBucketDb { .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)); archiveUriCache.put(zoneId, bucketNameByTenant); } - } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDbTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDbTest.java index 57fa7cc8e44..19b56c2d39e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDbTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/archive/CuratorArchiveBucketDbTest.java @@ -1,11 +1,11 @@ package com.yahoo.vespa.hosted.controller.archive; +import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.flags.Flags; -import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.integration.archive.ArchiveBucket; +import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock; import org.apache.curator.shaded.com.google.common.collect.Streams; import org.junit.Test; @@ -23,21 +23,13 @@ public class CuratorArchiveBucketDbTest { @Test public void archiveUriFor() { ControllerTester tester = new ControllerTester(); - InMemoryFlagSource flagSource = (InMemoryFlagSource) tester.controller().flagSource(); + ((ZoneRegistryMock) tester.controller().zoneRegistry()).setSystemName(SystemName.Public); CuratorArchiveBucketDb bucketDb = new CuratorArchiveBucketDb(tester.controller()); tester.curator().writeArchiveBuckets(ZoneId.defaultId(), Set.of(new ArchiveBucket("existingBucket", "keyArn").withTenant(TenantName.defaultName()))); - // Nothing when feature flag is not set. - assertEquals(Optional.empty(), bucketDb.archiveUriFor(ZoneId.defaultId(), TenantName.defaultName())); - - // Returns hardcoded name from feature flag - flagSource.withStringFlag(Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.id(), "hardcoded"); - assertEquals(Optional.of(URI.create("s3://hardcoded/default/")), bucketDb.archiveUriFor(ZoneId.defaultId(), TenantName.defaultName())); - - // Finds existing bucket in db when set to "auto" - flagSource.withStringFlag(Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.id(), "auto"); + // Finds existing bucket in db assertEquals(Optional.of(URI.create("s3://existingBucket/default/")), bucketDb.archiveUriFor(ZoneId.defaultId(), TenantName.defaultName())); // Assigns to existing bucket while there is space diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArchiveAccessMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArchiveAccessMaintainerTest.java index 56247b04ac6..73e9362eaf8 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArchiveAccessMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArchiveAccessMaintainerTest.java @@ -33,8 +33,7 @@ public class ArchiveAccessMaintainerTest extends ControllerContainerCloudTest { public void grantsRoleAccess() { var containerTester = new ContainerTester(container, ""); ((InMemoryFlagSource) containerTester.controller().flagSource()) - .withBooleanFlag(PermanentFlags.ENABLE_PUBLIC_SIGNUP_FLOW.id(), true) - .withStringFlag(Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.id(), "auto"); + .withBooleanFlag(PermanentFlags.ENABLE_PUBLIC_SIGNUP_FLOW.id(), true); var tester = new ControllerTester(containerTester); String tenant1role = "arn:aws:iam::123456789012:role/my-role"; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArchiveUriUpdaterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArchiveUriUpdaterTest.java index 505536558ab..2bcedf6b659 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArchiveUriUpdaterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ArchiveUriUpdaterTest.java @@ -5,8 +5,6 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.flags.Flags; -import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.hosted.controller.api.integration.archive.ArchiveBucket; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; @@ -20,7 +18,6 @@ import java.net.URI; import java.time.Duration; import java.util.LinkedHashSet; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; @@ -36,9 +33,6 @@ public class ArchiveUriUpdaterTest { public void archive_uri_test() { var updater = new ArchiveUriUpdater(tester.controller(), Duration.ofDays(1)); - ((InMemoryFlagSource) tester.controller().flagSource()) - .withStringFlag(Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.id(), "auto"); - var tenant1 = TenantName.from("tenant1"); var tenant2 = TenantName.from("tenant2"); var tenantInfra = SystemApplication.TENANT; 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 69cc2512aef..31a3b5ff1cf 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 @@ -156,7 +156,6 @@ public class ApplicationApiTest extends ControllerContainerTest { @Test public void testApplicationApi() { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); // (Necessary but not provided in this API) - ((InMemoryFlagSource) tester.controller().flagSource()).withStringFlag(Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.id(), "my-bucket"); // GET API root tester.assertResponse(request("/application/v4/", GET).userIdentity(USER_ID), |