Added resource version uuid for offer operations. The resource version UUID is used to establish the relationship between the operation and the resources that the operation is operating on. Each resource provider will keep a resource version UUID, and change it when it believes that the resources from this resource provider are out of sync from the master's view. The master will keep track of the last known resource version UUID for each resource provider, and attach the resource version UUID in each operation it sends out. The resource provider should reject operations that have a different resource version UUID than that it maintains, because this means the operation is operating on resources that might have already been invalidated.
Review: https://reviews.apache.org/r/63094 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6b9d0c54 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6b9d0c54 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6b9d0c54 Branch: refs/heads/master Commit: 6b9d0c5426fa7c0a827b8e795264b4ddc9a80aa9 Parents: 9490730 Author: Jie Yu <[email protected]> Authored: Tue Oct 17 16:02:24 2017 -0700 Committer: Jie Yu <[email protected]> Committed: Sun Oct 29 15:57:28 2017 +0100 ---------------------------------------------------------------------- .../resource_provider/resource_provider.proto | 28 ++++++++++++++ .../resource_provider/resource_provider.proto | 28 ++++++++++++++ src/messages/messages.proto | 39 ++++++++++++++++++++ src/tests/resource_provider_manager_tests.cpp | 1 + .../resource_provider_validation_tests.cpp | 3 +- 5 files changed, 98 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/6b9d0c54/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 1b26f89..1e44b95 100644 --- a/include/mesos/resource_provider/resource_provider.proto +++ b/include/mesos/resource_provider/resource_provider.proto @@ -52,6 +52,20 @@ message Event { // independently from the framework-specified operation ID, which // is optional. required bytes operation_uuid = 3; + + // Used to establish the relationship between the operation and + // the resources that the operation is operating on. Each resource + // provider will keep a resource version UUID, and change it when + // it believes that the resources from this resource provider are + // out of sync from the master's view. The master will keep track + // of the last known resource version UUID for each resource + // provider, and attach the resource version UUID in each + // operation it sends out. The resource provider should reject + // operations that have a different resource version UUID than + // that it maintains, because this means the operation is + // operating on resources that might have already been + // invalidated. + required bytes resource_version_uuid = 4; } optional Type type = 1; @@ -98,6 +112,20 @@ message Call { // The total resources provided by this resource provider. repeated Resource resources = 2; + + // Used to establish the relationship between the operation and + // the resources that the operation is operating on. Each resource + // provider will keep a resource version UUID, and change it when + // it believes that the resources from this resource provider are + // out of sync from the master's view. The master will keep track + // of the last known resource version UUID for each resource + // provider, and attach the resource version UUID in each + // operation it sends out. The resource provider should reject + // operations that have a different resource version UUID than + // that it maintains, because this means the operation is + // operating on resources that might have already been + // invalidated. + required bytes resource_version_uuid = 3; } // Identifies who generated this call. http://git-wip-us.apache.org/repos/asf/mesos/blob/6b9d0c54/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 3afdbb9..3956f82 100644 --- a/include/mesos/v1/resource_provider/resource_provider.proto +++ b/include/mesos/v1/resource_provider/resource_provider.proto @@ -52,6 +52,20 @@ message Event { // independently from the framework specified operation id, which is // optional. required bytes operation_uuid = 3; + + // Used to establish the relationship between the operation and + // the resources that the operation is operating on. Each resource + // provider will keep a resource version UUID, and change it when + // it believes that the resources from this resource provider are + // out of sync from the master's view. The master will keep track + // of the last known resource version UUID for each resource + // provider, and attach the resource version UUID in each + // operation it sends out. The resource provider should reject + // operations that have a different resource version UUID than + // that it maintains, because this means the operation is + // operating on resources that might have already been + // invalidated. + required bytes resource_version_uuid = 4; } optional Type type = 1; @@ -98,6 +112,20 @@ message Call { // The total resources provided by this resource provider. repeated Resource resources = 2; + + // Used to establish the relationship between the operation and + // the resources that the operation is operating on. Each resource + // provider will keep a resource version UUID, and change it when + // it believes that the resources from this resource provider are + // out of sync from the master's view. The master will keep track + // of the last known resource version UUID for each resource + // provider, and attach the resource version UUID in each + // operation it sends out. The resource provider should reject + // operations that have a different resource version UUID than + // that it maintains, because this means the operation is + // operating on resources that might have already been + // invalidated. + required bytes resource_version_uuid = 3; } // Identifies who generated this call. http://git-wip-us.apache.org/repos/asf/mesos/blob/6b9d0c54/src/messages/messages.proto ---------------------------------------------------------------------- diff --git a/src/messages/messages.proto b/src/messages/messages.proto index 063a7c0..9dfe7f0 100644 --- a/src/messages/messages.proto +++ b/src/messages/messages.proto @@ -605,6 +605,19 @@ message CheckpointResourcesMessage { /** + * Describes a resource version using a UUID. It is used to establish + * the relationship between an offer operation and the resources that + * offer operation is operating on. + */ +message ResourceVersionUUID { + // If not set, it represents resources directly from the agent (not + // having a backing resource provider). + optional ResourceProviderID resource_provider_id = 1; + required bytes uuid = 2; +} + + +/** * This message is sent by the agent to the master to inform the * master about the total amount of oversubscribed (allocated and * allocatable), or total resources. For `RESOURCE_PROVIDER` capable @@ -639,6 +652,19 @@ message UpdateSlaveMessage { // Pending operations or terminal operations that have // unacknowledged status updates, which are known to this agent. optional OfferOperations offer_operations = 6; + + // Used to establish the relationship between the operation and the + // resources that the operation is operating on. Each resource + // provider will keep a resource version UUID, and change it when + // it believes that the resources from this resource provider are + // out of sync from the master's view. The master will keep track + // of the last known resource version UUID for each resource + // provider, and attach the resource version UUID in each operation + // it sends out. The resource provider should reject operations that + // have a different resource version UUID than that it maintains, + // because this means the operation is operating on resources that + // might have already been invalidated. + repeated ResourceVersionUUID resource_version_uuids = 7; } @@ -675,6 +701,19 @@ message ApplyOfferOperationMessage { // independently from the framework-specified operation ID, which is // optional. required bytes operation_uuid = 3; + + // Used to establish the relationship between the operation and the + // resources that the operation is operating on. Each resource + // provider will keep a resource version UUID, and change it when + // it believes that the resources from this resource provider are + // out of sync from the master's view. The master will keep track + // of the last known resource version UUID for each resource + // provider, and attach the resource version UUID in each operation + // it sends out. The resource provider should reject operations that + // have a different resource version UUID than that it maintains, + // because this means the operation is operating on resources that + // might have already been invalidated. + required ResourceVersionUUID resource_version_uuid = 4; } http://git-wip-us.apache.org/repos/asf/mesos/blob/6b9d0c54/src/tests/resource_provider_manager_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/resource_provider_manager_tests.cpp b/src/tests/resource_provider_manager_tests.cpp index f0fd5e8..4008b1c 100644 --- a/src/tests/resource_provider_manager_tests.cpp +++ b/src/tests/resource_provider_manager_tests.cpp @@ -286,6 +286,7 @@ TEST_P(ResourceProviderManagerHttpApiTest, UpdateState) Call::UpdateState* updateState = call.mutable_update_state(); updateState->mutable_resources()->CopyFrom(v1::Resources(resources)); + updateState->set_resource_version_uuid(UUID::random().toBytes()); http::Request request; request.method = "POST"; http://git-wip-us.apache.org/repos/asf/mesos/blob/6b9d0c54/src/tests/resource_provider_validation_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/resource_provider_validation_tests.cpp b/src/tests/resource_provider_validation_tests.cpp index e6960b1..bf789a0 100644 --- a/src/tests/resource_provider_validation_tests.cpp +++ b/src/tests/resource_provider_validation_tests.cpp @@ -101,7 +101,8 @@ TEST(ResourceProviderCallValidationTest, UpdateState) error = call::validate(call); EXPECT_SOME(error); - call.mutable_update_state(); + Call::UpdateState* updateState = call.mutable_update_state(); + updateState->set_resource_version_uuid(UUID::random().toBytes()); error = call::validate(call); EXPECT_NONE(error);
