aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-01-04 17:28:03 +0000
committerArne H Juul <arnej@yahooinc.com>2022-01-06 15:24:07 +0000
commit8d48491c1a7e690a5e070d5b996aeacd713ea1c6 (patch)
tree471c4fe403ae2891b7a610daab40198daf613784 /configserver
parent79132191823407316c9d3ab2c255451b9692b248 (diff)
wire legacy overrides to the flag source used
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java6
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/LegacyFlags.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java3
-rw-r--r--configserver/src/test/apps/legacy-flag/schemas/music.sd50
-rw-r--r--configserver/src/test/apps/legacy-flag/services.xml31
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/LegacyFlagsTest.java68
7 files changed, 157 insertions, 6 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
index 687c897c88b..54ceb394ee6 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
@@ -102,7 +102,7 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> {
) {
log.log(Level.FINE, () -> String.format("Loading model version %s for session %s application %s",
modelFactory.version(), applicationGeneration, applicationId));
- ModelContext.Properties modelContextProperties = createModelContextProperties(applicationId);
+ ModelContext.Properties modelContextProperties = createModelContextProperties(applicationId, applicationPackage);
Provisioned provisioned = new Provisioned();
ModelContext modelContext = new ModelContextImpl(
applicationPackage,
@@ -146,14 +146,14 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> {
return Optional.of(value);
}
- private ModelContext.Properties createModelContextProperties(ApplicationId applicationId) {
+ private ModelContext.Properties createModelContextProperties(ApplicationId applicationId, ApplicationPackage applicationPackage) {
return new ModelContextImpl.Properties(applicationId,
configserverConfig,
zone(),
ImmutableSet.copyOf(new ContainerEndpointsCache(TenantRepository.getTenantPath(tenant), curator).read(applicationId)),
false, // We may be bootstrapping, but we only know and care during prepare
false, // Always false, assume no one uses it when activating
- flagSource,
+ LegacyFlags.from(applicationPackage, flagSource),
new EndpointCertificateMetadataStore(curator, TenantRepository.getTenantPath(tenant))
.readEndpointCertificateMetadata(applicationId)
.flatMap(new EndpointCertificateRetriever(secretStore)::readEndpointCertificateSecrets),
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/LegacyFlags.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/LegacyFlags.java
index f4d939387cd..80467c80196 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/LegacyFlags.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/LegacyFlags.java
@@ -15,7 +15,7 @@ import java.util.Map;
*/
public class LegacyFlags {
- public static final String GEO_POSITIONS = "geo-positions";
+ public static final String GEO_POSITIONS = "v7-geo-positions";
public static final String FOO_BAR = "foo-bar"; // for testing
private static FlagSource buildFrom(Map<String, String> legacyOverrides) {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java
index aaacc9f69e0..e4a0fa81f94 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java
@@ -35,6 +35,7 @@ import com.yahoo.vespa.config.server.deploy.ZooKeeperDeployer;
import com.yahoo.vespa.config.server.filedistribution.FileDistributionFactory;
import com.yahoo.vespa.config.server.host.HostValidator;
import com.yahoo.vespa.config.server.http.InvalidApplicationException;
+import com.yahoo.vespa.config.server.modelfactory.LegacyFlags;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.modelfactory.PreparedModelsBuilder;
import com.yahoo.vespa.config.server.provision.HostProvisionerProvider;
@@ -195,7 +196,7 @@ public class SessionPreparer {
Set.copyOf(containerEndpoints),
params.isBootstrap(),
currentActiveApplicationSet.isEmpty(),
- flagSource,
+ LegacyFlags.from(applicationPackage, flagSource),
endpointCertificateSecrets,
athenzDomain,
params.quota(),
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java
index 806b67758c2..6a483c38aee 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java
@@ -10,6 +10,7 @@ import com.yahoo.config.application.api.ComponentInfo;
import com.yahoo.config.application.api.FileRegistry;
import com.yahoo.config.application.api.UnparsedConfigDefinition;
import com.yahoo.config.codegen.DefParser;
+import com.yahoo.config.model.application.AbstractApplicationPackage;
import com.yahoo.config.provision.AllocatedHosts;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.serialization.AllocatedHostsSerializer;
@@ -44,7 +45,7 @@ import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.USERAPP_ZK_S
*
* @author Tony Vaagenes
*/
-public class ZKApplicationPackage implements ApplicationPackage {
+public class ZKApplicationPackage extends AbstractApplicationPackage {
private final ZKApplication zkApplication;
diff --git a/configserver/src/test/apps/legacy-flag/schemas/music.sd b/configserver/src/test/apps/legacy-flag/schemas/music.sd
new file mode 100644
index 00000000000..f4b11d1e8e4
--- /dev/null
+++ b/configserver/src/test/apps/legacy-flag/schemas/music.sd
@@ -0,0 +1,50 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+# A basic search definition - called music, should be saved to music.sd
+search music {
+
+ # It contains one document type only - called music as well
+ document music {
+
+ field title type string {
+ indexing: summary | index # How this field should be indexed
+ # index-to: title, default # Create two indexes
+ weight: 75 # Ranking importancy of this field, used by the built in nativeRank feature
+ }
+
+ field artist type string {
+ indexing: summary | attribute | index
+ # index-to: artist, default
+
+ weight: 25
+ }
+
+ field year type int {
+ indexing: summary | attribute
+ }
+
+ # Increase query
+ field popularity type int {
+ indexing: summary | attribute
+ }
+
+ field url type uri {
+ indexing: summary | index
+ }
+
+ }
+
+ rank-profile default inherits default {
+ first-phase {
+ expression: nativeRank(title,artist) + attribute(popularity)
+ }
+
+ }
+
+ rank-profile textmatch inherits default {
+ first-phase {
+ expression: nativeRank(title,artist)
+ }
+
+ }
+
+}
diff --git a/configserver/src/test/apps/legacy-flag/services.xml b/configserver/src/test/apps/legacy-flag/services.xml
new file mode 100644
index 00000000000..4c9ac84b4f2
--- /dev/null
+++ b/configserver/src/test/apps/legacy-flag/services.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<services version="1.0">
+
+ <legacy>
+ <v7-geo-positions>false</v7-geo-positions>
+ <foo-bar>true</foo-bar>
+ </legacy>
+
+ <admin version="2.0">
+ <adminserver hostalias="node1"/>
+ <logserver hostalias="node1" />
+ </admin>
+
+ <content version="1.0">
+ <redundancy>1</redundancy>
+ <documents>
+ <document type="music" mode="index"/>
+ </documents>
+ <nodes>
+ <node hostalias="node1" distribution-key="0"/>
+ </nodes>
+ </content>
+
+ <container version="1.0">
+ <nodes>
+ <node hostalias="node1" />
+ </nodes>
+ </container>
+
+</services>
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/LegacyFlagsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/LegacyFlagsTest.java
new file mode 100644
index 00000000000..1bebe9089f1
--- /dev/null
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/LegacyFlagsTest.java
@@ -0,0 +1,68 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.config.server.application;
+
+import com.yahoo.vespa.config.server.modelfactory.LegacyFlags;
+import com.yahoo.cloud.config.ModelConfig;
+import com.yahoo.component.Version;
+import com.yahoo.config.model.application.provider.FilesApplicationPackage;
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.config.provision.ApplicationName;
+import com.yahoo.config.provision.InstanceName;
+import com.yahoo.config.provision.TenantName;
+import com.yahoo.vespa.config.server.ModelStub;
+import com.yahoo.vespa.config.server.ServerCache;
+import com.yahoo.vespa.config.server.monitoring.MetricUpdater;
+import com.yahoo.vespa.config.server.monitoring.Metrics;
+import com.yahoo.vespa.flags.Flags;
+import com.yahoo.vespa.flags.FlagSource;
+import com.yahoo.vespa.flags.InMemoryFlagSource;
+import com.yahoo.vespa.model.VespaModel;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.yahoo.config.ConfigInstance;
+import com.yahoo.vespa.config.ConfigKey;
+import com.yahoo.vespa.config.ConfigDefinitionKey;
+import com.yahoo.vespa.config.buildergen.ConfigDefinition;
+import com.yahoo.document.config.DocumentmanagerConfig;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.util.Optional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author arnej
+ */
+public class LegacyFlagsTest {
+
+ @Test
+ public void testThatLegacyOverridesWork() throws Exception {
+ File testApp = new File("src/test/apps/legacy-flag");
+ var appPkg = FilesApplicationPackage.fromFile(testApp);
+ var flag = Flags.USE_V8_GEO_POSITIONS.bindTo(LegacyFlags.from(appPkg, new InMemoryFlagSource()));
+ assertTrue(flag.value());
+ /* rest here tests that having a "legacy" XML tag doesn't break other things, but without actually using it: */
+ VespaModel model = new VespaModel(appPkg);
+ ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("foo").build();
+ ServerCache cache = new ServerCache();
+ Application app = new Application(model, cache, 1L, new Version(1, 2, 3),
+ new MetricUpdater(Metrics.createTestMetrics(), Metrics.createDimensions(applicationId)), applicationId);
+ assertNotNull(app.getModel());
+ /*
+ // Note: no feature flags active with this code path
+ ConfigDefinitionKey cdk = new ConfigDefinitionKey(DocumentmanagerConfig.CONFIG_DEF_NAME, DocumentmanagerConfig.CONFIG_DEF_NAMESPACE);
+ ConfigDefinition cdd = new ConfigDefinition(cdk.getName(), DocumentmanagerConfig.CONFIG_DEF_SCHEMA);
+ var cfgBuilder = app.getModel().getConfigInstance(new ConfigKey<>(cdk.getName(), "client", cdk.getNamespace()), cdd);
+ assertTrue(cfgBuilder instanceof DocumentmanagerConfig.Builder);
+ var cfg = ((DocumentmanagerConfig.Builder)cfgBuilder).build();
+ // no effect from legacy override seen here:
+ System.out.println("CFG: "+cfg);
+ */
+ }
+
+}