Updated Branches:
  refs/heads/master a8e36eb86 -> 8077ad40f

Fixed the slave to ignore messages not originating from the expected
master.

Review: https://reviews.apache.org/r/14541


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0eb61a35
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0eb61a35
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0eb61a35

Branch: refs/heads/master
Commit: 0eb61a351684938e65085abc52a01902a078d0de
Parents: a8e36eb
Author: Benjamin Mahler <bmah...@twitter.com>
Authored: Tue Oct 8 12:38:11 2013 -0700
Committer: Benjamin Mahler <bmah...@twitter.com>
Committed: Tue Oct 8 18:35:52 2013 -0700

----------------------------------------------------------------------
 src/slave/slave.cpp                 | 18 ++++++++++++++++++
 src/tests/balloon_framework_test.sh |  4 ++--
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0eb61a35/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 0ad4576..1dc2189 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -602,6 +602,12 @@ void Slave::noMasterDetected()
 
 void Slave::registered(const SlaveID& slaveId)
 {
+  if (from != master) {
+    LOG(WARNING) << "Ignoring registration message from " << from
+                 << " because it is not the expected master " << master;
+    return;
+  }
+
   switch(state) {
     case DISCONNECTED: {
       LOG(INFO) << "Registered with master " << master
@@ -643,6 +649,12 @@ void Slave::registered(const SlaveID& slaveId)
 
 void Slave::reregistered(const SlaveID& slaveId)
 {
+  if (from != master) {
+    LOG(WARNING) << "Ignoring re-registration message from " << from
+                 << " because it is not the expected master " << master;
+    return;
+  }
+
   switch(state) {
     case DISCONNECTED:
       LOG(INFO) << "Re-registered with master " << master;
@@ -773,6 +785,9 @@ void Slave::runTask(
     const string& pid,
     const TaskInfo& task)
 {
+  // TODO(bmahler): Consider ignoring requests not originating from the
+  // expected master.
+
   LOG(INFO) << "Got assigned task " << task.task_id()
             << " for framework " << frameworkId;
 
@@ -1043,6 +1058,9 @@ void Slave::_runTask(
 
 void Slave::killTask(const FrameworkID& frameworkId, const TaskID& taskId)
 {
+  // TODO(bmahler): Consider ignoring requests not originating from the
+  // expected master.
+
   LOG(INFO) << "Asked to kill task " << taskId
             << " of framework " << frameworkId;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/0eb61a35/src/tests/balloon_framework_test.sh
----------------------------------------------------------------------
diff --git a/src/tests/balloon_framework_test.sh 
b/src/tests/balloon_framework_test.sh
index 7229064..33946a5 100755
--- a/src/tests/balloon_framework_test.sh
+++ b/src/tests/balloon_framework_test.sh
@@ -73,7 +73,7 @@ unset MESOS_LAUNCHER_DIR
 unset MESOS_VERBOSE
 
 # Launch master.
-${MASTER} --port=5432 &
+${MASTER} --ip=127.0.0.1 --port=5432 &
 MASTER_PID=${!}
 echo "${GREEN}Launched master at ${MASTER_PID}${NORMAL}"
 sleep 2
@@ -92,7 +92,7 @@ SLAVE_WORK_DIR=`mktemp -d`
 
 ${SLAVE} \
     --work_dir=${SLAVE_WORK_DIR} \
-    --master=localhost:5432 \
+    --master=127.0.0.1:5432 \
     --isolation=cgroups \
     --cgroups_hierarchy=${TEST_CGROUP_HIERARCHY} \
     --cgroups_root=${TEST_CGROUP_ROOT} \

Reply via email to