You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bb...@apache.org on 2018/12/18 14:30:33 UTC

[mesos] 02/02: Validated that resource providers use correct ID in operation states.

This is an automated email from the ASF dual-hosted git repository.

bbannier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 49fc7fcf1e26d803aa0775f66f36763e39d695e9
Author: Benjamin Bannier <bb...@apache.org>
AuthorDate: Tue Dec 18 15:08:18 2018 +0100

    Validated that resource providers use correct ID in operation states.
    
    We expect resource providers to set their IDs in operation status
    messages. This patch adds some assertion that the IDs match our
    expectations, and adjusts some test code to honor these assumptions.
    
    Review: https://reviews.apache.org/r/69572/
---
 src/resource_provider/manager.cpp               | 8 ++++++++
 src/tests/master_slave_reconciliation_tests.cpp | 7 +++++++
 src/tests/resource_provider_manager_tests.cpp   | 3 +++
 3 files changed, 18 insertions(+)

diff --git a/src/resource_provider/manager.cpp b/src/resource_provider/manager.cpp
index 103f545..65852c6 100644
--- a/src/resource_provider/manager.cpp
+++ b/src/resource_provider/manager.cpp
@@ -882,13 +882,21 @@ void ResourceProviderManagerProcess::updateOperationStatus(
     ResourceProvider* resourceProvider,
     const Call::UpdateOperationStatus& update)
 {
+  CHECK_EQ(update.status().resource_provider_id(), resourceProvider->info.id());
+
   ResourceProviderMessage::UpdateOperationStatus body;
   body.update.mutable_status()->CopyFrom(update.status());
   body.update.mutable_operation_uuid()->CopyFrom(update.operation_uuid());
+
   if (update.has_framework_id()) {
     body.update.mutable_framework_id()->CopyFrom(update.framework_id());
   }
+
   if (update.has_latest_status()) {
+    CHECK_EQ(
+        update.latest_status().resource_provider_id(),
+        resourceProvider->info.id());
+
     body.update.mutable_latest_status()->CopyFrom(update.latest_status());
   }
 
diff --git a/src/tests/master_slave_reconciliation_tests.cpp b/src/tests/master_slave_reconciliation_tests.cpp
index de6e382..979048c 100644
--- a/src/tests/master_slave_reconciliation_tests.cpp
+++ b/src/tests/master_slave_reconciliation_tests.cpp
@@ -497,6 +497,13 @@ TEST_F(
         updateOperationStatus->mutable_operation_uuid()->CopyFrom(
             operationUuid);
 
+        ASSERT_TRUE(resourceProvider->info.has_id())
+          << "Asked to reconcile before subscription was finished";
+
+        updateOperationStatus->mutable_status()
+          ->mutable_resource_provider_id()
+          ->CopyFrom(resourceProvider->info.id());
+
         resourceProvider->send(call);
       }
     };
diff --git a/src/tests/resource_provider_manager_tests.cpp b/src/tests/resource_provider_manager_tests.cpp
index b61c50f..7049698 100644
--- a/src/tests/resource_provider_manager_tests.cpp
+++ b/src/tests/resource_provider_manager_tests.cpp
@@ -372,6 +372,8 @@ TEST_P(ResourceProviderManagerHttpApiTest, UpdateOperationStatus)
     resourceProviderId = evolve(message->subscribe->info.id());
   }
 
+  ASSERT_SOME(resourceProviderId);
+
   // Then, send an operation status update to the manager.
   {
     v1::FrameworkID frameworkId;
@@ -379,6 +381,7 @@ TEST_P(ResourceProviderManagerHttpApiTest, UpdateOperationStatus)
 
     mesos::v1::OperationStatus status;
     status.set_state(mesos::v1::OperationState::OPERATION_FINISHED);
+    status.mutable_resource_provider_id()->CopyFrom(resourceProviderId.get());
 
     mesos::v1::UUID operationUUID = evolve(protobuf::createUUID());;