diff options
6 files changed, 40 insertions, 18 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index 5c3c43461dc..9b64e27e3da 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -20,6 +20,7 @@ import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.curator.Lock; import com.yahoo.vespa.flags.FetchVector; import com.yahoo.vespa.flags.FlagSource; +import com.yahoo.vespa.flags.ListFlag; import com.yahoo.vespa.flags.PermanentFlags; import com.yahoo.vespa.flags.StringFlag; import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeploymentData; @@ -123,6 +124,7 @@ public class ApplicationController { private final ApplicationPackageValidator applicationPackageValidator; private final EndpointCertificates endpointCertificates; private final StringFlag dockerImageRepoFlag; + private final ListFlag<Integer> incompatibleMajorVersions; private final BillingController billingController; ApplicationController(Controller controller, CuratorDb curator, AccessControl accessControl, Clock clock, @@ -137,6 +139,7 @@ public class ApplicationController { artifactRepository = controller.serviceRegistry().artifactRepository(); applicationStore = controller.serviceRegistry().applicationStore(); dockerImageRepoFlag = PermanentFlags.DOCKER_IMAGE_REPO.bindTo(flagSource); + incompatibleMajorVersions = PermanentFlags.INCOMPATIBLE_MAJOR_VERSIONS.bindTo(flagSource); deploymentTrigger = new DeploymentTrigger(controller, clock); applicationPackageValidator = new ApplicationPackageValidator(controller); endpointCertificates = new EndpointCertificates(controller, @@ -751,6 +754,10 @@ public class ApplicationController { return curator.lockForDeployment(application, zone); } + public List<Integer> incompatibleMajorVersions() { + return incompatibleMajorVersions.value(); + } + /** * Verifies that the application can be deployed to the tenant, following these rules: * diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/InstanceList.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/InstanceList.java index 91e80eb8a30..0b4c3e9dff8 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/InstanceList.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/InstanceList.java @@ -34,12 +34,12 @@ public class InstanceList extends AbstractFilteringList<ApplicationId, InstanceL } /** - * Returns the subset of instances that aren't pinned to an an earlier major version than the given one. + * Returns the subset of instances that aren't pinned to an earlier major version than the given one. * * @param targetMajorVersion the target major version which applications returned allows upgrading to * @param defaultMajorVersion the default major version to assume for applications not specifying one */ - public InstanceList allowMajorVersion(int targetMajorVersion, int defaultMajorVersion) { + public InstanceList allowingMajorVersion(int targetMajorVersion, int defaultMajorVersion) { return matching(id -> targetMajorVersion <= application(id).deploymentSpec().majorVersion() .orElse(application(id).majorVersion() .orElse(defaultMajorVersion))); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java index 647b52f7d51..623fcfa2d94 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -59,7 +59,6 @@ import static com.yahoo.vespa.hosted.controller.deployment.Step.endStagingSetup; import static com.yahoo.vespa.hosted.controller.deployment.Step.endTests; import static com.yahoo.vespa.hosted.controller.deployment.Step.report; import static java.time.temporal.ChronoUnit.SECONDS; -import static java.util.Comparator.naturalOrder; import static java.util.function.Predicate.not; import static java.util.logging.Level.INFO; import static java.util.stream.Collectors.toList; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java index 5cf55930274..4b46d7777e7 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java @@ -17,6 +17,7 @@ import com.yahoo.vespa.athenz.api.AthenzDomain; import com.yahoo.vespa.athenz.api.AthenzPrincipal; import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.athenz.api.OAuthCredentials; +import com.yahoo.vespa.flags.FlagSource; import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.flags.PermanentFlags; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; @@ -92,6 +93,7 @@ public final class ControllerTester { private final ServiceRegistryMock serviceRegistry; private final CuratorDb curator; private final RotationsConfig rotationsConfig; + private final InMemoryFlagSource flagSource; private final AtomicLong nextPropertyId = new AtomicLong(1000); private final AtomicInteger nextProjectId = new AtomicInteger(1000); private final AtomicInteger nextDomainId = new AtomicInteger(1000); @@ -126,15 +128,17 @@ public final class ControllerTester { this(new AthenzDbMock(), new MockCuratorDb(), defaultRotationsConfig(), new ServiceRegistryMock(system)); } - private ControllerTester(AthenzDbMock athenzDb, boolean inContainer, - CuratorDb curator, RotationsConfig rotationsConfig, - ServiceRegistryMock serviceRegistry, Controller controller) { + private ControllerTester(AthenzDbMock athenzDb, boolean inContainer, CuratorDb curator, + RotationsConfig rotationsConfig, ServiceRegistryMock serviceRegistry, + InMemoryFlagSource flagSource, Controller controller) { this.athenzDb = athenzDb; this.inContainer = inContainer; this.clock = serviceRegistry.clock(); this.serviceRegistry = serviceRegistry; this.curator = curator; this.rotationsConfig = rotationsConfig; + this.flagSource = flagSource.withBooleanFlag(PermanentFlags.ENABLE_PUBLIC_SIGNUP_FLOW.id(), true) + .withListFlag(PermanentFlags.INCOMPATIBLE_MAJOR_VERSIONS.id(), List.of(), Integer.class); this.controller = controller; // Make root logger use time from manual clock @@ -148,8 +152,14 @@ public final class ControllerTester { private ControllerTester(AthenzDbMock athenzDb, CuratorDb curator, RotationsConfig rotationsConfig, ServiceRegistryMock serviceRegistry) { - this(athenzDb, false, curator, rotationsConfig, serviceRegistry, - createController(curator, rotationsConfig, athenzDb, serviceRegistry)); + this(athenzDb, curator, rotationsConfig, serviceRegistry, new InMemoryFlagSource()); + } + + private ControllerTester(AthenzDbMock athenzDb, + CuratorDb curator, RotationsConfig rotationsConfig, + ServiceRegistryMock serviceRegistry, InMemoryFlagSource flagSource) { + this(athenzDb, false, curator, rotationsConfig, serviceRegistry, flagSource, + createController(curator, rotationsConfig, athenzDb, serviceRegistry, flagSource)); } /** Creates a ControllerTester built on the ContainerTester's controller. This controller can not be recreated. */ @@ -159,6 +169,7 @@ public final class ControllerTester { tester.controller().curator(), null, tester.serviceRegistry(), + tester.flagSource(), tester.controller()); } @@ -217,10 +228,10 @@ public final class ControllerTester { } /** Create a new controller instance. Useful to verify that controller state is rebuilt from persistence */ - public final void createNewController() { + public void createNewController() { if (inContainer) throw new UnsupportedOperationException("Cannot recreate this controller"); - controller = createController(curator, rotationsConfig, athenzDb, serviceRegistry); + controller = createController(curator, rotationsConfig, athenzDb, serviceRegistry, flagSource); } /** Upgrade controller to given version */ @@ -373,9 +384,8 @@ public final class ControllerTester { private static Controller createController(CuratorDb curator, RotationsConfig rotationsConfig, AthenzDbMock athensDb, - ServiceRegistryMock serviceRegistry) { - InMemoryFlagSource flagSource = new InMemoryFlagSource() - .withBooleanFlag(PermanentFlags.ENABLE_PUBLIC_SIGNUP_FLOW.id(), true); + ServiceRegistryMock serviceRegistry, + FlagSource flagSource) { Controller controller = new Controller(curator, rotationsConfig, serviceRegistry.zoneRegistry().system().isPublic() ? diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java index 6165c2b8ca8..ca27e9d23cd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java @@ -12,6 +12,7 @@ import com.yahoo.jdisc.http.filter.SecurityRequestFilterChain; import com.yahoo.test.json.JsonTestHelper; import com.yahoo.vespa.athenz.api.AthenzDomain; import com.yahoo.vespa.athenz.api.AthenzIdentity; +import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.athenz.ApplicationAction; import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactoryMock; @@ -54,6 +55,10 @@ public class ContainerTester { return (AthenzClientFactoryMock) container.components().getComponent(AthenzClientFactoryMock.class.getName()); } + public InMemoryFlagSource flagSource() { + return (InMemoryFlagSource) container.components().getComponent(InMemoryFlagSource.class.getName()); + } + public ServiceRegistryMock serviceRegistry() { return (ServiceRegistryMock) container.components().getComponent(ServiceRegistryMock.class.getName()); } @@ -110,8 +115,8 @@ public class ContainerTester { .replaceAll("\"?\\(ignore\\)\"?", "\\\\E" + stopCharacters + "*\\\\Q"); if (!Pattern.matches(expectedResponsePattern, responseString)) { - throw new ComparisonFailure(responseFile.toString() + " (with ignored fields)", - expectedResponsePattern, responseString); + throw new ComparisonFailure(responseFile + " (with ignored fields)", + expectedResponsePattern, responseString); } } else { if (compareJson) { @@ -210,5 +215,4 @@ public class ContainerTester { public interface ConsumerThrowingException<T> { void accept(T t) throws Exception; } -} - +}
\ No newline at end of file diff --git a/flags/src/main/java/com/yahoo/vespa/flags/InMemoryFlagSource.java b/flags/src/main/java/com/yahoo/vespa/flags/InMemoryFlagSource.java index 9a69adfc1a6..d21e21b44c8 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/InMemoryFlagSource.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/InMemoryFlagSource.java @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.flags; +import com.yahoo.component.AbstractComponent; + import java.util.List; import java.util.Map; import java.util.Optional; @@ -14,7 +16,7 @@ import java.util.concurrent.ConcurrentHashMap; * * @author freva */ -public class InMemoryFlagSource implements FlagSource { +public class InMemoryFlagSource extends AbstractComponent implements FlagSource { private final Map<FlagId, RawFlag> rawFlagsById = new ConcurrentHashMap<>(); public InMemoryFlagSource withBooleanFlag(FlagId flagId, boolean value) { |