This is an automated email from the ASF dual-hosted git repository. grag pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 654faf9244b0016f8a17623aca7812923b3a313a Author: Benjamin Bannier <bbann...@apache.org> AuthorDate: Mon Jul 15 10:26:23 2019 -0700 Cleared agent drain state when draining is finished. Once a draining agent has neither frameworks with pending tasks nor any executors with either queued or launched tasks it has finished draining. This patch adds handling of that case which clears both the in-memory and persisted drain configuration. Review: https://reviews.apache.org/r/70959/ --- src/slave/slave.cpp | 31 +++++++++++++++++++++++++++++++ src/slave/slave.hpp | 4 ++++ 2 files changed, 35 insertions(+) diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index eecd71e..2477975 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -7067,6 +7067,8 @@ void Slave::removeFramework(Framework* framework) // Pass ownership of the framework pointer. completedFrameworks.set(framework->id(), Owned<Framework>(framework)); + updateDrainStatus(); + if (state == TERMINATING && frameworks.empty()) { terminate(self()); } @@ -8944,6 +8946,8 @@ void Slave::removeOperation(Operation* operation) checkpointResourceState( totalResources.filter(mesos::needCheckpointing), false); + + updateDrainStatus(); } @@ -9768,6 +9772,33 @@ void Slave::initializeResourceProviderManager( } +void Slave::updateDrainStatus() +{ + if (drainConfig.isNone()) { + return; + } + + bool drained = operations.empty() && frameworks.empty(); + + if (!drained) { + return; + } + + LOG(INFO) << "Agent finished draining"; + + const string drainConfigPath = paths::getDrainConfigPath(metaDir, info.id()); + + Try<Nothing> rm = os::rm(drainConfigPath); + + if (rm.isError()) { + EXIT(EXIT_FAILURE) << "Could not remove persisted drain configuration " + << "'" << drainConfigPath << "': " << rm.error(); + } + + drainConfig = None(); +} + + Framework::Framework( Slave* _slave, const Flags& slaveFlags, diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp index 58bdd2a..58a5608 100644 --- a/src/slave/slave.hpp +++ b/src/slave/slave.hpp @@ -910,6 +910,10 @@ private: // If the agent is currently draining, contains the configuration used to // drain the agent. If NONE, the agent is not currently draining. Option<DrainConfig> drainConfig; + + // Check whether draining is finished and possibly remove + // both in-memory and persisted drain configuration. + void updateDrainStatus(); };