Repository: mesos
Updated Branches:
  refs/heads/master f8111469b -> 454e7f2b7


Added default VolumeProfile module implementation.

By default, Mesos and the Storage Local Resource Provider (SLRP) will
not expect profiles to be used. This is partly due to the experimental
nature of the "profile" field and partly because some explicit operator
intervention is required to get profiles defined. There is no default
profile that is accepted by CSI plugins.

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


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

Branch: refs/heads/master
Commit: 86548e1a6ef5e0c4e7bc03e861c4b5c4dc7eae38
Parents: f80cb62
Author: Joseph Wu <[email protected]>
Authored: Mon Nov 20 16:29:18 2017 -0800
Committer: Joseph Wu <[email protected]>
Committed: Mon Dec 18 15:47:46 2017 -0800

----------------------------------------------------------------------
 include/mesos/module/volume_profile.hpp  |  63 ++++++++++++++++
 src/Makefile.am                          |  11 +++
 src/module/manager.cpp                   |   1 +
 src/resource_provider/volume_profile.cpp | 101 ++++++++++++++++++++++++++
 4 files changed, 176 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/86548e1a/include/mesos/module/volume_profile.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/module/volume_profile.hpp 
b/include/mesos/module/volume_profile.hpp
new file mode 100644
index 0000000..0c6cb95
--- /dev/null
+++ b/include/mesos/module/volume_profile.hpp
@@ -0,0 +1,63 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __MESOS_MODULE_VOLUME_PROFILE_HPP__
+#define __MESOS_MODULE_VOLUME_PROFILE_HPP__
+
+#include <mesos/mesos.hpp>
+#include <mesos/module.hpp>
+
+#include <mesos/resource_provider/volume_profile.hpp>
+
+namespace mesos {
+namespace modules {
+
+template <>
+inline const char* kind<mesos::VolumeProfileAdaptor>()
+{
+  return "VolumeProfileAdaptor";
+}
+
+
+template <>
+struct Module<mesos::VolumeProfileAdaptor> : ModuleBase
+{
+  Module(
+      const char* _moduleApiVersion,
+      const char* _mesosVersion,
+      const char* _authorName,
+      const char* _authorEmail,
+      const char* _description,
+      bool (*_compatible)(),
+      mesos::VolumeProfileAdaptor*
+        (*_create)(const Parameters& parameters))
+    : ModuleBase(
+        _moduleApiVersion,
+        _mesosVersion,
+        mesos::modules::kind<mesos::VolumeProfileAdaptor>(),
+        _authorName,
+        _authorEmail,
+        _description,
+        _compatible),
+      create(_create) {}
+
+  mesos::VolumeProfileAdaptor* (*create)(const Parameters& parameters);
+};
+
+} // namespace modules {
+} // namespace mesos {
+
+#endif // __MESOS_MODULE_VOLUME_PROFILE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/86548e1a/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 95c0a30..9c8daf5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -742,6 +742,11 @@ module_HEADERS =                                           
        \
   $(top_srcdir)/include/mesos/module/secret_generator.hpp              \
   $(top_srcdir)/include/mesos/module/secret_resolver.hpp
 
+if ENABLE_GRPC
+module_HEADERS +=                                                      \
+  $(top_srcdir)/include/mesos/module/volume_profile.hpp
+endif
+
 nodist_module_HEADERS =                                                        
\
   ../include/mesos/module/hook.pb.h                                    \
   ../include/mesos/module/module.pb.h
@@ -767,6 +772,7 @@ nodist_quota_HEADERS =                                      
                \
 resourceproviderdir = $(pkgincludedir)/resource_provider
 
 resourceprovider_HEADERS =                                             \
+  $(top_srcdir)/include/mesos/resource_provider/volume_profile.hpp     \
   $(top_srcdir)/include/mesos/resource_provider/resource_provider.hpp  \
   $(top_srcdir)/include/mesos/resource_provider/resource_provider.proto
 
@@ -1098,6 +1104,11 @@ libmesos_no_3rdparty_la_SOURCES +=                       
                \
   zookeeper/zookeeper.cpp                                              \
   zookeeper/group.cpp
 
+if ENABLE_GRPC
+libmesos_no_3rdparty_la_SOURCES +=                                     \
+  resource_provider/volume_profile.cpp
+endif
+
 libmesos_no_3rdparty_la_SOURCES +=                                     \
   authentication/cram_md5/authenticatee.hpp                            \
   authentication/cram_md5/authenticator.hpp                            \

http://git-wip-us.apache.org/repos/asf/mesos/blob/86548e1a/src/module/manager.cpp
----------------------------------------------------------------------
diff --git a/src/module/manager.cpp b/src/module/manager.cpp
index d93648a..f038f05 100644
--- a/src/module/manager.cpp
+++ b/src/module/manager.cpp
@@ -81,6 +81,7 @@ void ModuleManager::initialize()
   kindToVersion["ResourceEstimator"] = MESOS_VERSION;
   kindToVersion["SecretResolver"] = MESOS_VERSION;
   kindToVersion["TestModule"] = MESOS_VERSION;
+  kindToVersion["VolumeProfileAdaptor"] = MESOS_VERSION;
 
   // What happens then when Mesos is built with a certain version,
   // 'kindToVersion' states a certain other minimum version, and a

http://git-wip-us.apache.org/repos/asf/mesos/blob/86548e1a/src/resource_provider/volume_profile.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/volume_profile.cpp 
b/src/resource_provider/volume_profile.cpp
new file mode 100644
index 0000000..739ebb1
--- /dev/null
+++ b/src/resource_provider/volume_profile.cpp
@@ -0,0 +1,101 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <string>
+
+#include <mesos/mesos.hpp>
+
+#include <mesos/module/volume_profile.hpp>
+
+#include <mesos/resource_provider/volume_profile.hpp>
+
+#include <process/future.hpp>
+
+#include <stout/hashset.hpp>
+
+#include <csi/spec.hpp>
+
+#include "module/manager.hpp"
+
+using std::string;
+using std::tuple;
+
+using process::Failure;
+using process::Future;
+
+using google::protobuf::Map;
+
+namespace mesos {
+namespace internal {
+
+// The default implementation does nothing and always returns a Failure
+// whenever called.
+class DefaultVolumeProfileAdaptor : public VolumeProfileAdaptor
+{
+public:
+  DefaultVolumeProfileAdaptor() {}
+
+  ~DefaultVolumeProfileAdaptor() {}
+
+  virtual Future<VolumeProfileAdaptor::ProfileInfo> translate(
+      const string& profile,
+      const string& csiPluginInfoType) override
+  {
+    return Failure("By default, volume profiles are not supported");
+  }
+
+  virtual Future<hashset<string>> watch(
+      const hashset<string>& knownProfiles,
+      const string& csiPluginInfoType) 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
+    // because this module will never return a non-empty set of profiles.
+    if (knownProfiles.empty()) {
+      return Future<hashset<string>>();
+    }
+
+    return hashset<string>::EMPTY;
+  }
+};
+
+} // namespace internal {
+
+
+Try<VolumeProfileAdaptor*> VolumeProfileAdaptor::create(
+    const Option<string>& moduleName)
+{
+  if (moduleName.isNone()) {
+    LOG(INFO) << "Creating default volume profile adaptor module";
+    return new internal::DefaultVolumeProfileAdaptor();
+  }
+
+  LOG(INFO)
+    << "Creating volume profile adaptor module '" << moduleName.get() << "'";
+
+  Try<VolumeProfileAdaptor*> result =
+    modules::ModuleManager::create<VolumeProfileAdaptor>(moduleName.get());
+
+  if (result.isError()) {
+    return Error(
+        "Failed to initialize volume profile adaptor module: "
+        + result.error());
+  }
+
+  return result;
+}
+
+} // namespace mesos {

Reply via email to