aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@yahooinc.com>2021-10-14 16:55:49 +0200
committerValerij Fredriksen <valerijf@yahooinc.com>2021-10-14 16:55:49 +0200
commit7f1f9e3d1d17d176c13d183d4131f58c808c2141 (patch)
tree77409641acd2706c3b7a53efa58fc5cedae8c551 /node-admin/src/main/java/com/yahoo/vespa/hosted
parent4d5118af963dd985a417e5af45ab9af879e21ba3 (diff)
Create container storage root directories when creating Container FS
Diffstat (limited to 'node-admin/src/main/java/com/yahoo/vespa/hosted')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java14
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java4
2 files changed, 8 insertions, 10 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java
index 899df091e7a..3b1235d1ccf 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java
@@ -20,7 +20,6 @@ import com.yahoo.vespa.hosted.node.admin.task.util.fs.ContainerFileSystem;
import com.yahoo.vespa.hosted.node.admin.task.util.fs.ContainerPath;
import java.nio.file.FileSystem;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
@@ -29,8 +28,6 @@ import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
-import static com.yahoo.yolean.Exceptions.uncheck;
-
/**
* @author freva
*/
@@ -259,7 +256,9 @@ public class NodeAgentContextImpl implements NodeAgentContext {
}
public NodeAgentContextImpl build() {
- NodeAgentContextImpl context = new NodeAgentContextImpl(
+ Objects.requireNonNull(containerStorage, "Must set one of containerStorage or fileSystem");
+
+ return new NodeAgentContextImpl(
nodeSpecBuilder.build(),
Optional.ofNullable(acl).orElse(Acl.EMPTY),
Optional.ofNullable(identity).orElseGet(() -> new AthenzService("domain", "service")),
@@ -286,15 +285,10 @@ public class NodeAgentContextImpl implements NodeAgentContext {
}
}),
Optional.ofNullable(flagSource).orElseGet(InMemoryFlagSource::new),
- Optional.ofNullable(containerStorage).orElseGet(() -> Path.of("/data/vespa/storage")),
+ containerStorage,
"/opt/vespa",
Optional.ofNullable(userNamespace).orElseGet(() -> new UserNamespace(100000, 100000, "vespa", "vespa", 1000, 100)),
cpuSpeedUp, hostExclusiveTo);
-
- if (containerStorage != null)
- uncheck(() -> Files.createDirectories(context.containerPath("/").pathOnHost()));
-
- return context;
}
}
}
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java
index 495b72e4554..36edfa1c1ee 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java
@@ -4,12 +4,15 @@ package com.yahoo.vespa.hosted.node.admin.task.util.fs;
import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.WatchService;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.util.Set;
+import static com.yahoo.yolean.Exceptions.uncheck;
+
/**
* @author valerijf
*/
@@ -82,6 +85,7 @@ public class ContainerFileSystem extends FileSystem {
}
public static ContainerFileSystem create(Path containerStorageRoot, int uidOffset, int gidOffset) {
+ uncheck(() -> Files.createDirectories(containerStorageRoot));
return new ContainerFileSystemProvider(containerStorageRoot, uidOffset, gidOffset).getFileSystem(null);
}
}