Externalize Vespa user
@@ -6,7 +6,6 @@ import com.yahoo.config.provision.NodeType;
import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.SystemName;
import com.yahoo.vespa.athenz.api.AthenzService;
-import com.yahoo.vespa.defaults.Defaults;
import com.yahoo.vespa.hosted.dockerapi.ContainerName;
import com.yahoo.vespa.hosted.node.admin.component.ZoneId;
import com.yahoo.vespa.hosted.node.admin.docker.DockerNetworking;
@@ -38,7 +37,7 @@ public class NodeAgentContextImpl implements NodeAgentContext {
public NodeAgentContextImpl(String hostname, NodeType nodeType, AthenzService identity,
DockerNetworking dockerNetworking, ZoneId zoneId,
- Path pathToContainerStorage, Path pathToVespaHome) {
+ Path pathToContainerStorage, Path pathToVespaHome, String vespaUser) {
this.hostName = HostName.from(Objects.requireNonNull(hostname));
this.containerName = ContainerName.fromHostname(hostname);
this.nodeType = Objects.requireNonNull(nodeType);
@@ -48,7 +47,7 @@ public class NodeAgentContextImpl implements NodeAgentContext {
this.pathToNodeRootOnHost = Objects.requireNonNull(pathToContainerStorage).resolve(containerName.asString());
this.pathToVespaHome = Objects.requireNonNull(pathToVespaHome);
this.logPrefix = containerName.asString() + ": ";
- this.vespaUser = Defaults.getDefaults().vespaUser();
+ this.vespaUser = vespaUser;
}
@Override
@@ -138,6 +137,7 @@ public class NodeAgentContextImpl implements NodeAgentContext {
private ZoneId zoneId;
private Path pathToContainerStorage;
private Path pathToVespaHome;
+ private String vespaUser;
public Builder(String hostname) {
this.hostname = hostname;
@@ -173,6 +173,11 @@ public class NodeAgentContextImpl implements NodeAgentContext {
return this;
}
+ public Builder vespaUser(String vespaUser) {
+ this.vespaUser = vespaUser;
+ return this;
+ }
+
public Builder fileSystem(FileSystem fileSystem) {
return pathToContainerStorage(fileSystem.getPath("/home/docker"));
}
@@ -185,8 +190,8 @@ public class NodeAgentContextImpl implements NodeAgentContext {
Optional.ofNullable(dockerNetworking).orElse(DockerNetworking.HOST_NETWORK),
Optional.ofNullable(zoneId).orElseGet(() -> new ZoneId(SystemName.dev, Environment.dev, RegionName.defaultName())),
Optional.ofNullable(pathToContainerStorage).orElseGet(() -> Paths.get("/home/docker")),
- Optional.ofNullable(pathToVespaHome).orElseGet(() -> Paths.get("/opt/vespa"))
- );
+ Optional.ofNullable(pathToVespaHome).orElseGet(() -> Paths.get("/opt/vespa")),
+ Optional.ofNullable(vespaUser).orElseGet(() -> "vespa"));
}
}
}
