aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevi...@apache.org
Subject incubator-aurora git commit: Add option to override local scheduler address published into ZooKeeper
Date Fri, 23 Jan 2015 00:24:36 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 116ee2daa -> 3fa004b98


Add option to override local scheduler address published into ZooKeeper

I've added a new flag for the aurora scheduler, -hostname which can
override the scheduler server address published into ZK.

This is useful for cases such as running the scheduler in EC2, where
the autodetected local address is actual an interal IP and not the
public address of the machine.

Reviewed at https://reviews.apache.org/r/29464/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/3fa004b9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/3fa004b9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/3fa004b9

Branch: refs/heads/master
Commit: 3fa004b9854c42da0fd1a051377539f83310e572
Parents: 116ee2d
Author: Steve Niemitz <steve@tellapart.com>
Authored: Thu Jan 22 16:23:33 2015 -0800
Committer: Kevin Sweeney <kevints@apache.org>
Committed: Thu Jan 22 16:23:33 2015 -0800

----------------------------------------------------------------------
 .../org/apache/thermos/thermos_internal.thrift  |  2 +-
 .../apache/aurora/scheduler/app/AppModule.java  | 13 ++-
 .../app/LocalServiceRegistryWithOverrides.java  | 91 ++++++++++++++++++++
 .../aurora/scheduler/app/SchedulerMain.java     | 20 +++--
 .../aurora/scheduler/http/LeaderRedirect.java   |  9 +-
 .../apache/aurora/executor/common/announcer.py  | 10 ++-
 .../aurora/executor/thermos_task_runner.py      | 11 ++-
 .../python/apache/thermos/bin/thermos_runner.py | 11 ++-
 src/main/python/apache/thermos/core/runner.py   |  7 +-
 .../LocalServiceRegistryWithOverridesTest.java  | 64 ++++++++++++++
 .../aurora/scheduler/app/SchedulerIT.java       |  8 +-
 .../scheduler/http/JettyServerModuleTest.java   |  5 +-
 .../scheduler/http/LeaderRedirectTest.java      |  6 +-
 .../aurora/executor/common/test_announcer.py    |  6 +-
 14 files changed, 236 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/api/src/main/thrift/org/apache/thermos/thermos_internal.thrift
----------------------------------------------------------------------
diff --git a/api/src/main/thrift/org/apache/thermos/thermos_internal.thrift b/api/src/main/thrift/org/apache/thermos/thermos_internal.thrift
index 2c449a4..ae17174 100644
--- a/api/src/main/thrift/org/apache/thermos/thermos_internal.thrift
+++ b/api/src/main/thrift/org/apache/thermos/thermos_internal.thrift
@@ -80,7 +80,7 @@ struct RunnerHeader {
   2: i64    launch_time_ms  // kill this
   3: string sandbox
   7: string log_dir
-  4: string hostname        // kill this
+  4: string hostname        // if you kill this, the observer needs to be able to take a
hostname
   5: string user
   8: i32    uid             // added as a check in case user disappears
   6: map<string, i64> ports

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/main/java/org/apache/aurora/scheduler/app/AppModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/app/AppModule.java b/src/main/java/org/apache/aurora/scheduler/app/AppModule.java
index 360e161..5f6a019 100644
--- a/src/main/java/org/apache/aurora/scheduler/app/AppModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/app/AppModule.java
@@ -22,6 +22,7 @@ import javax.inject.Singleton;
 
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
+import com.google.common.base.Optional;
 import com.google.common.collect.Iterables;
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
@@ -76,19 +77,22 @@ public class AppModule extends AbstractModule {
 
   private final String clusterName;
   private final String serverSetPath;
-  private final String statsUrlPrefix;
   private final ClientConfig zkClientConfig;
+  private final String statsUrlPrefix;
+  private final Optional<String> zkLocalDnsNameOverride;
 
   AppModule(
       String clusterName,
       String serverSetPath,
       ClientConfig zkClientConfig,
-      String statsUrlPrefix) {
+      String statsUrlPrefix,
+      Optional<String> zkLocalDnsNameOverride) {
 
     this.clusterName = checkNotBlank(clusterName);
     this.serverSetPath = checkNotBlank(serverSetPath);
-    this.statsUrlPrefix = statsUrlPrefix;
     this.zkClientConfig = requireNonNull(zkClientConfig);
+    this.statsUrlPrefix = statsUrlPrefix;
+    this.zkLocalDnsNameOverride = requireNonNull(zkLocalDnsNameOverride);
   }
 
   @Override
@@ -127,6 +131,9 @@ public class AppModule extends AbstractModule {
     install(new SlaModule());
     install(new UpdaterModule());
 
+    bind(LocalServiceRegistryWithOverrides.Settings.class).toInstance(
+        new LocalServiceRegistryWithOverrides.Settings(this.zkLocalDnsNameOverride)
+    );
     bind(StatsProvider.class).toInstance(Stats.STATS_PROVIDER);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/main/java/org/apache/aurora/scheduler/app/LocalServiceRegistryWithOverrides.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/app/LocalServiceRegistryWithOverrides.java
b/src/main/java/org/apache/aurora/scheduler/app/LocalServiceRegistryWithOverrides.java
new file mode 100644
index 0000000..6d92ae3
--- /dev/null
+++ b/src/main/java/org/apache/aurora/scheduler/app/LocalServiceRegistryWithOverrides.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.aurora.scheduler.app;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import com.google.inject.Inject;
+import com.twitter.common.application.modules.LocalServiceRegistry;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Wraps the provided LocalServiceRegistry and optionally overrides the hostname it provides.
+ */
+public class LocalServiceRegistryWithOverrides {
+  public static class Settings {
+    private final Optional<String> zkLocalDnsNameOverride;
+
+    public Settings(Optional<String> zkLocalDnsNameOverride) {
+      if (zkLocalDnsNameOverride.isPresent()) {
+        /* Force resolution of the DNS address passed in to ensure it's valid */
+        try {
+          InetAddress.getByName(zkLocalDnsNameOverride.get());
+        } catch (UnknownHostException e) {
+          throw new IllegalStateException(
+              "Failed to resolve hostname supplied by -hostname", e);
+        }
+      }
+      this.zkLocalDnsNameOverride = zkLocalDnsNameOverride;
+    }
+
+    public Optional<String> getZkLocalDnsNameOverride() {
+      return zkLocalDnsNameOverride;
+    }
+  }
+
+  private final LocalServiceRegistry wrapped;
+  private final Optional<String> zkLocalDnsNameOverride;
+
+  @Inject
+  public LocalServiceRegistryWithOverrides(
+      LocalServiceRegistry registry,
+      Settings settings) {
+    this.wrapped = requireNonNull(registry);
+    this.zkLocalDnsNameOverride = settings.getZkLocalDnsNameOverride();
+  }
+
+  private Map<String, InetSocketAddress> applyDnsOverrides(
+      Map<String, InetSocketAddress> services) {
+    final InetAddress inetAddress;
+    try {
+      inetAddress = InetAddress.getByName(this.zkLocalDnsNameOverride.get());
+    } catch (UnknownHostException e) {
+      throw new RuntimeException("Failed to resolve address.", e);
+    }
+    return ImmutableMap.copyOf(
+        Maps.transformValues(services, new Function<InetSocketAddress, InetSocketAddress>()
{
+          @Override
+          public InetSocketAddress apply(InetSocketAddress input) {
+            return new InetSocketAddress(inetAddress, input.getPort());
+          }
+        }));
+  }
+
+  public Map<String, InetSocketAddress> getAuxiliarySockets() {
+    Map<String, InetSocketAddress> auxSockets = wrapped.getAuxiliarySockets();
+    if (zkLocalDnsNameOverride.isPresent()) {
+      return applyDnsOverrides(auxSockets);
+    } else {
+      return auxSockets;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/main/java/org/apache/aurora/scheduler/app/SchedulerMain.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/app/SchedulerMain.java b/src/main/java/org/apache/aurora/scheduler/app/SchedulerMain.java
index 72c7545..8428941 100644
--- a/src/main/java/org/apache/aurora/scheduler/app/SchedulerMain.java
+++ b/src/main/java/org/apache/aurora/scheduler/app/SchedulerMain.java
@@ -27,7 +27,6 @@ import com.google.inject.Module;
 import com.twitter.common.application.AbstractApplication;
 import com.twitter.common.application.AppLauncher;
 import com.twitter.common.application.Lifecycle;
-import com.twitter.common.application.modules.LocalServiceRegistry;
 import com.twitter.common.application.modules.StatsModule;
 import com.twitter.common.args.Arg;
 import com.twitter.common.args.CmdLine;
@@ -108,8 +107,12 @@ public class SchedulerMain extends AbstractApplication {
   @CmdLine(name = "viz_job_url_prefix", help = "URL prefix for job container stats.")
   private static final Arg<String> STATS_URL_PREFIX = Arg.create("");
 
+  @CmdLine(name = "hostname",
+      help = "The hostname to advertise in ZooKeeper instead of the locally-resolved hostname.")
+  private static final Arg<String> HOSTNAME_OVERRIDE = Arg.create(null);
+
   @Inject private SingletonService schedulerService;
-  @Inject private LocalServiceRegistry serviceRegistry;
+  @Inject private LocalServiceRegistryWithOverrides serviceRegistry;
   @Inject private SchedulerLifecycle schedulerLifecycle;
   @Inject private Lifecycle appLifecycle;
 
@@ -129,11 +132,17 @@ public class SchedulerMain extends AbstractApplication {
       String clusterName,
       String serverSetPath,
       ClientConfig zkClientConfig,
-      String statsURLPrefix) {
+      String statsURLPrefix,
+      Optional<String> zkLocalDnsNameOverride) {
 
     return ImmutableList.<Module>builder()
         .add(new StatsModule())
-        .add(new AppModule(clusterName, serverSetPath, zkClientConfig, statsURLPrefix))
+        .add(new AppModule(
+            clusterName,
+            serverSetPath,
+            zkClientConfig,
+            statsURLPrefix,
+            zkLocalDnsNameOverride))
         .addAll(getExtraModules())
         .add(getPersistentStorageModule())
         .add(new MemStorageModule(Bindings.annotatedKeyFactory(LogStorage.WriteBehind.class)))
@@ -179,7 +188,8 @@ public class SchedulerMain extends AbstractApplication {
                 CLUSTER_NAME.get(),
                 SERVERSET_PATH.get(),
                 zkClientConfig,
-                STATS_URL_PREFIX.get()))
+                STATS_URL_PREFIX.get(),
+                Optional.fromNullable(HOSTNAME_OVERRIDE.get())))
         .add(new ZooKeeperClientModule(zkClientConfig))
         .add(new AbstractModule() {
           @Override

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/main/java/org/apache/aurora/scheduler/http/LeaderRedirect.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/LeaderRedirect.java b/src/main/java/org/apache/aurora/scheduler/http/LeaderRedirect.java
index cf17385..e03009c 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/LeaderRedirect.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/LeaderRedirect.java
@@ -27,13 +27,14 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.net.HostAndPort;
 import com.google.common.util.concurrent.Atomics;
-import com.twitter.common.application.modules.LocalServiceRegistry;
 import com.twitter.common.net.pool.DynamicHostSet;
 import com.twitter.common.net.pool.DynamicHostSet.HostChangeMonitor;
 import com.twitter.common.net.pool.DynamicHostSet.MonitorException;
 import com.twitter.thrift.Endpoint;
 import com.twitter.thrift.ServiceInstance;
 
+import org.apache.aurora.scheduler.app.LocalServiceRegistryWithOverrides;
+
 /**
  * Redirect logic for finding the leading scheduler in the event that this process is not
the
  * leader.
@@ -47,13 +48,15 @@ public class LeaderRedirect {
 
   private static final Logger LOG = Logger.getLogger(LeaderRedirect.class.getName());
 
-  private final LocalServiceRegistry serviceRegistry;
+  private final LocalServiceRegistryWithOverrides serviceRegistry;
   private final DynamicHostSet<ServiceInstance> schedulers;
 
   private final AtomicReference<ServiceInstance> leader = Atomics.newReference();
 
   @Inject
-  LeaderRedirect(LocalServiceRegistry serviceRegistry, DynamicHostSet<ServiceInstance>
schedulers) {
+  LeaderRedirect(
+      LocalServiceRegistryWithOverrides serviceRegistry,
+      DynamicHostSet<ServiceInstance> schedulers) {
     this.serviceRegistry = Objects.requireNonNull(serviceRegistry);
     this.schedulers = Objects.requireNonNull(schedulers);
   }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/main/python/apache/aurora/executor/common/announcer.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/common/announcer.py b/src/main/python/apache/aurora/executor/common/announcer.py
index 9e5bdc3..dda76f0 100644
--- a/src/main/python/apache/aurora/executor/common/announcer.py
+++ b/src/main/python/apache/aurora/executor/common/announcer.py
@@ -13,7 +13,6 @@
 #
 
 import posixpath
-import socket
 import threading
 import time
 from abc import abstractmethod
@@ -75,10 +74,13 @@ class AnnouncerCheckerProvider(StatusCheckerProvider):
 
     portmap = resolve_ports(mesos_task, assigned_task.assignedPorts)
 
+    # assigned_task.slaveHost is the --hostname argument passed into the mesos slave.
+    # Using this allows overriding the hostname published into ZK when announcing.
+    # If no argument was passed to the mesos-slave, the slave falls back to gethostname().
     endpoint, additional = make_endpoints(
-        socket.gethostname(),
-        portmap,
-        mesos_task.announce().primary_port().get())
+      assigned_task.slaveHost,
+      portmap,
+      mesos_task.announce().primary_port().get())
 
     client = self.make_zk_client()
     path = self.make_zk_path(assigned_task)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/main/python/apache/aurora/executor/thermos_task_runner.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/thermos_task_runner.py b/src/main/python/apache/aurora/executor/thermos_task_runner.py
index 5e4bd65..f29faf1 100644
--- a/src/main/python/apache/aurora/executor/thermos_task_runner.py
+++ b/src/main/python/apache/aurora/executor/thermos_task_runner.py
@@ -16,6 +16,7 @@ import errno
 import getpass
 import os
 import signal
+import socket
 import struct
 import subprocess
 import sys
@@ -71,7 +72,8 @@ class ThermosTaskRunner(TaskRunner):
                sandbox,
                checkpoint_root=None,
                artifact_dir=None,
-               clock=time):
+               clock=time,
+               hostname=None):
     """
       runner_pex       location of the thermos_runner pex that this task runner should use
       task_id          task_id assigned by scheduler
@@ -96,6 +98,7 @@ class ThermosTaskRunner(TaskRunner):
     self._role = role
     self._clock = clock
     self._artifact_dir = artifact_dir or safe_mkdtemp()
+    self._hostname = hostname or socket.gethostname()
 
     # wait events
     self._dead = threading.Event()
@@ -244,7 +247,8 @@ class ThermosTaskRunner(TaskRunner):
                   checkpoint_root=self._checkpoint_root,
                   sandbox=self._root,
                   task_id=self._task_id,
-                  thermos_json=self._task_filename)
+                  thermos_json=self._task_filename,
+                  hostname=self._hostname)
 
     if getpass.getuser() == 'root':
       params.update(setuid=self._role)
@@ -388,4 +392,5 @@ class DefaultThermosTaskRunnerProvider(TaskRunnerProvider):
         sandbox,
         checkpoint_root=self._checkpoint_root,
         artifact_dir=self._artifact_dir,
-        clock=self._clock)
+        clock=self._clock,
+        hostname=assigned_task.slaveHost)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/main/python/apache/thermos/bin/thermos_runner.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/thermos/bin/thermos_runner.py b/src/main/python/apache/thermos/bin/thermos_runner.py
index 647de27..bd8cf7f 100644
--- a/src/main/python/apache/thermos/bin/thermos_runner.py
+++ b/src/main/python/apache/thermos/bin/thermos_runner.py
@@ -94,6 +94,14 @@ app.add_option(
      help="bind a numbered port PORT to name NAME")
 
 
+app.add_option(
+    "--hostname",
+    default=None,
+    dest="hostname",
+    help="The hostname to advertise in ZooKeeper and the thermos observer instead of "
+         "the locally-resolved hostname.")
+
+
 def get_task_from_options(opts):
   tasks = ThermosConfigLoader.load_json(opts.thermos_json)
   if len(tasks.tasks()) == 0:
@@ -157,7 +165,8 @@ def proxy_main(args, opts):
       user=opts.setuid,
       portmap=prebound_ports,
       chroot=opts.chroot,
-      planner_class=CappedTaskPlanner
+      planner_class=CappedTaskPlanner,
+      hostname=opts.hostname,
   )
 
   for sig in (signal.SIGUSR1, signal.SIGUSR2):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/main/python/apache/thermos/core/runner.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/thermos/core/runner.py b/src/main/python/apache/thermos/core/runner.py
index 8aac6b5..41200bd 100644
--- a/src/main/python/apache/thermos/core/runner.py
+++ b/src/main/python/apache/thermos/core/runner.py
@@ -411,14 +411,14 @@ class TaskRunner(object):
         return None
       return cls(task.tasks()[0].task(), checkpoint_root, checkpoint.header.sandbox,
                  log_dir=checkpoint.header.log_dir, task_id=task_id,
-                 portmap=checkpoint.header.ports)
+                 portmap=checkpoint.header.ports, hostname=checkpoint.header.hostname)
     except Exception as e:
       log.error('Failed to reconstitute checkpoint in TaskRunner.get: %s' % e, exc_info=True)
       return None
 
   def __init__(self, task, checkpoint_root, sandbox, log_dir=None,
                task_id=None, portmap=None, user=None, chroot=False, clock=time,
-               universal_handler=None, planner_class=TaskPlanner):
+               universal_handler=None, planner_class=TaskPlanner, hostname=None):
     """
       required:
         task (config.Task) = the task to run
@@ -463,6 +463,7 @@ class TaskRunner(object):
     self._launch_time = launch_time
     self._log_dir = log_dir or os.path.join(sandbox, '.logs')
     self._pathspec = TaskPath(root=checkpoint_root, task_id=self._task_id, log_dir=self._log_dir)
+    self._hostname = hostname or socket.gethostname()
     try:
       ThermosTaskValidator.assert_valid_task(task)
       ThermosTaskValidator.assert_valid_ports(task, self._portmap)
@@ -626,7 +627,7 @@ class TaskRunner(object):
           launch_time_ms=int(self._launch_time * 1000),
           sandbox=self._sandbox,
           log_dir=self._log_dir,
-          hostname=socket.gethostname(),
+          hostname=self._hostname,
           user=self._user,
           uid=uid,
           ports=self._portmap)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/test/java/org/apache/aurora/scheduler/app/LocalServiceRegistryWithOverridesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/app/LocalServiceRegistryWithOverridesTest.java
b/src/test/java/org/apache/aurora/scheduler/app/LocalServiceRegistryWithOverridesTest.java
new file mode 100644
index 0000000..21fd027
--- /dev/null
+++ b/src/test/java/org/apache/aurora/scheduler/app/LocalServiceRegistryWithOverridesTest.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.aurora.scheduler.app;
+
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.twitter.common.application.modules.LocalServiceRegistry;
+import com.twitter.common.net.InetSocketAddressHelper;
+
+import com.twitter.common.testing.easymock.EasyMockTest;
+
+import org.junit.Test;
+
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+
+public class LocalServiceRegistryWithOverridesTest extends EasyMockTest {
+  private InetSocketAddress localHost;
+  public LocalServiceRegistryWithOverridesTest() throws UnknownHostException {
+    this.localHost = InetSocketAddressHelper.getLocalAddress(8081);
+  }
+
+  private LocalServiceRegistryWithOverrides createMockServiceRegistry(
+      Optional<String> dnsOverride) throws Exception {
+    LocalServiceRegistry serviceRegistry = control.createMock(LocalServiceRegistry.class);
+    expect(serviceRegistry.getAuxiliarySockets()).andReturn(
+        ImmutableMap.of("http", InetSocketAddressHelper.getLocalAddress(8081)));
+
+    control.replay();
+    return new LocalServiceRegistryWithOverrides(
+        serviceRegistry,
+        new LocalServiceRegistryWithOverrides.Settings(dnsOverride));
+  }
+
+  @Test
+  public void testNoOverride() throws Exception {
+    LocalServiceRegistryWithOverrides registry = createMockServiceRegistry(
+        Optional.<String>absent());
+    InetSocketAddress addr = registry.getAuxiliarySockets().get("http");
+    assertEquals(addr.getHostString(), localHost.getHostString());
+  }
+
+  @Test
+  public void testOverride() throws Exception {
+    LocalServiceRegistryWithOverrides registry = createMockServiceRegistry(
+        Optional.of("www.google.com"));
+    InetSocketAddress addr = registry.getAuxiliarySockets().get("http");
+    assertEquals(addr.getHostString(), "www.google.com");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java b/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
index 5e54364..9fd188f 100644
--- a/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
@@ -214,7 +214,13 @@ public class SchedulerIT extends BaseZooKeeperTest {
     final SchedulerMain main = SchedulerMain.class.newInstance();
     injector = Guice.createInjector(
         ImmutableList.<Module>builder()
-            .addAll(main.getModules(CLUSTER_NAME, SERVERSET_PATH, zkClientConfig, STATS_URL_PREFIX))
+            .addAll(
+                main.getModules(
+                    CLUSTER_NAME,
+                    SERVERSET_PATH,
+                    zkClientConfig,
+                    STATS_URL_PREFIX,
+                    Optional.<String>absent()))
             .add(new LifecycleModule())
             .add(new AppLauncherModule())
             .add(new ZooKeeperClientModule(zkClientConfig))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java b/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java
index fbc3da3..652d247 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/JettyServerModuleTest.java
@@ -17,6 +17,7 @@ import java.net.InetSocketAddress;
 
 import javax.ws.rs.core.MediaType;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Throwables;
 import com.google.common.testing.TearDown;
 import com.google.common.util.concurrent.RateLimiter;
@@ -46,6 +47,7 @@ import com.twitter.thrift.ServiceInstance;
 import org.apache.aurora.gen.AuroraAdmin;
 import org.apache.aurora.gen.ServerInfo;
 import org.apache.aurora.scheduler.SchedulerServicesModule;
+import org.apache.aurora.scheduler.app.LocalServiceRegistryWithOverrides;
 import org.apache.aurora.scheduler.async.OfferQueue;
 import org.apache.aurora.scheduler.async.RescheduleCalculator;
 import org.apache.aurora.scheduler.async.TaskGroups.TaskGroupsSettings;
@@ -109,7 +111,8 @@ public abstract class JettyServerModuleTest extends EasyMockTest {
                     Amount.of(1L, Time.MILLISECONDS),
                     bindMock(BackoffStrategy.class),
                     RateLimiter.create(1000)));
-
+            bind(LocalServiceRegistryWithOverrides.Settings.class).toInstance(
+                new LocalServiceRegistryWithOverrides.Settings(Optional.<String>absent()));
             bind(new TypeLiteral<DynamicHostSet<ServiceInstance>>() { }).toInstance(schedulers);
             thrift = bindMock(AuroraAdmin.Iface.class);
             bindMock(CronJobManager.class);

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java b/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java
index c3bf5ea..7f80757 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/LeaderRedirectTest.java
@@ -37,6 +37,7 @@ import com.twitter.common.testing.easymock.EasyMockTest;
 import com.twitter.thrift.Endpoint;
 import com.twitter.thrift.ServiceInstance;
 
+import org.apache.aurora.scheduler.app.LocalServiceRegistryWithOverrides;
 import org.easymock.Capture;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -80,7 +81,10 @@ public class LeaderRedirectTest extends EasyMockTest {
     Set<ServiceRunner> services = ImmutableSet.of(fakeRunner);
     LocalServiceRegistry serviceRegistry =
         new LocalServiceRegistry(Providers.of(services), new ShutdownRegistryImpl());
-    leaderRedirector = new LeaderRedirect(serviceRegistry, schedulers);
+    LocalServiceRegistryWithOverrides withOverrides =
+        new LocalServiceRegistryWithOverrides(serviceRegistry,
+            new LocalServiceRegistryWithOverrides.Settings(Optional.<String>absent()));
+    leaderRedirector = new LeaderRedirect(withOverrides, schedulers);
 
     monitorCapture = new Capture<>();
     expect(schedulers.watch(capture(monitorCapture))).andReturn(null);

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3fa004b9/src/test/python/apache/aurora/executor/common/test_announcer.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/common/test_announcer.py b/src/test/python/apache/aurora/executor/common/test_announcer.py
index e329a90..6b78277 100644
--- a/src/test/python/apache/aurora/executor/common/test_announcer.py
+++ b/src/test/python/apache/aurora/executor/common/test_announcer.py
@@ -208,7 +208,11 @@ def make_assigned_task(thermos_config, assigned_ports=None):
       jobName=thermos_config.name().get(),
       executorConfig=executor_config)
 
-  return AssignedTask(instanceId=12345, task=task_config, assignedPorts=assigned_ports)
+  return AssignedTask(
+      instanceId=12345,
+      task=task_config,
+      assignedPorts=assigned_ports,
+      slaveHost='test-host')
 
 
 def make_job(role, environment, name, primary_port, portmap):


Mime
View raw message