This is an automated email from the ASF dual-hosted git repository. bmahler pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 244c27b61a63948905225c34d2cc833c3e2a55de Author: Andrei Sekretenko <[email protected]> AuthorDate: Sat Jun 15 12:23:12 2019 -0400 Made scheduler driver's updateFramework() require FrameworkInfo with ID. This patch makes it mandatory for the caller to fill the 'id' field of the FrameworkInfo passed into MesosSchedulerDriver::updateFramework(). Review: https://reviews.apache.org/r/70854/ --- include/mesos/scheduler.hpp | 18 ++++++++++++------ src/sched/sched.cpp | 26 +++++++++++++++----------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/include/mesos/scheduler.hpp b/include/mesos/scheduler.hpp index c5e61d4..8c67748 100644 --- a/include/mesos/scheduler.hpp +++ b/include/mesos/scheduler.hpp @@ -318,15 +318,21 @@ public: virtual Status reconcileTasks( const std::vector<TaskStatus>& statuses) = 0; - // Updates the FrameworkInfo with the provided value (except for the - // framework_id field, which should not be set by the caller). - // The driver implementation should send the supplied FrameworkInfo update - // to the master. Also, all the next re-registration attempts will be - // performed with the provided FrameworkInfo. + // Inform Mesos master about changes to the `FrameworkInfo`. The + // driver will store the new `FrameworkInfo` and all subsequent + // re-registrations will use it. // // NOTE: If the supplied info is invalid or fails authorization, // the `error()` callback will be invoked asynchronously (after - // the master replies with a FrameworkErrorMessage). + // the master replies with a `FrameworkErrorMessage`). + // + // NOTE: This must be called after initial registration with the + // master completes and the `FrameworkID` is assigned. The assigned + // `FrameworkID` must be set in `frameworkInfo`. + // + // NOTE: The `FrameworkInfo.user` and `FrameworkInfo.hostname` + // fields will be auto-populated using the same approach used + // during driver initialization. virtual Status updateFramework(const FrameworkInfo& frameworkInfo) = 0; }; diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp index 281236b..e6cc534 100644 --- a/src/sched/sched.cpp +++ b/src/sched/sched.cpp @@ -1597,12 +1597,22 @@ protected: void updateFramework(const FrameworkInfo& framework_) { - CHECK(!framework_.has_id()); + if (!framework.has_id() || framework.id().value().empty()) { + error("MesosSchedulerDriver::updateFramework() must not be called" + " prior to registration with the master"); + return; + } + + if (framework_.id() != framework.id()) { + error("The 'FrameworkInfo.id' provided to" + " MesosSchedulerDriver::updateFramework()" + " (" + stringify(framework_.id()) + ")" + " must be equal to the value known to the MesosSchedulerDriver" + " (" + stringify(framework.id()) + ")"); + return; + } - // Update the FrameworkInfo used for re-registration - FrameworkID frameworkId = framework.id(); framework = framework_; - *framework.mutable_id() = std::move(frameworkId); if (connected) { sendUpdateFramework(); @@ -2332,6 +2342,7 @@ Status MesosSchedulerDriver::reconcileTasks( } } + Status MesosSchedulerDriver::updateFramework(const FrameworkInfo& update) { synchronized (mutex) { @@ -2339,13 +2350,6 @@ Status MesosSchedulerDriver::updateFramework(const FrameworkInfo& update) return status; } - if (update.has_id()) { - LOG(ERROR) << "MesosSchedulerDriver::updateFramework should not be called" - << " with 'FrameworkInfo.id' set, aborting driver"; - abort(); - return status; - } - framework = update; fillMissingFrameworkInfoFields(&framework);
