aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2022-08-12 11:32:42 +0200
committerGitHub <noreply@github.com>2022-08-12 11:32:42 +0200
commit7c257dc514b91d1887af483ac56e44210c8ca64a (patch)
tree9c8a5e2d27a691f85d343ef21631e50093a7d4e8
parent6f74cbb42318b11eac108398a87e60340435aa80 (diff)
parent97b35e196c75932d72ff1db83faedeed6bb67db3 (diff)
Merge pull request #23638 from vespa-engine/hmusum/validate-file-extension-for-app-files-6
Refactor validate file extension for app files
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java27
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/Flags.java2
2 files changed, 14 insertions, 15 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 f4d3d9657c2..a6bbd6c20a2 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
@@ -44,6 +44,7 @@ import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.defaults.Defaults;
import com.yahoo.vespa.flags.FlagSource;
import com.yahoo.vespa.flags.Flags;
+import com.yahoo.vespa.flags.UnboundStringFlag;
import com.yahoo.yolean.Exceptions;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.ChildData;
@@ -685,29 +686,27 @@ public class SessionRepository {
DeployData deployData = new DeployData(userDir.getAbsolutePath(), applicationId, deployTimestamp, internalRedeploy,
sessionId, currentlyActiveSessionId.orElse(nonExistingActiveSessionId));
FilesApplicationPackage app = FilesApplicationPackage.fromFileWithDeployData(configApplicationDir, deployData);
+ validateFileExtensions(applicationId, deployLogger, app);
+
+ return app;
+ }
+
+ private void validateFileExtensions(ApplicationId applicationId, Optional<DeployLogger> deployLogger, FilesApplicationPackage app) {
try {
app.validateFileExtensions();
} catch (IllegalArgumentException e) {
- String flag = Flags.APPLICATION_FILES_WITH_UNKNOWN_EXTENSION.bindTo(flagSource)
- .with(APPLICATION_ID, applicationId.serializedForm())
- .value();
if (configserverConfig.hostedVespa()) {
- switch (flag) {
- case "FAIL":
- throw e;
- case "LOG":
- deployLogger.ifPresent(logger -> logger.logApplicationPackage(Level.WARNING, e.getMessage()));
- break;
- case "NOOP":
- default:
- break;
+ UnboundStringFlag flag = Flags.APPLICATION_FILES_WITH_UNKNOWN_EXTENSION;
+ String value = flag.bindTo(flagSource).with(APPLICATION_ID, applicationId.serializedForm()).value();
+ switch (value) {
+ case "FAIL" -> throw e;
+ case "LOG" -> deployLogger.ifPresent(logger -> logger.logApplicationPackage(Level.WARNING, e.getMessage()));
+ default -> log.log(Level.WARNING, "Unknown value for flag " + flag.id() + ": " + value);
}
} else {
deployLogger.ifPresent(logger -> logger.logApplicationPackage(Level.WARNING, e.getMessage()));
}
}
-
- return app;
}
private LocalSession createSessionFromApplication(File applicationDirectory,
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 8e06cde420e..1b1a5493cc5 100644
--- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
+++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
@@ -411,7 +411,7 @@ public class Flags {
public static final UnboundStringFlag APPLICATION_FILES_WITH_UNKNOWN_EXTENSION = defineStringFlag(
"fail-deployment-for-files-with-unknown-extension", "FAIL",
List.of("hmusum"), "2022-04-27", "2022-09-01",
- "Whether to log, fail or do nothing for deployments when app has a file with unknown extension (valid values LOG, FAIL, NOOP)",
+ "Whether to log, fail or do nothing for deployments when app has a file with unknown extension (valid values: LOG, FAIL)",
"Takes effect at redeployment",
ZONE_ID, APPLICATION_ID);