Skip to content

Commit

Permalink
Merge pull request #391 from mesos/bug/390-RevertHostMode
Browse files Browse the repository at this point in the history
Fixes IP address issues. When running system tests, use the --systemT…
  • Loading branch information
Phil Winder committed Oct 29, 2015
2 parents 7359502 + c10d96f commit d520859
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.node.Node;

import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.SocketException;
import java.net.URL;
import java.net.*;
import java.security.InvalidParameterException;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -107,13 +104,13 @@ public void run() {
}));

try {
InetAddress eth0 = AdaptorIPAddress.eth0();
InetAddress eth0 = InetAddress.getLocalHost();
LOGGER.debug("InetAddress: " + eth0);
SerializableIPAddress serializableIPAddress = new SerializableIPAddress(eth0);
driver.sendFrameworkMessage(serializableIPAddress.toBytes());
LOGGER.debug("Sent framework message: " + serializableIPAddress.toString());
} catch (NoSuchElementException | SocketException e) {
LOGGER.warn("Unable to obtain eth0 ip address", e);
} catch (UnknownHostException | NoSuchElementException e) {
LOGGER.error("Unable to obtain eth0 ip address", e);
}

// Send status update, running
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class Configuration {
private static final Logger LOGGER = Logger.getLogger(Configuration.class);
public static final String FRAMEWORK_USE_DOCKER = "--frameworkUseDocker";
public static final String JAVA_HOME = "--javaHome";
public static final String SYSTEM_TEST_MODE = "--systemTestMode";
@Parameter(names = {EXECUTOR_HEALTH_DELAY}, description = "The delay between executor healthcheck requests (ms).", validateValueWith = CLIValidators.PositiveLong.class)
private static Long executorHealthDelay = 30000L;
// **** ZOOKEEPER
Expand Down Expand Up @@ -86,6 +87,8 @@ public class Configuration {
private InetSocketAddress frameworkFileServerAddress;
@Parameter(names = {JAVA_HOME}, description = "(Only when " + FRAMEWORK_USE_DOCKER + " is false) When starting in jar mode, if java is not on the path, you can specify the path here.", validateWith = CLIValidators.NotEmptyString.class)
private String javaHome = "";
@Parameter(names = {SYSTEM_TEST_MODE}, arity = 1, description = "Internal use only. Enables docker bridge mode for system tests.")
private Boolean systemTestMode = false;
// ****************** Runtime configuration **********************

public Configuration(String... args) {
Expand Down Expand Up @@ -243,6 +246,10 @@ public String getJavaHome() {
return javaHome.replaceAll("java$", "").replaceAll("/$", "") + "/";
}

public Boolean isSystemTestMode() {
return systemTestMode;
}

/**
* Ensures that the number is > than the EXECUTOR_HEALTH_DELAY
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,18 @@ private Protos.ExecutorInfo.Builder newExecutorInfo(Configuration configuration)
.setName("elasticsearch-executor-" + UUID.randomUUID().toString())
.setCommand(newCommandInfo(configuration));
if (configuration.isFrameworkUseDocker()) {

Protos.ContainerInfo.DockerInfo.Builder containerBuilder = Protos.ContainerInfo.DockerInfo.newBuilder()
.setImage(configuration.getExecutorImage())
.setForcePullImage(configuration.getExecutorForcePullImage());
if (configuration.isSystemTestMode()) {
containerBuilder.setNetwork(Protos.ContainerInfo.DockerInfo.Network.BRIDGE);
} else {
containerBuilder.setNetwork(Protos.ContainerInfo.DockerInfo.Network.HOST);
}
executorInfoBuilder.setContainer(Protos.ContainerInfo.newBuilder()
.setType(Protos.ContainerInfo.Type.DOCKER)
.setDocker(Protos.ContainerInfo.DockerInfo.newBuilder()
.setImage(configuration.getExecutorImage())
.setForcePullImage(configuration.getExecutorForcePullImage())
.setNetwork(Protos.ContainerInfo.DockerInfo.Network.BRIDGE))
.setDocker(containerBuilder)
.addVolumes(Protos.Volume.newBuilder().setHostPath(SETTINGS_PATH_VOLUME).setContainerPath(SETTINGS_PATH_VOLUME).setMode(Protos.Volume.Mode.RO)) // Temporary fix until we get a data container.
.addVolumes(Protos.Volume.newBuilder().setContainerPath(SETTINGS_DATA_VOLUME_CONTAINER).setHostPath(configuration.getDataDir()).setMode(Protos.Volume.Mode.RW).build())
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected CreateContainerCmd dockerCommand() {
.withName(TEST_CONFIG.getSchedulerName() + "_" + new SecureRandom().nextInt())
.withEnv("JAVA_OPTS=-Xms128m -Xmx256m")
.withCmd(
Configuration.SYSTEM_TEST_MODE, "true",
ZookeeperCLIParameter.ZOOKEEPER_MESOS_URL, getZookeeperMesosUrl(),
ZookeeperCLIParameter.ZOOKEEPER_FRAMEWORK_URL, getZookeeperFrameworkUrl(),
ZookeeperCLIParameter.ZOOKEEPER_FRAMEWORK_TIMEOUT, "30000",
Expand Down

0 comments on commit d520859

Please sign in to comment.