diff options
author | Geir Storli <geirst@verizonmedia.com> | 2021-01-27 13:06:20 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2021-01-27 13:06:20 +0000 |
commit | 560775c77738107f6dfea173d05d74faf2e33079 (patch) | |
tree | e16165f1d69b157ead28c0686fd60d62ac300520 | |
parent | 1c89aaceb7279f8c6b7c1aa0259292ce19a74b69 (diff) |
Add feature flag for enabling blocking of feed in the distributor.
6 files changed, 59 insertions, 10 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java index a90fe9ebfb7..a9a83386573 100644 --- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java @@ -83,6 +83,7 @@ public interface ModelContext { @ModelFeatureFlag(owners = {"musum", "mpolden"}, comment = "Revisit in February 2021") default boolean reconfigurableZookeeperServer() { return false; } @ModelFeatureFlag(owners = {"bjorncs", "tokle"}) default boolean enableJdiscConnectionLog() { return false; } @ModelFeatureFlag(owners = {"bjorncs", "tokle", "baldersheim"}) default boolean enableZstdCompressionAccessLog() { return false; } + @ModelFeatureFlag(owners = {"geirst"}) default boolean enableFeedBlockInDistributor() { return false; } } /** Warning: As elsewhere in this package, do not make backwards incompatible changes that will break old config models! */ diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java index 95104391dfd..686cb7ce7c6 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java @@ -52,6 +52,7 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea private boolean enableAutomaticReindexing = false; private boolean reconfigurableZookeeperServer = false; private boolean useBucketExecutorForLidSpaceCompact; + private boolean enableFeedBlockInDistributor = false; @Override public ModelContext.FeatureFlags featureFlags() { return this; } @Override public boolean multitenant() { return multitenant; } @@ -86,6 +87,7 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea @Override public boolean enableAutomaticReindexing() { return enableAutomaticReindexing; } @Override public boolean reconfigurableZookeeperServer() { return reconfigurableZookeeperServer; } @Override public boolean useBucketExecutorForLidSpaceCompact() { return useBucketExecutorForLidSpaceCompact; } + @Override public boolean enableFeedBlockInDistributor() { return enableFeedBlockInDistributor; } public TestProperties setFeedConcurrency(double feedConcurrency) { this.feedConcurrency = feedConcurrency; @@ -195,6 +197,10 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea return this; } + public TestProperties enableFeedBlockInDistributor(boolean enabled) { + enableFeedBlockInDistributor = enabled; + return this; + } public static class Spec implements ConfigServerSpec { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ClusterControllerConfig.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ClusterControllerConfig.java index ad5b472387f..8d6127970c8 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/ClusterControllerConfig.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ClusterControllerConfig.java @@ -39,6 +39,7 @@ public class ClusterControllerConfig extends AbstractConfigProducer<ClusterContr minNodeRatioPerGroup = clusterTuning.childAsDouble("min-node-ratio-per-group"); bucketSplittingMinimumBits = clusterTuning.childAsInteger("bucket-splitting.minimum-bits"); } + boolean enableClusterFeedBlock = deployState.getProperties().featureFlags().enableFeedBlockInDistributor(); if (tuning != null) { return new ClusterControllerConfig(ancestor, clusterName, @@ -49,11 +50,14 @@ public class ClusterControllerConfig extends AbstractConfigProducer<ClusterContr tuning.childAsDouble("min-distributor-up-ratio"), tuning.childAsDouble("min-storage-up-ratio"), bucketSplittingMinimumBits, - minNodeRatioPerGroup - ); + minNodeRatioPerGroup, + enableClusterFeedBlock); } else { - return new ClusterControllerConfig(ancestor, clusterName, null, null, null, null, null, null, - bucketSplittingMinimumBits, minNodeRatioPerGroup); + return new ClusterControllerConfig(ancestor, clusterName, + null, null, null, null, null, null, + bucketSplittingMinimumBits, + minNodeRatioPerGroup, + enableClusterFeedBlock); } } } @@ -67,6 +71,7 @@ public class ClusterControllerConfig extends AbstractConfigProducer<ClusterContr Double minStorageUpRatio; Integer minSplitBits; private Double minNodeRatioPerGroup; + private boolean enableClusterFeedBlock = false; // TODO refactor; too many args private ClusterControllerConfig(AbstractConfigProducer parent, @@ -78,7 +83,8 @@ public class ClusterControllerConfig extends AbstractConfigProducer<ClusterContr Double minDistributorUpRatio, Double minStorageUpRatio, Integer minSplitBits, - Double minNodeRatioPerGroup) { + Double minNodeRatioPerGroup, + boolean enableClusterFeedBlock) { super(parent, "fleetcontroller"); this.clusterName = clusterName; @@ -90,6 +96,7 @@ public class ClusterControllerConfig extends AbstractConfigProducer<ClusterContr this.minStorageUpRatio = minStorageUpRatio; this.minSplitBits = minSplitBits; this.minNodeRatioPerGroup = minNodeRatioPerGroup; + this.enableClusterFeedBlock = enableClusterFeedBlock; } @Override @@ -131,7 +138,7 @@ public class ClusterControllerConfig extends AbstractConfigProducer<ClusterContr if (minNodeRatioPerGroup != null) { builder.min_node_ratio_per_group(minNodeRatioPerGroup); } - + builder.enable_cluster_feed_block(enableClusterFeedBlock); setDefaultClusterFeedBlockLimits(builder); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/FleetControllerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/FleetControllerClusterTest.java index 137f5351299..01bbffce360 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/FleetControllerClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/FleetControllerClusterTest.java @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.content; +import com.yahoo.config.model.deploy.DeployState; +import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.vespa.config.content.FleetcontrollerConfig; import com.yahoo.config.model.test.MockRoot; import com.yahoo.text.XML; @@ -11,13 +13,20 @@ import org.w3c.dom.Document; import static org.junit.Assert.assertEquals; public class FleetControllerClusterTest { - ClusterControllerConfig parse(String xml) { + + private ClusterControllerConfig parse(String xml, boolean enableFeedBlockInDistributor) { Document doc = XML.getDocument(xml); - MockRoot root = new MockRoot(); + var deployState = new DeployState.Builder().properties( + new TestProperties().enableFeedBlockInDistributor(enableFeedBlockInDistributor)).build(); + MockRoot root = new MockRoot("", deployState); return new ClusterControllerConfig.Builder("storage", new ModelElement(doc.getDocumentElement())).build(root.getDeployState(), root, new ModelElement(doc.getDocumentElement()).getXml()); } + private ClusterControllerConfig parse(String xml) { + return parse(xml, false); + } + @Test public void testParameters() { FleetcontrollerConfig.Builder builder = new FleetcontrollerConfig.Builder(); @@ -96,12 +105,27 @@ public class FleetControllerClusterTest { assertEquals(0.89, limits.get("attribute-multi-value"), 0.0001); } - FleetcontrollerConfig getConfigForBasicCluster() { + @Test + public void feature_flag_controls_enable_cluster_feed_block() { + verifyThatFeatureFlagControlsEnableClusterFeedBlock(true); + verifyThatFeatureFlagControlsEnableClusterFeedBlock(false); + } + + private void verifyThatFeatureFlagControlsEnableClusterFeedBlock(boolean flag) { + var config = getConfigForBasicCluster(flag); + assertEquals(flag, config.enable_cluster_feed_block()); + } + + private FleetcontrollerConfig getConfigForBasicCluster(boolean enableFeedBlockInDistributor) { var builder = new FleetcontrollerConfig.Builder(); parse("<cluster id=\"storage\">\n" + " <documents/>\n" + - "</cluster>"). + "</cluster>", enableFeedBlockInDistributor). getConfig(builder); return new FleetcontrollerConfig(builder); } + + private FleetcontrollerConfig getConfigForBasicCluster() { + return getConfigForBasicCluster(false); + } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java index d1be0ec2cce..fa30cb895c0 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java @@ -165,6 +165,7 @@ public class ModelContextImpl implements ModelContext { private final boolean enableJdiscConnectionLog; private final boolean enableZstdCompressionAccessLog; private final boolean useBucketExecutorForLidSpaceCompact; + private final boolean enableFeedBlockInDistributor; public FeatureFlags(FlagSource source, ApplicationId appId) { this.enableAutomaticReindexing = flagValue(source, appId, Flags.ENABLE_AUTOMATIC_REINDEXING); @@ -185,6 +186,7 @@ public class ModelContextImpl implements ModelContext { this.enableJdiscConnectionLog = flagValue(source, appId, Flags.ENABLE_JDISC_CONNECTION_LOG); this.enableZstdCompressionAccessLog = flagValue(source, appId, Flags.ENABLE_ZSTD_COMPRESSION_ACCESS_LOG); this.useBucketExecutorForLidSpaceCompact = flagValue(source, appId, Flags.USE_BUCKET_EXECUTOR_FOR_LID_SPACE_COMPACT); + this.enableFeedBlockInDistributor = flagValue(source, appId, Flags.ENABLE_FEED_BLOCK_IN_DISTRIBUTOR); } @Override public boolean enableAutomaticReindexing() { return enableAutomaticReindexing; } @@ -205,6 +207,7 @@ public class ModelContextImpl implements ModelContext { @Override public boolean enableJdiscConnectionLog() { return enableJdiscConnectionLog; } @Override public boolean enableZstdCompressionAccessLog() { return enableZstdCompressionAccessLog; } @Override public boolean useBucketExecutorForLidSpaceCompact() { return useBucketExecutorForLidSpaceCompact; } + @Override public boolean enableFeedBlockInDistributor() { return enableFeedBlockInDistributor; } private static <V> V flagValue(FlagSource source, ApplicationId appId, UnboundFlag<? extends V, ?, ?> flag) { return flag.bindTo(source) diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java index 6389d1811fc..7ae49d3eb66 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java @@ -318,6 +318,14 @@ public class Flags { "Use EndpointCertificateMaintainer instead of EndpointCertificateManager cleanup thread to handle certificate refreshes and deletions", "Takes effect on next run of maintainer / next manager cleanup thread run"); + public static final UnboundBooleanFlag ENABLE_FEED_BLOCK_IN_DISTRIBUTOR = defineFeatureFlag( + "enable-feed-block-in-distributor", false, + List.of("geirst"), "2021-01-27", "2021-04-01", + "Enables blocking of feed in the distributor if resource usage is above limit on at least one content node", + "Takes effect at redeployment", + ZONE_ID, APPLICATION_ID); + + /** WARNING: public for testing: All flags should be defined in {@link Flags}. */ public static UnboundBooleanFlag defineFeatureFlag(String flagId, boolean defaultValue, List<String> owners, String createdAt, String expiresAt, String description, |