From dcae51ced05988d5030e8e7578cb75e70fdf7f05 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Mon, 2 May 2022 15:18:18 +0200 Subject: Use a string flag for files with unknown extension in app Need 3 values (might want to avoid logging/notification in console for some cases that should be allowed, so use a string flag) --- .../config/server/session/SessionRepository.java | 20 +++++++++++++------- flags/src/main/java/com/yahoo/vespa/flags/Flags.java | 7 +++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index 3a54123f26e..ccfe8e31b69 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -43,15 +43,14 @@ import com.yahoo.vespa.config.server.zookeeper.SessionCounter; import com.yahoo.vespa.config.server.zookeeper.ZKApplication; import com.yahoo.vespa.curator.Curator; import com.yahoo.vespa.defaults.Defaults; -import com.yahoo.vespa.flags.BooleanFlag; import com.yahoo.vespa.flags.FlagSource; import com.yahoo.vespa.flags.Flags; +import com.yahoo.vespa.flags.StringFlag; import com.yahoo.yolean.Exceptions; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.cache.ChildData; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; import org.apache.zookeeper.KeeperException; - import java.io.File; import java.io.FilenameFilter; import java.io.IOException; @@ -129,7 +128,7 @@ public class SessionRepository { private final ModelFactoryRegistry modelFactoryRegistry; private final ConfigDefinitionRepo configDefinitionRepo; private final int maxNodeSize; - private final BooleanFlag failDeploymentForFilesWithUnknownExtension; + private final StringFlag failDeploymentForFilesWithUnknownExtension; public SessionRepository(TenantName tenantName, TenantApplications applicationRepo, @@ -173,7 +172,7 @@ public class SessionRepository { this.modelFactoryRegistry = modelFactoryRegistry; this.configDefinitionRepo = configDefinitionRepo; this.maxNodeSize = maxNodeSize; - this.failDeploymentForFilesWithUnknownExtension = Flags.FAIL_DEPLOYMENT_FOR_FILES_WITH_UNKNOWN_EXTENSION.bindTo(flagSource); + this.failDeploymentForFilesWithUnknownExtension = Flags.APPLICATION_FILES_WITH_UNKNOWN_EXTENSION.bindTo(flagSource); loadSessions(); // Needs to be done before creating cache below this.directoryCache = curator.createDirectoryCache(sessionsPath.getAbsolute(), false, false, zkCacheExecutor); @@ -686,9 +685,16 @@ public class SessionRepository { try { app.validateFileExtensions(); } catch (IllegalArgumentException e) { - if (failDeploymentForFilesWithUnknownExtension.value()) - throw e; - deployLogger.ifPresent(logger -> logger.logApplicationPackage(Level.WARNING, e.getMessage())); + switch (failDeploymentForFilesWithUnknownExtension.value()) { + case "FAIL": + throw e; + case "LOG": + deployLogger.ifPresent(logger -> logger.logApplicationPackage(Level.WARNING, e.getMessage())); + break; + case "NOOP": + default: + break; + } } return app; 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 572897c52ed..964893af6e0 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java @@ -397,6 +397,13 @@ public class Flags { "Takes effect at redeployment", ZONE_ID, APPLICATION_ID); + public static final UnboundStringFlag APPLICATION_FILES_WITH_UNKNOWN_EXTENSION = defineStringFlag( + "fail-deployment-for-files-with-unknown-extension", "NOOP", + List.of("hmusum"), "2022-04-27", "2022-05-27", + "Whether to log, fail or do nothing for deployments when app has a file with unknown extension (valid values LOG, FAIL, NOOP)", + "Takes effect at redeployment", + ZONE_ID, APPLICATION_ID); + public static final UnboundBooleanFlag NOTIFICATION_DISPATCH_FLAG = defineFeatureFlag( "dispatch-notifications", false, List.of("enygaard"), "2022-05-02", "2022-09-30", -- cgit v1.2.3