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
commit 4150559ab29e37c8b5d65024ce3a728b359de2f1 Author: Andrei Sekretenko <asekrete...@apache.org> AuthorDate: Wed Oct 14 17:46:46 2020 +0200 Moved failover timeout validation to stateless FrameworkInfo validation. This turns the validation of the failover timeout in `FrameworkInfo` into a part of `validation::framework::validate()` that performs all the other validations that depend on `FrameworkInfo` only. Review: https://reviews.apache.org/r/72964 --- src/master/master.cpp | 13 ------------- src/master/validation.cpp | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/master/master.cpp b/src/master/master.cpp index d6d3ea7..6c0523d 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -157,8 +157,6 @@ using mesos::master::detector::MasterDetector; using mesos::scheduler::OfferConstraints; -static bool isValidFailoverTimeout(const FrameworkInfo& frameworkInfo); - class SlaveObserver : public ProtobufProcess<SlaveObserver> { @@ -2612,11 +2610,6 @@ Option<Error> Master::validateFramework( return Error("Framework has been removed"); } - if (!isValidFailoverTimeout(frameworkInfo)) { - return Error("The framework failover_timeout (" + - stringify(frameworkInfo.failover_timeout()) + - ") is invalid"); - } return Option<Error>::none(); } @@ -12319,12 +12312,6 @@ double Master::_resources_revocable_percent(const string& name) } -static bool isValidFailoverTimeout(const FrameworkInfo& frameworkInfo) -{ - return Duration::create(frameworkInfo.failover_timeout()).isSome(); -} - - void Master::Subscribers::send( const mesos::master::Event& event, const Option<FrameworkInfo>& frameworkInfo, diff --git a/src/master/validation.cpp b/src/master/validation.cpp index 5b1bcb5..feeea8e 100644 --- a/src/master/validation.cpp +++ b/src/master/validation.cpp @@ -560,13 +560,25 @@ Option<Error> validateOfferFilters(const FrameworkInfo& frameworkInfo) return None(); } + +Option<Error> validateFailoverTimeout(const FrameworkInfo& frameworkInfo) +{ + if (Duration::create(frameworkInfo.failover_timeout()).isSome()) { + return None(); + } + + return Error( + "The framework failover_timeout (" + + stringify(frameworkInfo.failover_timeout()) + ") is invalid"); +} + } // namespace internal { Option<Error> validate(const mesos::FrameworkInfo& frameworkInfo) { // TODO(jay_guo): This currently only validates the role(s), - // framework ID and offer filters, validate more fields! + // framework ID, offer filters and failover timeout, validate more fields! Option<Error> error = internal::validateRoles(frameworkInfo); if (error.isSome()) { @@ -585,6 +597,12 @@ Option<Error> validate(const mesos::FrameworkInfo& frameworkInfo) return error; } + error = internal::validateFailoverTimeout(frameworkInfo); + + if(error.isSome()) { + return error; + } + return None(); }