Passed `ResourceProviderInfo` to disk profile adaptor modules.

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


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

Branch: refs/heads/master
Commit: 542776b7293f7e2c7bd95967c724fafc524636c4
Parents: d4bfd8b
Author: Chun-Hung Hsiao <chhs...@mesosphere.io>
Authored: Thu Feb 8 14:41:16 2018 -0800
Committer: Jie Yu <yujie....@gmail.com>
Committed: Thu Feb 8 16:24:02 2018 -0800

----------------------------------------------------------------------
 .../resource_provider/storage/disk_profile.hpp  | 53 +++++++++++---------
 src/resource_provider/storage/disk_profile.cpp  |  6 +--
 src/resource_provider/storage/provider.cpp      | 13 ++---
 .../storage/uri_disk_profile.cpp                | 14 +++---
 .../storage/uri_disk_profile.hpp                |  8 +--
 5 files changed, 44 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/542776b7/include/mesos/resource_provider/storage/disk_profile.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/resource_provider/storage/disk_profile.hpp 
b/include/mesos/resource_provider/storage/disk_profile.hpp
index d1a522a..fa1a4fc 100644
--- a/include/mesos/resource_provider/storage/disk_profile.hpp
+++ b/include/mesos/resource_provider/storage/disk_profile.hpp
@@ -21,14 +21,16 @@
 #include <string>
 #include <tuple>
 
+#include <csi/spec.hpp>
+
+#include <mesos/mesos.hpp>
+
 #include <process/future.hpp>
 
 #include <stout/hashset.hpp>
 #include <stout/none.hpp>
 #include <stout/nothing.hpp>
 
-#include <csi/spec.hpp>
-
 namespace mesos {
 
 /**
@@ -97,43 +99,46 @@ public:
   virtual ~DiskProfileAdaptor() {}
 
   /**
-   * Called before a Storage Resource Provider makes an affected CSI request.
-   * The caller is responsible for copying the returned values into the request
-   * object.
+   * Returns the CSI volume capability and the parameters to create CSI
+   * volumes associated with the profile.
    *
-   * This method is expected to return a Failure if a matching "profile"
+   * This method is expected to return a Failure if a matching profile
    * cannot be found or retrieved. The caller should not proceed with
    * any of the affected CSI requests if this method returns a failure.
    *
-   * The `csiPluginInfoType` parameter is the `CSIPluginInfo::type` field
-   * found inside `ResourceProviderInfo::storage`. This module may choose to
-   * filter results based on the type of CSI plugin.
+   * The `resourceProviderInfo` parameter is the `ResourceProviderInfo`
+   * of the storage resource provider. This module may choose to filter
+   * results based on the type and name of the resource provider, or
+   * based on the type of the CSI plugin.
    *
-   * NOTE: This module assumes that profiles are immutable after creation.
-   * Changing the `VolumeCapability` or Parameters of a profile after creation
-   * may result in undefined behavior from the SLRP or CSI plugins.
+   * NOTE: This module assumes that profiles are immutable after
+   * creation. Changing the CSI volume capability or parameters of a
+   * profile after creation may result in undefined behavior from the
+   * storage resource provider.
    */
   virtual process::Future<ProfileInfo> translate(
       const std::string& profile,
-      const std::string& csiPluginInfoType) = 0;
+      const ResourceProviderInfo& resourceProviderInfo) = 0;
 
   /**
-   * Returns a future that will be satisifed iff the set of profiles known
-   * by the module differs from the `knownProfiles` parameter.
+   * Returns a future that will be satisifed iff the set of profiles
+   * known by the module differs from the `knownProfiles` parameter.
    *
-   * The `csiPluginInfoType` parameter is the `CSIPluginInfo::type` field
-   * found inside `ResourceProviderInfo::storage`. This module may choose to
-   * filter results based on the type of CSI plugin.
+   * The `resourceProviderInfo` parameter is the `ResourceProviderInfo`
+   * of the storage resource provider. This module may choose to filter
+   * results based on the type and name of the resource provider, or
+   * based on the type of the CSI plugin.
    *
-   * NOTE: It is highly recommended for the module to insert a random delay
-   * between discovering a different set of profiles and satisfying this
-   * future, because the SLRP is expected to update the set of offered
-   * resources based on this future. Adding a random delay may prevent
-   * a thundering herd of resource updates to the Mesos master.
+   * NOTE: It is highly recommended for the module to insert a random
+   * delay between discovering a different set of profiles and
+   * satisfying this future, because the storage resource provider is
+   * expected to update the set of offered resources based on this
+   * future. Adding a random delay may prevent a thundering herd of
+   * resource updates to the Mesos master.
    */
   virtual process::Future<hashset<std::string>> watch(
       const hashset<std::string>& knownProfiles,
-      const std::string& csiPluginInfoType) = 0;
+      const ResourceProviderInfo& resourceProviderInfo) = 0;
 
 protected:
   DiskProfileAdaptor() {}

http://git-wip-us.apache.org/repos/asf/mesos/blob/542776b7/src/resource_provider/storage/disk_profile.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/disk_profile.cpp 
b/src/resource_provider/storage/disk_profile.cpp
index 053fb7a..ba195cb 100644
--- a/src/resource_provider/storage/disk_profile.cpp
+++ b/src/resource_provider/storage/disk_profile.cpp
@@ -16,8 +16,6 @@
 
 #include <string>
 
-#include <mesos/mesos.hpp>
-
 #include <mesos/module/disk_profile.hpp>
 
 #include <mesos/resource_provider/storage/disk_profile.hpp>
@@ -52,14 +50,14 @@ public:
 
   virtual Future<DiskProfileAdaptor::ProfileInfo> translate(
       const string& profile,
-      const string& csiPluginInfoType) override
+      const ResourceProviderInfo& resourceProviderInfo) override
   {
     return Failure("By default, disk profiles are not supported");
   }
 
   virtual Future<hashset<string>> watch(
       const hashset<string>& knownProfiles,
-      const string& csiPluginInfoType) override
+      const ResourceProviderInfo& resourceProviderInfo) override
   {
     // If the input set of profiles is empty, that means the caller is in sync
     // with this module. Hence, we return a future that will never be 
satisified

http://git-wip-us.apache.org/repos/asf/mesos/blob/542776b7/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp 
b/src/resource_provider/storage/provider.cpp
index 786a0ce..33abc0e 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -651,9 +651,7 @@ Future<Nothing> 
StorageLocalResourceProviderProcess::recover()
       loop(
           self(),
           [=] {
-            return diskProfileAdaptor->watch(
-                knownProfiles,
-                info.storage().plugin().type())
+            return diskProfileAdaptor->watch(knownProfiles, info)
               .then(defer(self(), [=](const hashset<string>& profiles) {
                 // Save the returned set of profiles so that we
                 // can watch the module for changes to it.
@@ -995,11 +993,7 @@ Future<Nothing> 
StorageLocalResourceProviderProcess::recoverProfiles()
   // required profiles have been recovered.
   return loop(
       self(),
-      [=] {
-        return diskProfileAdaptor->watch(
-            knownProfiles,
-            info.storage().plugin().type());
-      },
+      [=] { return diskProfileAdaptor->watch(knownProfiles, info); },
       [=](const hashset<string>& profiles) -> ControlFlow<Nothing> {
         // Save the returned set of profiles so that we can watch the
         // module for changes to it, both in this loop and after
@@ -1283,8 +1277,7 @@ Future<Nothing> 
StorageLocalResourceProviderProcess::updateProfiles()
       continue;
     }
 
-    futures.push_back(diskProfileAdaptor->translate(
-        profile, info.storage().plugin().type())
+    futures.push_back(diskProfileAdaptor->translate(profile, info)
       .then(defer(self(), [=](const DiskProfileAdaptor::ProfileInfo& info) {
         profileInfos.put(profile, info);
         return Nothing();

http://git-wip-us.apache.org/repos/asf/mesos/blob/542776b7/src/resource_provider/storage/uri_disk_profile.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/uri_disk_profile.cpp 
b/src/resource_provider/storage/uri_disk_profile.cpp
index 7372b29..5a48656 100644
--- a/src/resource_provider/storage/uri_disk_profile.cpp
+++ b/src/resource_provider/storage/uri_disk_profile.cpp
@@ -20,8 +20,6 @@
 #include <string>
 #include <tuple>
 
-#include <mesos/mesos.hpp>
-
 #include <mesos/module/disk_profile.hpp>
 
 #include <mesos/resource_provider/storage/disk_profile.hpp>
@@ -100,25 +98,25 @@ UriDiskProfileAdaptor::~UriDiskProfileAdaptor()
 
 Future<DiskProfileAdaptor::ProfileInfo> UriDiskProfileAdaptor::translate(
     const string& profile,
-    const std::string& csiPluginInfoType)
+    const ResourceProviderInfo& resourceProviderInfo)
 {
   return dispatch(
       process.get(),
       &UriDiskProfileAdaptorProcess::translate,
       profile,
-      csiPluginInfoType);
+      resourceProviderInfo);
 }
 
 
 Future<hashset<string>> UriDiskProfileAdaptor::watch(
     const hashset<string>& knownProfiles,
-    const std::string& csiPluginInfoType)
+    const ResourceProviderInfo& resourceProviderInfo)
 {
   return dispatch(
       process.get(),
       &UriDiskProfileAdaptorProcess::watch,
       knownProfiles,
-      csiPluginInfoType);
+      resourceProviderInfo);
 }
 
 
@@ -138,7 +136,7 @@ void UriDiskProfileAdaptorProcess::initialize()
 Future<DiskProfileAdaptor::ProfileInfo>
   UriDiskProfileAdaptorProcess::translate(
       const string& profile,
-      const std::string& csiPluginInfoType)
+      const ResourceProviderInfo& resourceProviderInfo)
 {
   if (data.count(profile) != 1) {
     return Failure("Profile '" + profile + "' not found");
@@ -150,7 +148,7 @@ Future<DiskProfileAdaptor::ProfileInfo>
 
 Future<hashset<string>> UriDiskProfileAdaptorProcess::watch(
     const hashset<string>& knownProfiles,
-    const std::string& csiPluginInfoType)
+    const ResourceProviderInfo& resourceProviderInfo)
 {
   if (profiles != knownProfiles) {
     return profiles;

http://git-wip-us.apache.org/repos/asf/mesos/blob/542776b7/src/resource_provider/storage/uri_disk_profile.hpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/uri_disk_profile.hpp 
b/src/resource_provider/storage/uri_disk_profile.hpp
index 2f4fc7c..746111e 100644
--- a/src/resource_provider/storage/uri_disk_profile.hpp
+++ b/src/resource_provider/storage/uri_disk_profile.hpp
@@ -180,11 +180,11 @@ public:
 
   virtual process::Future<mesos::DiskProfileAdaptor::ProfileInfo> translate(
       const std::string& profile,
-      const std::string& csiPluginInfoType) override;
+      const ResourceProviderInfo& resourceProviderInfo) override;
 
   virtual process::Future<hashset<std::string>> watch(
       const hashset<std::string>& knownProfiles,
-      const std::string& csiPluginInfoType) override;
+      const ResourceProviderInfo& resourceProviderInfo) override;
 
 protected:
   Flags flags;
@@ -202,11 +202,11 @@ public:
 
   process::Future<mesos::DiskProfileAdaptor::ProfileInfo> translate(
       const std::string& profile,
-      const std::string& csiPluginInfoType);
+      const ResourceProviderInfo& resourceProviderInfo);
 
   process::Future<hashset<std::string>> watch(
       const hashset<std::string>& knownProfiles,
-      const std::string& csiPluginInfoType);
+      const ResourceProviderInfo& resourceProviderInfo);
 
 private:
   // Helpers for fetching the `--uri`.

Reply via email to