You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/11/08 23:13:39 UTC

[1/2] mesos git commit: Added a devolve function for 'OfferOperationStatus'.

Repository: mesos
Updated Branches:
  refs/heads/master eecac215e -> 50068a1fc


Added a devolve function for 'OfferOperationStatus'.

Review: https://reviews.apache.org/r/63621/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/50068a1f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/50068a1f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/50068a1f

Branch: refs/heads/master
Commit: 50068a1fc80ef66376aa89485755a445af8e6d2d
Parents: 24f2203
Author: Jan Schlicht <ja...@mesosphere.io>
Authored: Wed Nov 8 14:05:02 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Nov 8 15:13:27 2017 -0800

----------------------------------------------------------------------
 src/internal/devolve.cpp | 6 ++++++
 src/internal/devolve.hpp | 1 +
 2 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/50068a1f/src/internal/devolve.cpp
----------------------------------------------------------------------
diff --git a/src/internal/devolve.cpp b/src/internal/devolve.cpp
index e05fcd4..3a02490 100644
--- a/src/internal/devolve.cpp
+++ b/src/internal/devolve.cpp
@@ -104,6 +104,12 @@ Offer devolve(const v1::Offer& offer)
 }
 
 
+OfferOperationStatus devolve(const v1::OfferOperationStatus& status)
+{
+  return devolve<OfferOperationStatus>(status);
+}
+
+
 Resource devolve(const v1::Resource& resource)
 {
   return devolve<Resource>(resource);

http://git-wip-us.apache.org/repos/asf/mesos/blob/50068a1f/src/internal/devolve.hpp
----------------------------------------------------------------------
diff --git a/src/internal/devolve.hpp b/src/internal/devolve.hpp
index 48d9c33..17ab76e 100644
--- a/src/internal/devolve.hpp
+++ b/src/internal/devolve.hpp
@@ -60,6 +60,7 @@ FrameworkInfo devolve(const v1::FrameworkInfo& frameworkInfo);
 HealthCheck devolve(const v1::HealthCheck& check);
 InverseOffer devolve(const v1::InverseOffer& inverseOffer);
 Offer devolve(const v1::Offer& offer);
+OfferOperationStatus devolve(const v1::OfferOperationStatus& status);
 Resource devolve(const v1::Resource& resource);
 Resources devolve(const v1::Resources& resources);
 ResourceProviderID devolve(const v1::ResourceProviderID& resourceProviderId);


[2/2] mesos git commit: Updated offer operation handling to set resource versions.

Posted by ji...@apache.org.
Updated offer operation handling to set resource versions.

Resource version UUIDs are used to establish a relationship between
operation and the resource they are operating on. For each agent the
master keeps track of its resource version and the resource version of
the agents' resource providers. As resource versions are required in a
'ApplyOfferOperationMessage', the master has to find the resource
version that's matching the resources an operation should apply to and
set it accordingly.

Review: https://reviews.apache.org/r/63620/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/24f2203f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/24f2203f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/24f2203f

Branch: refs/heads/master
Commit: 24f2203fb6fda1a0a6aac8b901140041cf66a93f
Parents: eecac21
Author: Jan Schlicht <ja...@mesosphere.io>
Authored: Wed Nov 8 11:57:17 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Nov 8 15:13:27 2017 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 82 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/24f2203f/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 01675ed..e1381a9 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -5218,11 +5218,25 @@ void Master::_accept(
 
         addOfferOperation(framework, slave, offerOperation);
 
+        CHECK(consumed.has_provider_id());
+
+        Option<UUID> resourceVersion =
+          slave->resourceVersions.get(consumed.provider_id());
+
+        CHECK_SOME(resourceVersion);
+
         ApplyOfferOperationMessage message;
         message.mutable_framework_id()->CopyFrom(frameworkId);
         message.mutable_operation_info()->CopyFrom(offerOperation->info());
         message.set_operation_uuid(offerOperation->operation_uuid());
 
+        message.mutable_resource_version_uuid()
+          ->mutable_resource_provider_id()
+          ->CopyFrom(consumed.provider_id());
+
+        message.mutable_resource_version_uuid()
+          ->set_uuid(resourceVersion->toBytes());
+
         send(slave->pid, message);
         break;
       }
@@ -5262,11 +5276,25 @@ void Master::_accept(
 
         addOfferOperation(framework, slave, offerOperation);
 
+        CHECK(consumed.has_provider_id());
+
+        Option<UUID> resourceVersion =
+          slave->resourceVersions.get(consumed.provider_id());
+
+        CHECK_SOME(resourceVersion);
+
         ApplyOfferOperationMessage message;
         message.mutable_framework_id()->CopyFrom(frameworkId);
         message.mutable_operation_info()->CopyFrom(offerOperation->info());
         message.set_operation_uuid(offerOperation->operation_uuid());
 
+        message.mutable_resource_version_uuid()
+          ->mutable_resource_provider_id()
+          ->CopyFrom(consumed.provider_id());
+
+        message.mutable_resource_version_uuid()
+          ->set_uuid(resourceVersion->toBytes());
+
         send(slave->pid, message);
         break;
       }
@@ -5280,7 +5308,7 @@ void Master::_accept(
           continue;
         }
 
-        const Resources& consumed = operation.create_block().source();
+        const Resource& consumed = operation.create_block().source();
 
         if (!_offeredResources.contains(consumed)) {
           drop(framework,
@@ -5306,11 +5334,25 @@ void Master::_accept(
 
         addOfferOperation(framework, slave, offerOperation);
 
+        CHECK(consumed.has_provider_id());
+
+        Option<UUID> resourceVersion =
+          slave->resourceVersions.get(consumed.provider_id());
+
+        CHECK_SOME(resourceVersion);
+
         ApplyOfferOperationMessage message;
         message.mutable_framework_id()->CopyFrom(frameworkId);
         message.mutable_operation_info()->CopyFrom(offerOperation->info());
         message.set_operation_uuid(offerOperation->operation_uuid());
 
+        message.mutable_resource_version_uuid()
+          ->mutable_resource_provider_id()
+          ->CopyFrom(consumed.provider_id());
+
+        message.mutable_resource_version_uuid()
+          ->set_uuid(resourceVersion->toBytes());
+
         send(slave->pid, message);
         break;
       }
@@ -5324,7 +5366,7 @@ void Master::_accept(
           continue;
         }
 
-        const Resources& consumed = operation.destroy_block().block();
+        const Resource& consumed = operation.destroy_block().block();
 
         if (!_offeredResources.contains(consumed)) {
           drop(framework,
@@ -5350,11 +5392,25 @@ void Master::_accept(
 
         addOfferOperation(framework, slave, offerOperation);
 
+        CHECK(consumed.has_provider_id());
+
+        Option<UUID> resourceVersion =
+          slave->resourceVersions.get(consumed.provider_id());
+
+        CHECK_SOME(resourceVersion);
+
         ApplyOfferOperationMessage message;
         message.mutable_framework_id()->CopyFrom(frameworkId);
         message.mutable_operation_info()->CopyFrom(offerOperation->info());
         message.set_operation_uuid(offerOperation->operation_uuid());
 
+        message.mutable_resource_version_uuid()
+          ->mutable_resource_provider_id()
+          ->CopyFrom(consumed.provider_id());
+
+        message.mutable_resource_version_uuid()
+          ->set_uuid(resourceVersion->toBytes());
+
         send(slave->pid, message);
         break;
       }
@@ -9878,6 +9934,23 @@ void Master::_apply(
   slave->apply(operation);
 
   if (slave->capabilities.resourceProvider) {
+    Result<ResourceProviderID> resourceProviderId =
+      getResourceProviderId(operation);
+
+    // This must have been validated by the caller.
+    CHECK(!resourceProviderId.isError());
+
+    Option<UUID> resourceVersion = resourceProviderId.isSome()
+      ? slave->resourceVersions.get(resourceProviderId.get())
+      : slave->resourceVersions.get(None());
+
+    CHECK_SOME(resourceVersion)
+      << "Resource version of "
+      << (resourceProviderId.isSome()
+           ? "resource provider " + stringify(resourceProviderId.get())
+           : "agent " + stringify(*slave))
+      << " is unknown";
+
     OfferOperation* offerOperation = new OfferOperation(
         protobuf::createOfferOperation(
             operation,
@@ -9893,6 +9966,13 @@ void Master::_apply(
     }
     message.mutable_operation_info()->CopyFrom(offerOperation->info());
     message.set_operation_uuid(offerOperation->operation_uuid());
+    if (resourceProviderId.isSome()) {
+      message.mutable_resource_version_uuid()
+        ->mutable_resource_provider_id()
+        ->CopyFrom(resourceProviderId.get());
+    }
+    message.mutable_resource_version_uuid()
+      ->set_uuid(resourceVersion->toBytes());
 
     LOG(INFO) << "Sending offer operation "
               << offerOperation->operation_uuid()