This is an automated email from the ASF dual-hosted git repository. asekretenko pushed a commit to branch 1.9.x in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/1.9.x by this push: new 70291ed Fixed handling disconnected agents by REACTIVATE_AGENT call. 70291ed is described below commit 70291edf09f5b35af2b5389024de84b550ccacf3 Author: Andrei Sekretenko <asekrete...@apache.org> AuthorDate: Tue Apr 14 20:05:11 2020 +0200 Fixed handling disconnected agents by REACTIVATE_AGENT call. This patch fixes MESOS-10116 by preventing REACTIVATE_AGENT from activating disconnected agents in the allocator and also fixes the handling of agents that were removed while the reactivation was being stored into the registry. Review: https://reviews.apache.org/r/72363 --- src/master/http.cpp | 14 ++++++++++++-- src/master/master.cpp | 17 ++++------------- src/master/master.hpp | 4 ---- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/master/http.cpp b/src/master/http.cpp index 9cfdc77..db456b5 100644 --- a/src/master/http.cpp +++ b/src/master/http.cpp @@ -4145,8 +4145,18 @@ Future<Response> Master::Http::_reactivateAgent( master->slaves.deactivated.erase(slaveId); Slave* slave = master->slaves.registered.get(slaveId); - if (slave != nullptr) { - master->reactivate(slave); + if (slave == nullptr) { + return Conflict("Agent removed while processing the call"); + } + + if (slave->connected) { + LOG(INFO) << "Reactivating agent " << *slave; + + slave->active = true; + master->allocator->activateSlave(slaveId); + } else { + LOG(INFO) << "Disconnected agent " << *slave + << " will be reactivated upon reregistration."; } slave->estimatedDrainStartTime = None(); diff --git a/src/master/master.cpp b/src/master/master.cpp index a99f0eb..f641adc 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -3447,18 +3447,6 @@ void Master::deactivate(Slave* slave) } -void Master::reactivate(Slave* slave) -{ - CHECK_NOTNULL(slave); - CHECK(!slaves.deactivated.contains(slave->id)); - - LOG(INFO) << "Reactivating agent " << *slave; - - slave->active = true; - allocator->activateSlave(slave->id); -} - - void Master::resourceRequest( const UPID& from, const FrameworkID& frameworkId, @@ -8173,7 +8161,10 @@ void Master::___reregisterSlave( dispatch(slave->observer, &SlaveObserver::reconnect); if (!slaves.deactivated.contains(slave->id)) { - reactivate(slave); + LOG(INFO) << "Reactivating re-registered agent " << *slave; + + slave->active = true; + allocator->activateSlave(slave->id); } } diff --git a/src/master/master.hpp b/src/master/master.hpp index c4a1e62..7dc6248 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -685,10 +685,6 @@ protected: // offers). Other aspects of the agent will continue to function normally. void deactivate(Slave* slave); - // Adds the agent back to the resource offer cycle. - // Must *NOT* be called if the agent is `deactivated`. - void reactivate(Slave* slave); - // Add a slave. void addSlave( Slave* slave,