Added more assertions to the master.

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


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

Branch: refs/heads/master
Commit: 3cecdbdd4b727567c621f999fb8df45116f0a979
Parents: ac26919
Author: Neil Conway <neil.con...@gmail.com>
Authored: Mon Sep 19 15:47:33 2016 -0700
Committer: Vinod Kone <vinodk...@gmail.com>
Committed: Mon Sep 19 15:47:33 2016 -0700

----------------------------------------------------------------------
 src/master/master.cpp | 11 +++++++++--
 src/master/master.hpp |  3 ---
 2 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3cecdbdd/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index d5a194b..34de462 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -5183,6 +5183,9 @@ void Master::_reregisterSlave(
   // example.
   bool slaveWasRemoved = slaves.removed.get(slave->id).isSome();
 
+  slaves.removed.erase(slave->id);
+  slaves.unreachable.erase(slave->id);
+
   addSlave(slave, completedFrameworks);
 
   Duration pingTimeout =
@@ -5673,6 +5676,9 @@ void Master::markUnreachable(const SlaveID& slaveId)
   LOG(INFO) << "Marking agent " << *slave
             << " unreachable: health check timed out";
 
+  CHECK(!slaves.unreachable.contains(slaveId));
+  CHECK(slaves.removed.get(slaveId).isNone());
+
   // We want to remove the slave first, to avoid the allocator
   // re-allocating the recovered resources.
   //
@@ -7036,9 +7042,10 @@ void Master::addSlave(
     const vector<Archive::Framework>& completedFrameworks)
 {
   CHECK_NOTNULL(slave);
+  CHECK(!slaves.registered.contains(slave->id));
+  CHECK(!slaves.unreachable.contains(slave->id));
+  CHECK(slaves.removed.get(slave->id).isNone());
 
-  slaves.removed.erase(slave->id);
-  slaves.unreachable.erase(slave->id);
   slaves.registered.put(slave);
 
   link(slave->pid);

http://git-wip-us.apache.org/repos/asf/mesos/blob/3cecdbdd/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 6aeb1b9..7e50359 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -1928,9 +1928,6 @@ protected:
       }
     }
 
-    // TODO(neilc): Check if the slave appears in the list of
-    // `unreachable` slaves in the registry?
-
     Registry::Slave* slave = registry->mutable_slaves()->add_slaves();
     slave->mutable_info()->CopyFrom(info);
     slaveIDs->insert(info.id());

Reply via email to