summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorvalerijf <valerijf@yahoo-inc.com>2017-05-31 15:43:44 +0200
committervalerijf <valerijf@yahoo-inc.com>2017-05-31 15:43:44 +0200
commitbeac414eb3a5832b9e34e0b21b16d33b7387b693 (patch)
treee456af133f5c605b405c6e587732d933efbbdf07 /node-admin
parent34082c5ec29790320c180da31b6f5b9bb9443754 (diff)
Run local zone without building local image
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/configserver-app/hosted-vespa/http-server.xml (renamed from node-admin/include/http-server.xml)0
-rw-r--r--node-admin/configserver-app/node-flavors.xml (renamed from node-admin/include/node-flavors.xml)0
-rwxr-xr-xnode-admin/configserver-app/start-config-server.sh (renamed from node-admin/include/start-config-server.sh)0
-rw-r--r--node-admin/include/Dockerfile.template33
-rwxr-xr-xnode-admin/include/nodectl-instance.sh191
-rw-r--r--node-admin/include/root-bashrc1
-rwxr-xr-xnode-admin/include/start-services.sh98
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java4
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/LocalZoneUtils.java33
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/RunVespaLocal.java50
10 files changed, 25 insertions, 385 deletions
diff --git a/node-admin/include/http-server.xml b/node-admin/configserver-app/hosted-vespa/http-server.xml
index f77d392de97..f77d392de97 100644
--- a/node-admin/include/http-server.xml
+++ b/node-admin/configserver-app/hosted-vespa/http-server.xml
diff --git a/node-admin/include/node-flavors.xml b/node-admin/configserver-app/node-flavors.xml
index 7d22975994a..7d22975994a 100644
--- a/node-admin/include/node-flavors.xml
+++ b/node-admin/configserver-app/node-flavors.xml
diff --git a/node-admin/include/start-config-server.sh b/node-admin/configserver-app/start-config-server.sh
index a592ec3cbd3..a592ec3cbd3 100755
--- a/node-admin/include/start-config-server.sh
+++ b/node-admin/configserver-app/start-config-server.sh
diff --git a/node-admin/include/Dockerfile.template b/node-admin/include/Dockerfile.template
deleted file mode 100644
index 53f8bfac18f..00000000000
--- a/node-admin/include/Dockerfile.template
+++ /dev/null
@@ -1,33 +0,0 @@
-# NOTE: Whenever the vespa-base version changes, review pom.xml. A fixed version of vespa-base contains components
-# built from a certain vespa revision, while the docker image you will build with this Dockerfile contains components
-# (i.e. the node-admin jar file) built from HEAD. Since dependencies change over time, there may be mismatches.
-# Therefore, one of the following may be necessary for one or more dependencies in pom.xml:
-# a) Hard-coding a version override.
-# b) Changing a hard-coded version override.
-# c) Removing a hard-coded version override.
-#
-# Because of the way docker creates and caches docker image layers, the command should be in order of likelihood
-# of change (Files that are updated most often should be at the bottom).
-#
-# See build.sh for the meaning of $NODE_ADMIN_FROM_IMAGE.
-FROM $NODE_ADMIN_FROM_IMAGE
-
-# Be aware that this Dockerfile is not being used in any pipelines and has no relation to production environments etc.
-# It is here for developers' convenience - it allows building and experimenting with node-admin locally.
-
-# Things for convenience.
-RUN yum install -y tcpdump
-ADD root-bashrc /root/.bashrc
-
-# Make config-server aware of node flavor 'docker'.
-ADD node-flavors.xml $VESPA_HOME/conf/configserver-app/node-flavors.xml
-
-# Make config-server also listen to 4080
-ADD http-server.xml $VESPA_HOME/conf/configserver-app/hosted-vespa/http-server.xml
-
-# Entrypoint for running config server in a container.
-ADD start-config-server.sh $VESPA_HOME/bin/start-config-server.sh
-
-# Included in base image, but here overridden with local modifications.
-# TODO: Update the source instead.
-ADD start-services.sh $VESPA_HOME/bin/start-services.sh
diff --git a/node-admin/include/nodectl-instance.sh b/node-admin/include/nodectl-instance.sh
deleted file mode 100755
index a1018d6ba12..00000000000
--- a/node-admin/include/nodectl-instance.sh
+++ /dev/null
@@ -1,191 +0,0 @@
-#!/bin/sh
-# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-# WARNING: This script should be kept in sync with the file used by Chef:
-# vespa-cookbooks/hosted/files/default/prepost-instance.sh
-# TODO: Remove the above cookbook file (with the down-side that a new script
-# requires a new vespa release, instead of just a hosted release).
-#
-# Usage: nodectl-instance.sh [resume|start|stop|suspend]
-#
-# resume: Set the node "in service" by e.g. undraining container traffic
-#
-# start: Start services on the node. Can be seen as a boot of a non-Docker node.
-# start can be assumed to have completed successfully.
-#
-# stop: Stop services on the node. Can be seen as a shutdown of a non-Docker node.
-#
-# suspend: Prepare for a short suspension, e.g. there's a pending upgrade. Set the
-# node "out of service" by draining container traffic, and flush index for a
-# quick start after the suspension. There's no need to stop.
-
-# BEGIN environment bootstrap section
-# Do not edit between here and END as this section should stay identical in all scripts
-
-function debug {
- echo "$(date -Is) $*"
-}
-
-findpath () {
- myname=${0}
- mypath=${myname%/*}
- myname=${myname##*/}
- if [ "$mypath" ] && [ -d "$mypath" ]; then
- return
- fi
- mypath=$(pwd)
- if [ -f "${mypath}/${myname}" ]; then
- return
- fi
- echo "FATAL: Could not figure out the path where $myname lives from $0"
- exit 1
-}
-
-COMMON_ENV=libexec/vespa/common-env.sh
-
-source_common_env () {
- if [ "$VESPA_HOME" ] && [ -d "$VESPA_HOME" ]; then
- # ensure it ends with "/" :
- VESPA_HOME=${VESPA_HOME%/}/
- export VESPA_HOME
- common_env=$VESPA_HOME/$COMMON_ENV
- if [ -f "$common_env" ]; then
- . $common_env
- return
- fi
- fi
- return 1
-}
-
-findroot () {
- source_common_env && return
- if [ "$VESPA_HOME" ]; then
- echo "FATAL: bad VESPA_HOME value '$VESPA_HOME'"
- exit 1
- fi
- if [ "$ROOT" ] && [ -d "$ROOT" ]; then
- VESPA_HOME="$ROOT"
- source_common_env && return
- fi
- findpath
- while [ "$mypath" ]; do
- VESPA_HOME=${mypath}
- source_common_env && return
- mypath=${mypath%/*}
- done
- echo "FATAL: missing VESPA_HOME environment variable"
- echo "Could not locate $COMMON_ENV anywhere"
- exit 1
-}
-
-findroot
-
-# END environment bootstrap section
-
-has_servicename() {
- local name="$1"
- $VESPA_HOME/bin/vespa-model-inspect host $(hostname) | grep -q "$name @ "
- return $?
-}
-
-has_container() {
- has_servicename container || has_servicename qrserver
-}
-
-has_searchnode() {
- has_servicename searchnode
-}
-
-container_drain() {
- # TODO: Implement proper draining
- sleep 60
-}
-
-Resume() {
- # Always start vip for now
- $echo $VESPA_HOME/bin/vespa-routing vip -u node-admin in
-
- # Start filebeat if configured
- if [ -f /etc/filebeat/filebeat.yml ] ; then
- $echo service filebeat start
- fi
-}
-
-# Start all services, can be seen as a reboot of a non-Docker node
-Start() {
- debug "Configuring rsyslog service to work"
- # Disable kernel log module
- sed -i.bak 's/^\$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf
- debug "Starting rsyslog service"
- service rsyslog start
-
- debug "Starting crond service"
- service crond start
-
- debug "Yinst settings"
- yinst set zpe_policy_updater.domains=$ATHENS_DOMAIN \
- zpe_policy_updater.autostart=on \
- zpe_policy_updater.cron_start_hour=* \
- zpe_policy_updater.cron_start_min=*/30 \
- zpe_policy_updater.cron_start_delay=30
- debug "Starting all yinst packages"
- # Start yinst the way it is done when a non-Docker node is booted.
- # As this is implemented in yinst now (2017-02-08), this will take care of
- # cleaning up /home/y/tmp and /home/y/var/run
- /etc/rc.d/init.d/yinst start
- debug "yinst started, exited with $?"
-}
-
-# Stop all services, can be seen as a shutdown of a non-Docker node
-Stop() {
- debug "Stopping services and other yinst packages running"
- # Stop yinst the way it is done when a non-Docker node is shutdown.
- /etc/rc.d/init.d/yinst stop
- debug "Stopping crond service"
- service crond stop
- debug "Stopping rsyslog service"
- service rsyslog stop
-}
-
-Suspend() {
- # Always stop vip for now
- $echo $VESPA_HOME/bin/vespa-routing vip -u node-admin out
-
- if has_searchnode; then
- $echo $VESPA_HOME/bin/vespa-proton-cmd --local prepareRestart
- fi
-
- if has_container; then
- $echo container_drain
- fi
-}
-
-main() {
- if [ $# -lt 1 ]; then
- echo "Usage: $0 [-e] start|stop|suspend" >&2
- exit 1
- fi
-
- echo=""
- if [ "$1" = "-e" ]; then
- echo=echo
- shift
- fi
-
- action="$1"
-
- if [ "$action" = "start" ]; then
- Start
- elif [ "$action" = "stop" ]; then
- Stop
- elif [ "$action" = "suspend" ]; then
- Suspend
- elif [ "$action" = "resume" ]; then
- Resume
- else
- echo "Unknown action: $action" >&2
- exit 1
- fi
-}
-
-main "$@"
diff --git a/node-admin/include/root-bashrc b/node-admin/include/root-bashrc
deleted file mode 100644
index fda1752c85f..00000000000
--- a/node-admin/include/root-bashrc
+++ /dev/null
@@ -1 +0,0 @@
-export TERM=xterm
diff --git a/node-admin/include/start-services.sh b/node-admin/include/start-services.sh
deleted file mode 100755
index 0fe5c1c0724..00000000000
--- a/node-admin/include/start-services.sh
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/bash
-# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-# TODO: This file duplicates a file in the base image (with local modifications).
-# Update the file there.
-
-# BEGIN environment bootstrap section
-# Do not edit between here and END as this section should stay identical in all scripts
-
-findpath () {
- myname=${0}
- mypath=${myname%/*}
- myname=${myname##*/}
- if [ "$mypath" ] && [ -d "$mypath" ]; then
- return
- fi
- mypath=$(pwd)
- if [ -f "${mypath}/${myname}" ]; then
- return
- fi
- echo "FATAL: Could not figure out the path where $myname lives from $0"
- exit 1
-}
-
-COMMON_ENV=libexec/vespa/common-env.sh
-
-source_common_env () {
- if [ "$VESPA_HOME" ] && [ -d "$VESPA_HOME" ]; then
- # ensure it ends with "/" :
- VESPA_HOME=${VESPA_HOME%/}/
- export VESPA_HOME
- common_env=$VESPA_HOME/$COMMON_ENV
- if [ -f "$common_env" ]; then
- . $common_env
- return
- fi
- fi
- return 1
-}
-
-findroot () {
- source_common_env && return
- if [ "$VESPA_HOME" ]; then
- echo "FATAL: bad VESPA_HOME value '$VESPA_HOME'"
- exit 1
- fi
- if [ "$ROOT" ] && [ -d "$ROOT" ]; then
- VESPA_HOME="$ROOT"
- source_common_env && return
- fi
- findpath
- while [ "$mypath" ]; do
- VESPA_HOME=${mypath}
- source_common_env && return
- mypath=${mypath%/*}
- done
- echo "FATAL: missing VESPA_HOME environment variable"
- echo "Could not locate $COMMON_ENV anywhere"
- exit 1
-}
-
-findroot
-
-# END environment bootstrap section
-
-export LC_ALL=C
-
-function wait_for_network_up {
- while true
- do
- for config_server_host in $(echo $CONFIG_SERVER_ADDRESS | tr "," " ")
- do
- ping -c 1 -W 3 $config_server_host && return
- sleep 1
- done
- done
-}
-
-if [ -z $CONFIG_SERVER_ADDRESS ]
-then
- echo "CONFIG_SERVER_ADDRESS must be set."
- exit -1
-fi
-
-chown yahoo $VESPA_HOME/var/jdisc_container
-
-# Local modification; fixes ownership issues for vespa node running in container.
-chown yahoo $VESPA_HOME/var/zookeeper
-
-if [ -d "$VESPA_HOME/logs" ]
-then
- chmod 1777 $VESPA_HOME/logs
-fi
-
-yinst set services.addr_configserver=$CONFIG_SERVER_ADDRESS
-wait_for_network_up
-yinst start services
-logfmt -n -f
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
index 0e20e16ea48..c2855da85a0 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
@@ -123,6 +123,10 @@ public class DockerOperationsImpl implements DockerOperations {
.withUlimit("core", -1, -1)
.withAddCapability("SYS_PTRACE"); // Needed for gcore, pstack etc.
+ if (environment.isRunningLocally()) {
+ command.withEntrypoint("/usr/local/bin/start-services.sh", "--run-local");
+ }
+
command.withVolume("/etc/hosts", "/etc/hosts");
for (String pathInNode : DIRECTORIES_TO_MOUNT.keySet()) {
String pathInHost = environment.pathInHostFromPathInNode(containerName, pathInNode).toString();
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/LocalZoneUtils.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/LocalZoneUtils.java
index f972c4c09f5..fdc5489e95c 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/LocalZoneUtils.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/LocalZoneUtils.java
@@ -24,7 +24,6 @@ import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
@@ -48,45 +47,47 @@ public class LocalZoneUtils {
public static final ContainerName CONFIG_SERVER_CONTAINER_NAME = new ContainerName(CONFIG_SERVER_HOSTNAME);
public static final String NODE_ADMIN_HOSTNAME = getParentHostHostname();
public static final ContainerName NODE_ADMIN_CONTAINER_NAME = new ContainerName("node-admin");
- public static final DockerImage VESPA_LOCAL_IMAGE = new DockerImage("vespa-local:latest");
private static final ConfigServerHttpRequestExecutor requestExecutor = ConfigServerHttpRequestExecutor.create(
Collections.singleton(CONFIG_SERVER_HOSTNAME));
private static final String APP_HOSTNAME_PREFIX = "cnode-";
private static final String TENANT_NAME = "localtenant";
private static final String APPLICATION_NAME = "default";
- private static final Path PROJECT_ROOT = Paths.get("").toAbsolutePath();
- public static void startConfigServerIfNeeded(Docker docker, Environment environment) throws UnknownHostException {
+ public static void startConfigServerIfNeeded(Docker docker, Environment environment, DockerImage dockerImage, Path pathToProjectRoot) throws UnknownHostException {
Optional<Container> container = docker.getContainer(CONFIG_SERVER_CONTAINER_NAME);
if (container.isPresent()) {
if (container.get().state.isRunning()) return;
else docker.deleteContainer(CONFIG_SERVER_CONTAINER_NAME);
}
- docker.createContainerCommand(VESPA_LOCAL_IMAGE, CONFIG_SERVER_CONTAINER_NAME, CONFIG_SERVER_HOSTNAME)
+ Path pathToConfigServerApp = Paths.get(Defaults.getDefaults().underVespaHome("conf/configserver-app"));
+ docker.createContainerCommand(dockerImage, CONFIG_SERVER_CONTAINER_NAME, CONFIG_SERVER_HOSTNAME)
.withNetworkMode(DockerImpl.DOCKER_CUSTOM_MACVLAN_NETWORK_NAME)
.withIpAddress(environment.getInetAddressForHost(CONFIG_SERVER_HOSTNAME))
.withEnvironment("HOSTED_VESPA_ENVIRONMENT", environment.getEnvironment())
.withEnvironment("HOSTED_VESPA_REGION", environment.getRegion())
.withEnvironment("CONFIG_SERVER_HOSTNAME", CONFIG_SERVER_HOSTNAME)
- .withEntrypoint(Defaults.getDefaults().underVespaHome("bin/start-config-server.sh"))
.withUlimit("nofile", 262_144, 262_144)
.withUlimit("nproc", 32_768, 409_600)
.withUlimit("core", -1, -1)
+ .withEntrypoint(pathToConfigServerApp.resolve("start-config-server.sh").toString())
.create();
+ docker.copyArchiveToContainer(pathToProjectRoot.resolve("node-admin/configserver-app").toString(),
+ CONFIG_SERVER_CONTAINER_NAME, Defaults.getDefaults().underVespaHome("conf"));
+
docker.startContainer(CONFIG_SERVER_CONTAINER_NAME);
}
- public static void startNodeAdminIfNeeded(Docker docker, Environment environment, Path pathToContainerStorage) {
+ public static void startNodeAdminIfNeeded(Docker docker, Environment environment, DockerImage dockerImage, Path pathToContainerStorage) {
Optional<Docker.ContainerStats> containerStats = docker.getContainerStats(NODE_ADMIN_CONTAINER_NAME);
if (containerStats.isPresent())
return;
else
docker.deleteContainer(NODE_ADMIN_CONTAINER_NAME);
- Docker.CreateContainerCommand createCmd = docker.createContainerCommand(VESPA_LOCAL_IMAGE,
+ Docker.CreateContainerCommand createCmd = docker.createContainerCommand(dockerImage,
NODE_ADMIN_CONTAINER_NAME, NODE_ADMIN_HOSTNAME)
.withNetworkMode("host")
.withVolume("/proc", "/host/proc")
@@ -96,9 +97,11 @@ public class LocalZoneUtils {
.withEnvironment("REGION", environment.getRegion())
.withEnvironment("CONFIG_SERVER_ADDRESS", CONFIG_SERVER_HOSTNAME)
.withEnvironment("ATHENS_DOMAIN", "fake.env")
+ .withEnvironment("RUNNING_LOCALLY", "true")
.withUlimit("nofile", 262_144, 262_144)
.withUlimit("nproc", 32_768, 409_600)
- .withUlimit("core", -1, -1);
+ .withUlimit("core", -1, -1)
+ .withEntrypoint("/usr/local/bin/start-services.sh", "--run-local");
if (DockerTestUtils.getSystemOS() == DockerTestUtils.OS.Mac_OS_X) {
createCmd.withNetworkMode(DockerImpl.DOCKER_CUSTOM_MACVLAN_NETWORK_NAME);
@@ -141,18 +144,6 @@ public class LocalZoneUtils {
docker.executeInContainerAsRoot(NODE_ADMIN_CONTAINER_NAME, "chown", "yahoo", "/host/var/run/docker.sock");
}
- public static void buildVespaLocalDockerImage(Docker docker, DockerImage vespaBaseImage) throws IOException {
- Path dockerfilePath = PROJECT_ROOT.resolve("node-admin/include/Dockerfile");
-
- Path dockerfileTemplatePath = Paths.get("node-admin/include/Dockerfile.template");
- String dockerfileTemplate = new String(Files.readAllBytes(dockerfileTemplatePath))
- .replaceAll("\\$NODE_ADMIN_FROM_IMAGE", vespaBaseImage.asString())
- .replaceAll("\\$VESPA_HOME", Defaults.getDefaults().vespaHome());
- Files.write(dockerfilePath, dockerfileTemplate.getBytes());
-
- docker.buildImage(dockerfilePath.getParent().toFile(), VESPA_LOCAL_IMAGE);
- }
-
public static Optional<ContainerNodeSpec> getContainerNodeSpec(String hostName) {
try {
GetNodesResponse.Node nodeResponse = requestExecutor.get("/nodes/v2/node/" + hostName,
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/RunVespaLocal.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/RunVespaLocal.java
index 58114cda78a..249d1b03b0d 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/RunVespaLocal.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/RunVespaLocal.java
@@ -1,16 +1,12 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.docker;
-import com.yahoo.metrics.simple.MetricReceiver;
import com.yahoo.net.HostName;
import com.yahoo.vespa.hosted.dockerapi.Docker;
import com.yahoo.vespa.hosted.dockerapi.DockerImage;
import com.yahoo.vespa.hosted.dockerapi.DockerTestUtils;
-import com.yahoo.vespa.hosted.dockerapi.metrics.MetricReceiverWrapper;
-import com.yahoo.vespa.hosted.node.admin.provider.ComponentsProviderImpl;
import com.yahoo.vespa.hosted.node.admin.util.Environment;
import com.yahoo.vespa.hosted.node.admin.util.InetAddressResolver;
-import com.yahoo.vespa.hosted.node.admin.util.PathResolver;
import com.yahoo.vespa.hosted.provision.Node;
import java.io.IOException;
@@ -21,7 +17,6 @@ import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.time.Duration;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
import java.util.logging.Logger;
import java.util.stream.Stream;
@@ -39,12 +34,13 @@ import static org.junit.Assert.assertTrue;
* @author freva
*/
public class RunVespaLocal {
- private static final Environment.Builder environmentBuilder = new Environment.Builder()
+ private static final Environment environment = new Environment.Builder()
.configServerHosts(LocalZoneUtils.CONFIG_SERVER_HOSTNAME)
.environment("dev")
.region("vespa-local")
.parentHostHostname(HostName.getLocalhost())
- .inetAddressResolver(new InetAddressResolver());
+ .inetAddressResolver(new InetAddressResolver())
+ .build();
private final Logger logger = Logger.getLogger("RunVespaLocal");
private final Docker docker;
@@ -55,26 +51,13 @@ public class RunVespaLocal {
this.pathToVespaRoot = pathToVespaRoot;
}
- /**
- * Pulls the base image and builds the vespa-local image
- * @param vespaBaseImage Vespa docker image to use as base for the image that the config-server and nodes will run
- */
- public void buildVespaLocalImage(DockerImage vespaBaseImage) throws ExecutionException, InterruptedException, IOException {
- if (!docker.imageIsDownloaded(vespaBaseImage)) {
- logger.info("Pulling " + vespaBaseImage.asString() + " (This may take a while)");
- docker.pullImageAsync(vespaBaseImage).get();
- }
-
- logger.info("Building " + LocalZoneUtils.VESPA_LOCAL_IMAGE.asString());
- LocalZoneUtils.buildVespaLocalDockerImage(docker, vespaBaseImage);
- }
/**
* Starts config server, provisions numNodesToProvision and puts them in ready state
*/
- public void startLocalZoneWithNodes(int numNodesToProvision) throws IOException {
+ public void startLocalZoneWithNodes(DockerImage dockerImage, int numNodesToProvision) throws IOException {
logger.info("Starting config-server");
- LocalZoneUtils.startConfigServerIfNeeded(docker, environmentBuilder.build());
+ LocalZoneUtils.startConfigServerIfNeeded(docker, environment, dockerImage, pathToVespaRoot);
logger.info("Waiting until config-server is ready to serve");
URL configServerUrl = new URL("http://" + LocalZoneUtils.CONFIG_SERVER_HOSTNAME +
@@ -85,7 +68,7 @@ public class RunVespaLocal {
Set<String> hostnames = LocalZoneUtils.provisionNodes(LocalZoneUtils.NODE_ADMIN_HOSTNAME, numNodesToProvision);
hostnames.stream()
.map(LocalZoneUtils::getContainerNodeSpec)
- .flatMap(optional -> optional.isPresent() ? Stream.of(optional.get()) : Stream.empty()) // Remove with JDK 9
+ .flatMap(optional -> optional.map(Stream::of).orElseGet(Stream::empty)) // Remove with JDK 9
.forEach(nodeSpec -> {
if (nodeSpec.nodeState == Node.State.provisioned) LocalZoneUtils.setState(Node.State.dirty, nodeSpec.hostname);
if (nodeSpec.nodeState == Node.State.dirty) LocalZoneUtils.setState(Node.State.ready, nodeSpec.hostname);
@@ -93,30 +76,15 @@ public class RunVespaLocal {
}
/**
- * Start node-admin in IDE
- * @param pathResolver Instance of {@link PathResolver} that specifies the path to where the container data will
- * be stored, the path must exist and must be writeable by user,
- * normally /home/docker/container-storage
- */
- public void startNodeAdminInIDE(PathResolver pathResolver) {
- logger.info("Starting node-admin");
- environmentBuilder.pathResolver(pathResolver);
- new ComponentsProviderImpl(
- docker,
- new MetricReceiverWrapper(MetricReceiver.nullImplementation),
- environmentBuilder.build(),
- true);
- }
-
- /**
* Starts node-admin inside a container
+ * @param dockerImage Docker image that node-admin should be running
* @param pathToContainerStorage Path to where the container data will be stored, the path must exist and must
* be writeable by user, normally /home/docker/container-storage
*/
- public void startNodeAdminAsContainer(Path pathToContainerStorage) throws IOException {
+ public void startNodeAdminAsContainer(DockerImage dockerImage, Path pathToContainerStorage) throws IOException {
logger.info("Starting node-admin");
String parentHostHostname = LocalZoneUtils.NODE_ADMIN_HOSTNAME;
- LocalZoneUtils.startNodeAdminIfNeeded(docker, environmentBuilder.build(), pathToContainerStorage);
+ LocalZoneUtils.startNodeAdminIfNeeded(docker, environment, dockerImage, pathToContainerStorage);
logger.info("Provisioning host at " + parentHostHostname);
LocalZoneUtils.provisionHost(parentHostHostname);