This is an automated email from the ASF dual-hosted git repository. asekretenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push: new ff720df Fixed handling disconnected agents by REACTIVATE_AGENT call. ff720df is described below commit ff720df995daae76803f13f54f8129166663a0d3 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 c51d9fd..f34ea54 100644 --- a/src/master/http.cpp +++ b/src/master/http.cpp @@ -3974,8 +3974,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 a8cca62..6a013e3 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -3402,18 +3402,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, @@ -7250,7 +7238,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 a57237d..214307f 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -686,10 +686,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,