Repository: mesos Updated Branches: refs/heads/master 7c7f8dd19 -> e4bd79489
Introduced a version during slave (re-)registration. Review: https://reviews.apache.org/r/26202 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2c46ccca Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2c46ccca Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2c46ccca Branch: refs/heads/master Commit: 2c46ccca68841d2f6b475812817225f21630a5e5 Parents: 5da57a7 Author: Benjamin Mahler <[email protected]> Authored: Thu Sep 25 18:11:12 2014 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Wed Oct 8 11:45:11 2014 -0700 ---------------------------------------------------------------------- src/master/master.cpp | 50 ++++++++++++++++++++++++++++------------ src/master/master.hpp | 19 +++++++++++---- src/messages/messages.proto | 10 ++++++++ src/slave/slave.cpp | 4 ++++ 4 files changed, 64 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/2c46ccca/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index eb7b210..03881df 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -579,14 +579,16 @@ void Master::initialize() install<RegisterSlaveMessage>( &Master::registerSlave, - &RegisterSlaveMessage::slave); + &RegisterSlaveMessage::slave, + &RegisterSlaveMessage::version); install<ReregisterSlaveMessage>( &Master::reregisterSlave, &ReregisterSlaveMessage::slave, &ReregisterSlaveMessage::executor_infos, &ReregisterSlaveMessage::tasks, - &ReregisterSlaveMessage::completed_frameworks); + &ReregisterSlaveMessage::completed_frameworks, + &ReregisterSlaveMessage::version); install<UnregisterSlaveMessage>( &Master::unregisterSlave, @@ -2876,7 +2878,10 @@ void Master::schedulerMessage( } -void Master::registerSlave(const UPID& from, const SlaveInfo& slaveInfo) +void Master::registerSlave( + const UPID& from, + const SlaveInfo& slaveInfo, + const string& version) { ++metrics.messages_register_slave; @@ -2885,7 +2890,7 @@ void Master::registerSlave(const UPID& from, const SlaveInfo& slaveInfo) << " because authentication is still in progress"; authenticating[from] - .onReady(defer(self(), &Self::registerSlave, from, slaveInfo)); + .onReady(defer(self(), &Self::registerSlave, from, slaveInfo, version)); return; } @@ -2950,6 +2955,7 @@ void Master::registerSlave(const UPID& from, const SlaveInfo& slaveInfo) &Self::_registerSlave, slaveInfo_, from, + version, lambda::_1)); } @@ -2957,6 +2963,7 @@ void Master::registerSlave(const UPID& from, const SlaveInfo& slaveInfo) void Master::_registerSlave( const SlaveInfo& slaveInfo, const UPID& pid, + const string& version, const Future<bool>& admit) { slaves.registering.erase(pid); @@ -2980,7 +2987,11 @@ void Master::_registerSlave( stringify(slaveInfo.id())); send(pid, message); } else { - Slave* slave = new Slave(slaveInfo, pid, Clock::now()); + Slave* slave = new Slave( + slaveInfo, + pid, + version.empty() ? Option<string>::none() : version, + Clock::now()); LOG(INFO) << "Registered slave " << *slave; ++metrics.slave_registrations; @@ -2995,7 +3006,8 @@ void Master::reregisterSlave( const SlaveInfo& slaveInfo, const vector<ExecutorInfo>& executorInfos, const vector<Task>& tasks, - const vector<Archive::Framework>& completedFrameworks) + const vector<Archive::Framework>& completedFrameworks, + const string& version) { ++metrics.messages_reregister_slave; @@ -3010,7 +3022,8 @@ void Master::reregisterSlave( slaveInfo, executorInfos, tasks, - completedFrameworks)); + completedFrameworks, + version)); return; } @@ -3130,13 +3143,14 @@ void Master::reregisterSlave( // registrar. registrar->apply(Owned<Operation>(new ReadmitSlave(slaveInfo))) .onAny(defer(self(), - &Self::_reregisterSlave, - slaveInfo, - from, - executorInfos, - tasks, - completedFrameworks, - lambda::_1)); + &Self::_reregisterSlave, + slaveInfo, + from, + executorInfos, + tasks, + completedFrameworks, + version, + lambda::_1)); } @@ -3146,6 +3160,7 @@ void Master::_reregisterSlave( const vector<ExecutorInfo>& executorInfos, const vector<Task>& tasks, const vector<Archive::Framework>& completedFrameworks, + const string& version, const Future<bool>& readmit) { slaves.reregistering.erase(slaveInfo.id()); @@ -3168,7 +3183,12 @@ void Master::_reregisterSlave( send(pid, message); } else { // Re-admission succeeded. - Slave* slave = new Slave(slaveInfo, pid, Clock::now()); + Slave* slave = new Slave( + slaveInfo, + pid, + version.empty() ? Option<string>::none() : version, + Clock::now()); + slave->reregisteredTime = Clock::now(); LOG(INFO) << "Re-registered slave " << *slave; http://git-wip-us.apache.org/repos/asf/mesos/blob/2c46ccca/src/master/master.hpp ---------------------------------------------------------------------- diff --git a/src/master/master.hpp b/src/master/master.hpp index 0f0b205..e97d213 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -157,13 +157,15 @@ public: const std::string& data); void registerSlave( const process::UPID& from, - const SlaveInfo& slaveInfo); + const SlaveInfo& slaveInfo, + const std::string& version); void reregisterSlave( const process::UPID& from, const SlaveInfo& slaveInfo, const std::vector<ExecutorInfo>& executorInfos, const std::vector<Task>& tasks, - const std::vector<Archive::Framework>& completedFrameworks); + const std::vector<Archive::Framework>& completedFrameworks, + const std::string& version); void unregisterSlave( const process::UPID& from, @@ -227,6 +229,7 @@ public: const std::vector<ExecutorInfo>& executorInfos, const std::vector<Task>& tasks, const std::vector<Archive::Framework>& completedFrameworks, + const std::string& version, const process::Future<bool>& readmit); MasterInfo info() const @@ -267,6 +270,7 @@ protected: void _registerSlave( const SlaveInfo& slaveInfo, const process::UPID& pid, + const std::string& version, const process::Future<bool>& admit); void __reregisterSlave( @@ -815,11 +819,13 @@ struct Slave { Slave(const SlaveInfo& _info, const process::UPID& _pid, - const process::Time& time) + const Option<std::string> _version, + const process::Time& _registeredTime) : id(_info.id()), info(_info), pid(_pid), - registeredTime(time), + version(_version), + registeredTime(_registeredTime), connected(true), active(true), observer(NULL) @@ -954,6 +960,11 @@ struct Slave process::UPID pid; + // The Mesos version of the slave. If set, the slave is >= 0.21.0. + // TODO(bmahler): Use stout's Version when it can parse labels, etc. + // TODO(bmahler): Make this required once it is always set. + const Option<std::string> version; + process::Time registeredTime; Option<process::Time> reregisteredTime; http://git-wip-us.apache.org/repos/asf/mesos/blob/2c46ccca/src/messages/messages.proto ---------------------------------------------------------------------- diff --git a/src/messages/messages.proto b/src/messages/messages.proto index 16d9d67..b8039ef 100644 --- a/src/messages/messages.proto +++ b/src/messages/messages.proto @@ -227,6 +227,11 @@ message FrameworkErrorMessage { message RegisterSlaveMessage { required SlaveInfo slave = 1; + + // NOTE: This is a hack for the master to detect the slave's + // version. If unset the slave is < 0.21.0. + // TODO(bmahler): Do proper versioning: MESOS-986. + optional string version = 2; } @@ -239,6 +244,11 @@ message ReregisterSlaveMessage { repeated ExecutorInfo executor_infos = 4; repeated Task tasks = 3; repeated Archive.Framework completed_frameworks = 5; + + // NOTE: This is a hack for the master to detect the slave's + // version. If unset the slave is < 0.21.0. + // TODO(bmahler): Do proper versioning: MESOS-986. + optional string version = 6; } http://git-wip-us.apache.org/repos/asf/mesos/blob/2c46ccca/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index ee3d649..809b008 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -882,11 +882,15 @@ void Slave::doReliableRegistration(const Duration& duration) if (!info.has_id()) { // Registering for the first time. RegisterSlaveMessage message; + message.set_version(MESOS_VERSION); message.mutable_slave()->CopyFrom(info); + send(master.get(), message); } else { // Re-registering, so send tasks running. ReregisterSlaveMessage message; + message.set_version(MESOS_VERSION); + // TODO(bmahler): Remove in 0.22.0. message.mutable_slave_id()->CopyFrom(info.id()); message.mutable_slave()->CopyFrom(info);
