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 b2cfcecb34e76b9a5380bf27f8a2b650510ed158 Author: Greg Mann <[email protected]> AuthorDate: Fri Jun 28 13:13:58 2019 -0700 Added agent capability for agent draining. This patch adds a new required agent capability, AGENT_DRAINING, which indicates to the master that the agent is capable of handling automatic task draining via the `DrainSlaveMessage`. Review: https://reviews.apache.org/r/70839/ --- include/mesos/mesos.proto | 4 ++++ include/mesos/v1/mesos.proto | 4 ++++ src/common/protobuf_utils.cpp | 3 ++- src/common/protobuf_utils.hpp | 7 +++++++ src/slave/constants.cpp | 4 +++- src/slave/flags.cpp | 12 +++++++----- src/tests/master_tests.cpp | 3 ++- src/tests/slave_tests.cpp | 3 ++- 8 files changed, 31 insertions(+), 9 deletions(-) diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto index e3fbe1c..6869413 100644 --- a/include/mesos/mesos.proto +++ b/include/mesos/mesos.proto @@ -1042,6 +1042,10 @@ message SlaveInfo { // handle feedback for operations on agent default resources, the // RESOURCE_PROVIDER capability should be set as well. AGENT_OPERATION_FEEDBACK = 6; + + // This expresses the ability for the agent to automatically drain tasks + // in preparation for operator maintenance. This capability is required. + AGENT_DRAINING = 7; } // Enum fields should be optional, see: MESOS-4997. diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto index e198813..158db35 100644 --- a/include/mesos/v1/mesos.proto +++ b/include/mesos/v1/mesos.proto @@ -1034,6 +1034,10 @@ message AgentInfo { // handle feedback for operations on agent default resources, the // RESOURCE_PROVIDER capability should be set as well. AGENT_OPERATION_FEEDBACK = 6; + + // This expresses the ability for the agent to automatically drain tasks + // in preparation for operator maintenance. This capability is required. + AGENT_DRAINING = 7; } // Enum fields should be optional, see: MESOS-4997. diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp index 9ff0cf5..c5f762b 100644 --- a/src/common/protobuf_utils.cpp +++ b/src/common/protobuf_utils.cpp @@ -1135,7 +1135,8 @@ bool operator==(const Capabilities& left, const Capabilities& right) left.reservationRefinement == right.reservationRefinement && left.resourceProvider == right.resourceProvider && left.resizeVolume == right.resizeVolume && - left.agentOperationFeedback == right.agentOperationFeedback; + left.agentOperationFeedback == right.agentOperationFeedback && + left.agentDraining == right.agentDraining; } diff --git a/src/common/protobuf_utils.hpp b/src/common/protobuf_utils.hpp index f6ea923..cf52ccd 100644 --- a/src/common/protobuf_utils.hpp +++ b/src/common/protobuf_utils.hpp @@ -334,6 +334,9 @@ struct Capabilities case SlaveInfo::Capability::AGENT_OPERATION_FEEDBACK: agentOperationFeedback = true; break; + case SlaveInfo::Capability::AGENT_DRAINING: + agentDraining = true; + break; // If adding another case here be sure to update the // equality operator. } @@ -347,6 +350,7 @@ struct Capabilities bool resourceProvider = false; bool resizeVolume = false; bool agentOperationFeedback = false; + bool agentDraining = false; google::protobuf::RepeatedPtrField<SlaveInfo::Capability> toRepeatedPtrField() const @@ -370,6 +374,9 @@ struct Capabilities if (agentOperationFeedback) { result.Add()->set_type(SlaveInfo::Capability::AGENT_OPERATION_FEEDBACK); } + if (agentDraining) { + result.Add()->set_type(SlaveInfo::Capability::AGENT_DRAINING); + } return result; } diff --git a/src/slave/constants.cpp b/src/slave/constants.cpp index 4c29b00..1963890 100644 --- a/src/slave/constants.cpp +++ b/src/slave/constants.cpp @@ -41,7 +41,9 @@ vector<SlaveInfo::Capability> AGENT_CAPABILITIES() SlaveInfo::Capability::RESERVATION_REFINEMENT, SlaveInfo::Capability::RESOURCE_PROVIDER, SlaveInfo::Capability::RESIZE_VOLUME, - SlaveInfo::Capability::AGENT_OPERATION_FEEDBACK}; + SlaveInfo::Capability::AGENT_OPERATION_FEEDBACK, + SlaveInfo::Capability::AGENT_DRAINING, + }; vector<SlaveInfo::Capability> result; foreach (SlaveInfo::Capability::Type type, types) { diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp index 9e26db0..b4e3eb9 100644 --- a/src/slave/flags.cpp +++ b/src/slave/flags.cpp @@ -798,8 +798,8 @@ mesos::internal::slave::Flags::Flags() add(&Flags::agent_features, "agent_features", "JSON representation of agent features to whitelist. We always require\n" - "'MULTI_ROLE', 'HIERARCHICAL_ROLE', 'RESERVATION_REFINEMENT', and\n" - "'AGENT_OPERATION_FEEDBACK'.\n" + "'MULTI_ROLE', 'HIERARCHICAL_ROLE', 'RESERVATION_REFINEMENT',\n" + "'AGENT_OPERATION_FEEDBACK', and 'AGENT_DRAINING'.\n" "\n" "Example:\n" "{\n" @@ -807,7 +807,8 @@ mesos::internal::slave::Flags::Flags() " {\"type\": \"MULTI_ROLE\"},\n" " {\"type\": \"HIERARCHICAL_ROLE\"},\n" " {\"type\": \"RESERVATION_REFINEMENT\"},\n" - " {\"type\": \"AGENT_OPERATION_FEEDBACK\"}\n" + " {\"type\": \"AGENT_OPERATION_FEEDBACK\"},\n" + " {\"type\": \"AGENT_DRAINING\"}\n" " ]\n" "}\n", [](const Option<SlaveCapabilities>& agentFeatures) -> Option<Error> { @@ -819,11 +820,12 @@ mesos::internal::slave::Flags::Flags() if (!capabilities.multiRole || !capabilities.hierarchicalRole || !capabilities.reservationRefinement || - !capabilities.agentOperationFeedback) { + !capabilities.agentOperationFeedback || + !capabilities.agentDraining) { return Error( "At least the following agent features need to be enabled:" " MULTI_ROLE, HIERARCHICAL_ROLE, RESERVATION_REFINEMENT," - " AGENT_OPERATION_FEEDBACK"); + " AGENT_OPERATION_FEEDBACK, and AGENT_DRAINING"); } if (capabilities.resizeVolume && !capabilities.resourceProvider) { diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp index d7b4613..f817450 100644 --- a/src/tests/master_tests.cpp +++ b/src/tests/master_tests.cpp @@ -5314,7 +5314,8 @@ TEST_F(MasterTest, StateEndpointAgentCapabilities) "RESERVATION_REFINEMENT", "RESOURCE_PROVIDER", "RESIZE_VOLUME", - "AGENT_OPERATION_FEEDBACK" + "AGENT_OPERATION_FEEDBACK", + "AGENT_DRAINING" ] )~"); diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp index 7ba2df9..5d930bd 100644 --- a/src/tests/slave_tests.cpp +++ b/src/tests/slave_tests.cpp @@ -1545,7 +1545,8 @@ TEST_F(SlaveTest, StateEndpoint) "RESERVATION_REFINEMENT", "RESOURCE_PROVIDER", "RESIZE_VOLUME", - "AGENT_OPERATION_FEEDBACK" + "AGENT_OPERATION_FEEDBACK", + "AGENT_DRAINING" ] )~");
