Repository: mesos Updated Branches: refs/heads/master 607374b53 -> 0842dd70c
Added an event to publish resources. Before launching a task that use resource provider resources, the Mesos master will instruct the resource provider to make these resources available for the task. External resource providers will checkpoint informations to be able to reconcile resource usage in case of a failover. Resource providers will acknowledge the 'PUBLISH' operations by sending back 'ACKNOWLEDGE_PUBLISH' together with the UUID of the operation. Review: https://reviews.apache.org/r/62502/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f8c40a72 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f8c40a72 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f8c40a72 Branch: refs/heads/master Commit: f8c40a72e57bf4a2d5072bf788a69531b6a6dfa6 Parents: 607374b Author: Jan Schlicht <j...@mesosphere.io> Authored: Tue Nov 21 14:41:48 2017 -0800 Committer: Jie Yu <yujie....@gmail.com> Committed: Tue Nov 21 14:41:48 2017 -0800 ---------------------------------------------------------------------- .../resource_provider/resource_provider.proto | 23 ++++++++++++++++++++ .../resource_provider/resource_provider.proto | 15 +++++++++++++ src/resource_provider/manager.cpp | 5 +++++ src/resource_provider/storage/provider.cpp | 4 ++++ src/resource_provider/validation.cpp | 12 ++++++++++ src/tests/mesos.hpp | 4 ++++ 6 files changed, 63 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/f8c40a72/include/mesos/resource_provider/resource_provider.proto ---------------------------------------------------------------------- diff --git a/include/mesos/resource_provider/resource_provider.proto b/include/mesos/resource_provider/resource_provider.proto index 1e44b95..615a2ab 100644 --- a/include/mesos/resource_provider/resource_provider.proto +++ b/include/mesos/resource_provider/resource_provider.proto @@ -34,6 +34,7 @@ message Event { SUBSCRIBED = 1; // See 'Subscribed' below. OPERATION = 2; // See 'Operation' below. + PUBLISH = 3; // See 'Publish' below. } // First event received by the resource provider when it subscribes @@ -68,9 +69,17 @@ message Event { required bytes resource_version_uuid = 4; } + // Received when the master wants to launch a task using resources + // of this resource provider. + message Publish { + required bytes uuid = 1; + repeated Resource resources = 2; + } + optional Type type = 1; optional Subscribed subscribed = 2; optional Operation operation = 3; + optional Publish publish = 4; } @@ -85,6 +94,7 @@ message Call { SUBSCRIBE = 1; // See 'Subscribe'. UPDATE_OFFER_OPERATION_STATUS = 2; // See 'UpdateOfferOperationStatus'. UPDATE_STATE = 3; // See 'UpdateState'. + ACKNOWLEDGE_PUBLISH = 4; // See 'AcknowledgePublish'. } // Request to subscribe with the master. @@ -128,6 +138,18 @@ message Call { required bytes resource_version_uuid = 3; } + message AcknowledgePublish { + enum Status { + UNKNOWN = 0; + OK = 1; + FAILED = 2; + } + + required bytes uuid = 1; + + required Status status = 2; + } + // Identifies who generated this call. // The 'ResourceProviderManager' assigns a resource provider ID when // a new resource provider subscribes for the first time. Once @@ -142,4 +164,5 @@ message Call { optional Subscribe subscribe = 3; optional UpdateOfferOperationStatus update_offer_operation_status = 4; optional UpdateState update_state = 5; + optional AcknowledgePublish acknowledge_publish = 6; } http://git-wip-us.apache.org/repos/asf/mesos/blob/f8c40a72/include/mesos/v1/resource_provider/resource_provider.proto ---------------------------------------------------------------------- diff --git a/include/mesos/v1/resource_provider/resource_provider.proto b/include/mesos/v1/resource_provider/resource_provider.proto index 3956f82..7197b9b 100644 --- a/include/mesos/v1/resource_provider/resource_provider.proto +++ b/include/mesos/v1/resource_provider/resource_provider.proto @@ -34,6 +34,7 @@ message Event { SUBSCRIBED = 1; // See 'Subscribed' below. OPERATION = 2; // See 'Operation' below. + PUBLISH = 3; // See 'Publish' below. } // First event received by the resource provider when it subscribes @@ -68,9 +69,17 @@ message Event { required bytes resource_version_uuid = 4; } + // Received when the master wants to launch a task using resources + // of this resource provider. + message Publish { + required bytes uuid = 1; + repeated Resource resources = 2; + } + optional Type type = 1; optional Subscribed subscribed = 2; optional Operation operation = 3; + optional Publish publish = 4; } @@ -85,6 +94,7 @@ message Call { SUBSCRIBE = 1; // See 'Subscribe'. UPDATE_OFFER_OPERATION_STATUS = 2; // See 'UpdateOfferOperationStatus'. UPDATE_STATE = 3; // See 'UpdateState'. + ACKNOWLEDGE_PUBLISH = 4; // See 'AcknowledgePublish'. } // Request to subscribe with the master. @@ -128,6 +138,10 @@ message Call { required bytes resource_version_uuid = 3; } + message AcknowledgePublish { + required bytes uuid = 1; + } + // Identifies who generated this call. // The 'ResourceProviderManager' assigns a resource provider ID when // a new resource provider subscribes for the first time. Once @@ -142,4 +156,5 @@ message Call { optional Subscribe subscribe = 3; optional UpdateOfferOperationStatus update_offer_operation_status = 4; optional UpdateState update_state = 5; + optional AcknowledgePublish acknowledge_publish = 6; } http://git-wip-us.apache.org/repos/asf/mesos/blob/f8c40a72/src/resource_provider/manager.cpp ---------------------------------------------------------------------- diff --git a/src/resource_provider/manager.cpp b/src/resource_provider/manager.cpp index 6dfc429..988442a 100644 --- a/src/resource_provider/manager.cpp +++ b/src/resource_provider/manager.cpp @@ -302,6 +302,11 @@ Future<http::Response> ResourceProviderManagerProcess::api( updateState(&resourceProvider, call.update_state()); return Accepted(); } + + case Call::ACKNOWLEDGE_PUBLISH: { + // TODO(nfnt): Add a 'ACKNOWLEDGE_PUBLISH' handler. + return NotImplemented(); + } } UNREACHABLE(); http://git-wip-us.apache.org/repos/asf/mesos/blob/f8c40a72/src/resource_provider/storage/provider.cpp ---------------------------------------------------------------------- diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp index 4622499..49c042c 100644 --- a/src/resource_provider/storage/provider.cpp +++ b/src/resource_provider/storage/provider.cpp @@ -104,6 +104,10 @@ void StorageLocalResourceProviderProcess::received(const Event& event) CHECK(event.has_operation()); break; } + case Event::PUBLISH: { + CHECK(event.has_publish()); + break; + } case Event::UNKNOWN: { LOG(WARNING) << "Received an UNKNOWN event and ignored"; break; http://git-wip-us.apache.org/repos/asf/mesos/blob/f8c40a72/src/resource_provider/validation.cpp ---------------------------------------------------------------------- diff --git a/src/resource_provider/validation.cpp b/src/resource_provider/validation.cpp index ddc57c3..75556c0 100644 --- a/src/resource_provider/validation.cpp +++ b/src/resource_provider/validation.cpp @@ -73,6 +73,18 @@ Option<Error> validate(const Call& call) return None(); } + + case Call::ACKNOWLEDGE_PUBLISH: { + if (!call.has_resource_provider_id()) { + return Error("Expecting 'resource_provider_id' to be present"); + } + + if (!call.has_acknowledge_publish()) { + return Error("Expecting 'acknowledge_publish' to be present."); + } + + return None(); + } } UNREACHABLE(); http://git-wip-us.apache.org/repos/asf/mesos/blob/f8c40a72/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index 30b8ac5..41292c8 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -2664,6 +2664,7 @@ public: MOCK_METHOD0_T(disconnected, void()); MOCK_METHOD1_T(subscribed, void(const typename Event::Subscribed&)); MOCK_METHOD1_T(operation, void(const typename Event::Operation&)); + MOCK_METHOD1_T(publish, void(const typename Event::Publish&)); void events(std::queue<Event> events) { @@ -2678,6 +2679,9 @@ public: case Event::OPERATION: operation(event.operation()); break; + case Event::PUBLISH: + publish(event.publish()); + break; case Event::UNKNOWN: LOG(FATAL) << "Received unexpected UNKNOWN event"; break;