You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by qi...@apache.org on 2020/08/03 02:51:32 UTC
[mesos] branch master updated (da08b0c -> d2c84d1)
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.
from da08b0c Fixed a compilation issue on Windows with os::spawn.
new 8a41f00 Added CSI volume type into the `Volume` protobuf message.
new e5514e9 Updated `CSIPluginInfo` for supporting 3rd party CSI plugins.
new 4d3c3d7 Introduced a new agent flag `--csi_plugin_config_dir`.
new d2c84d1 Improved CSI service manager to support unmanaged CSI plugins.
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
docs/configuration/agent.md | 43 +++++++
include/mesos/csi/types.hpp | 40 -------
include/mesos/csi/types.proto | 90 --------------
include/mesos/mesos.proto | 129 ++++++++++++++++++++-
.../storage/disk_profile_adaptor.hpp | 4 +-
include/mesos/type_utils.hpp | 6 +
include/mesos/v1/mesos.proto | 129 ++++++++++++++++++++-
src/CMakeLists.txt | 2 -
src/Makefile.am | 10 --
src/common/type_utils.cpp | 18 +++
src/csi/service_manager.cpp | 92 ++++++++++++++-
src/csi/service_manager.hpp | 12 +-
src/csi/state.proto | 4 +-
src/csi/types.cpp | 36 ------
src/csi/v0_utils.cpp | 68 +++++------
src/csi/v0_utils.hpp | 14 ++-
src/csi/v0_volume_manager.cpp | 12 +-
src/csi/v0_volume_manager.hpp | 8 +-
src/csi/v0_volume_manager_process.hpp | 8 +-
src/csi/v1_utils.cpp | 68 +++++------
src/csi/v1_utils.hpp | 14 ++-
src/csi/v1_volume_manager.cpp | 12 +-
src/csi/v1_volume_manager.hpp | 8 +-
src/csi/v1_volume_manager_process.hpp | 8 +-
src/csi/volume_manager.hpp | 8 +-
src/examples/test_csi_plugin.cpp | 6 +-
src/resource_provider/state.proto | 4 +-
src/slave/flags.cpp | 39 +++++++
src/slave/flags.hpp | 1 +
src/tests/csi_utils_tests.cpp | 1 -
src/tests/disk_profile_adaptor_tests.cpp | 6 +-
31 files changed, 576 insertions(+), 324 deletions(-)
delete mode 100644 include/mesos/csi/types.hpp
delete mode 100644 include/mesos/csi/types.proto
delete mode 100644 src/csi/types.cpp
[mesos] 02/04: Updated `CSIPluginInfo` for supporting 3rd party CSI
plugins.
Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit e5514e903478b688c6bcde7ca2551ba424055d10
Author: Qian Zhang <zh...@gmail.com>
AuthorDate: Wed Jul 8 11:22:09 2020 +0800
Updated `CSIPluginInfo` for supporting 3rd party CSI plugins.
Review: https://reviews.apache.org/r/72661
---
include/mesos/mesos.proto | 38 ++++++++++++++++++++++++++++++++++----
include/mesos/v1/mesos.proto | 38 ++++++++++++++++++++++++++++++++++----
2 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index fe371ea..0f91d88 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -1063,7 +1063,7 @@ message SlaveInfo {
/**
- * Describes the container configuration to run a CSI plugin component.
+ * Describes the container configuration to run a managed CSI plugin.
*/
message CSIPluginContainerInfo {
enum Service {
@@ -1080,6 +1080,15 @@ message CSIPluginContainerInfo {
/**
+ * Describes the endpoint of an unmanaged CSI plugin service.
+ */
+message CSIPluginEndpoint {
+ required CSIPluginContainerInfo.Service csi_service = 1;
+ required string endpoint = 2;
+}
+
+
+/**
* Describes a CSI plugin.
*/
message CSIPluginInfo {
@@ -1103,13 +1112,34 @@ message CSIPluginInfo {
// that the concatenation of type and name is unique in the cluster, and it
// remains the same if the instance is migrated to another agent (e.g., there
// is a change in the agent ID).
- required string name = 2;
-
- // A list of container configurations to run CSI plugin components.
+ optional string name = 2 [default = "default"];
+
+ // We support two kinds of CSI plugins:
+ // 1. Managed CSI plugins: This is the plugin which will be launched by
+ // Mesos as standalone container, and Mesos will internally determine
+ // its endpoint when launching it and manage its whole lifecyle. For this
+ // kind of plugins, the `containers` field below must be specified.
+ // 2. Unmanaged CSI plugins: This is the plugin which is launched out of
+ // Mesos (e.g., manually launched by the operator). For this kind of
+ // plugins, the `endpoints` field below must be specified because Mesos
+ // needs it to call CSI gRPC methods.
+ // Please note that only one of the `containers` and `endpoints` fields should
+ // be specified.
+
+ // A list of container configurations to run managed CSI plugin.
// The controller service will be served by the first configuration
// that contains `CONTROLLER_SERVICE`, and the node service will be
// served by the first configuration that contains `NODE_SERVICE`.
repeated CSIPluginContainerInfo containers = 3;
+
+ // The service endpoints of the unmanaged CSI plugin. An endpoint is usually
+ // a path to a Unix domain socket.
+ repeated CSIPluginEndpoint endpoints = 4;
+
+ // The root directory of all the target paths managed by the CSI plugin.
+ // Each volume will be published by the CSI plugin at a sub-directory
+ // under this path.
+ optional string target_path_root = 5;
}
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index effcfa1..f25db8a 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -1051,7 +1051,7 @@ message AgentInfo {
/**
- * Describes the container configuration to run a CSI plugin component.
+ * Describes the container configuration to run a managed CSI plugin.
*/
message CSIPluginContainerInfo {
enum Service {
@@ -1068,6 +1068,15 @@ message CSIPluginContainerInfo {
/**
+ * Describes the endpoint of an unmanaged CSI plugin service.
+ */
+message CSIPluginEndpoint {
+ required CSIPluginContainerInfo.Service csi_service = 1;
+ required string endpoint = 2;
+}
+
+
+/**
* Describes a CSI plugin.
*/
message CSIPluginInfo {
@@ -1091,13 +1100,34 @@ message CSIPluginInfo {
// that the concatenation of type and name is unique in the cluster, and it
// remains the same if the instance is migrated to another agent (e.g., there
// is a change in the agent ID).
- required string name = 2;
-
- // A list of container configurations to run CSI plugin components.
+ optional string name = 2 [default = "default"];
+
+ // We support two kinds of CSI plugins:
+ // 1. Managed CSI plugins: This is the plugin which will be launched by
+ // Mesos as standalone container, and Mesos will internally determine
+ // its endpoint when launching it and manage its whole lifecyle. For this
+ // kind of plugins, the `containers` field below must be specified.
+ // 2. Unmanaged CSI plugins: This is the plugin which is launched out of
+ // Mesos (e.g., manually launched by the operator). For this kind of
+ // plugins, the `endpoints` field below must be specified because Mesos
+ // needs it to call CSI gRPC methods.
+ // Please note that only one of the `containers` and `endpoints` fields should
+ // be specified.
+
+ // A list of container configurations to run managed CSI plugin.
// The controller service will be served by the first configuration
// that contains `CONTROLLER_SERVICE`, and the node service will be
// served by the first configuration that contains `NODE_SERVICE`.
repeated CSIPluginContainerInfo containers = 3;
+
+ // The service endpoints of the unmanaged CSI plugin. An endpoint is usually
+ // a path to a Unix domain socket.
+ repeated CSIPluginEndpoint endpoints = 4;
+
+ // The root directory of all the target paths managed by the CSI plugin.
+ // Each volume will be published by the CSI plugin at a sub-directory
+ // under this path.
+ optional string target_path_root = 5;
}
[mesos] 01/04: Added CSI volume type into the `Volume` protobuf
message.
Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 8a41f00a379431d65b144e120fe60da95e6195e9
Author: Qian Zhang <zh...@gmail.com>
AuthorDate: Wed Jul 8 11:08:08 2020 +0800
Added CSI volume type into the `Volume` protobuf message.
Also removed the `types.proto` file which has `VolumeCapability`
defined as well so that we will have a single place (`mesos.proto`)
to define this protobuf message.
Review: https://reviews.apache.org/r/72660
---
include/mesos/csi/types.hpp | 40 ----------
include/mesos/csi/types.proto | 90 ---------------------
include/mesos/mesos.proto | 91 ++++++++++++++++++++++
.../storage/disk_profile_adaptor.hpp | 4 +-
include/mesos/type_utils.hpp | 6 ++
include/mesos/v1/mesos.proto | 91 ++++++++++++++++++++++
src/CMakeLists.txt | 2 -
src/Makefile.am | 10 ---
src/common/type_utils.cpp | 18 +++++
src/csi/state.proto | 4 +-
src/csi/types.cpp | 36 ---------
src/csi/v0_utils.cpp | 68 ++++++++--------
src/csi/v0_utils.hpp | 14 ++--
src/csi/v0_volume_manager.cpp | 12 +--
src/csi/v0_volume_manager.hpp | 8 +-
src/csi/v0_volume_manager_process.hpp | 8 +-
src/csi/v1_utils.cpp | 68 ++++++++--------
src/csi/v1_utils.hpp | 14 ++--
src/csi/v1_volume_manager.cpp | 12 +--
src/csi/v1_volume_manager.hpp | 8 +-
src/csi/v1_volume_manager_process.hpp | 8 +-
src/csi/volume_manager.hpp | 8 +-
src/examples/test_csi_plugin.cpp | 6 +-
src/resource_provider/state.proto | 4 +-
src/tests/csi_utils_tests.cpp | 1 -
src/tests/disk_profile_adaptor_tests.cpp | 6 +-
26 files changed, 324 insertions(+), 313 deletions(-)
diff --git a/include/mesos/csi/types.hpp b/include/mesos/csi/types.hpp
deleted file mode 100644
index df9df38..0000000
--- a/include/mesos/csi/types.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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_CSI_TYPES_HPP__
-#define __MESOS_CSI_TYPES_HPP__
-
-// ONLY USEFUL AFTER RUNNING PROTOC.
-#include <mesos/csi/types.pb.h>
-
-namespace mesos {
-namespace csi {
-namespace types {
-
-bool operator==(const VolumeCapability& left, const VolumeCapability& right);
-
-
-inline bool operator!=(
- const VolumeCapability& left, const VolumeCapability& right)
-{
- return !(left == right);
-}
-
-} // namespace types {
-} // namespace csi {
-} // namespace mesos {
-
-#endif // __MESOS_CSI_TYPES_HPP__
diff --git a/include/mesos/csi/types.proto b/include/mesos/csi/types.proto
deleted file mode 100644
index 3e1ac4b..0000000
--- a/include/mesos/csi/types.proto
+++ /dev/null
@@ -1,90 +0,0 @@
-// 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.
-
-syntax = "proto3";
-
-package mesos.csi.types;
-
-// This file contains "unversioned" CSI protobuf definitions used by Mesos. For
-// any CSI version, an unversioned CSI protobuf constructed from a versioned one
-// can be used to reconstructed back the same versioned protobuf (excluding
-// unknown fields). An unversioned protobuf can also be used to construct a
-// protobuf of another CSI version, but version-specific details might be lost.
-
-
-/**
- * Protobuf to specify a capability of a volume:
- * https://github.com/container-storage-interface/spec/blob/release-1.1/spec.md#createvolume
- */
-message VolumeCapability {
- // Indicate that the volume will be accessed via the block device API.
- message BlockVolume {
- // Intentionally empty, for now.
- }
-
- // Indicate that the volume will be accessed via the filesystem API.
- message MountVolume {
- // The filesystem type. This field is OPTIONAL.
- // An empty string is equal to an unspecified field value.
- string fs_type = 1;
-
- // The mount options that can be used for the volume. This field is
- // OPTIONAL. `mount_flags` MAY contain sensitive information.
- // Therefore, the CO and the Plugin MUST NOT leak this information
- // to untrusted entities. The total size of this repeated field
- // SHALL NOT exceed 4 KiB.
- repeated string mount_flags = 2;
- }
-
- // Specify how a volume can be accessed.
- message AccessMode {
- enum Mode {
- UNKNOWN = 0;
-
- // Can only be published once as read/write on a single node, at
- // any given time.
- SINGLE_NODE_WRITER = 1;
-
- // Can only be published once as readonly on a single node, at
- // any given time.
- SINGLE_NODE_READER_ONLY = 2;
-
- // Can be published as readonly at multiple nodes simultaneously.
- MULTI_NODE_READER_ONLY = 3;
-
- // Can be published at multiple nodes simultaneously. Only one of
- // the node can be used as read/write. The rest will be readonly.
- MULTI_NODE_SINGLE_WRITER = 4;
-
- // Can be published as read/write at multiple nodes
- // simultaneously.
- MULTI_NODE_MULTI_WRITER = 5;
- }
-
- // This field is REQUIRED.
- Mode mode = 1;
- }
-
- // Specifies what API the volume will be accessed using. One of the
- // following fields MUST be specified.
- oneof access_type {
- BlockVolume block = 1;
- MountVolume mount = 2;
- }
-
- // This is a REQUIRED field.
- AccessMode access_mode = 3;
-}
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 5f795f5..fe371ea 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -3056,6 +3056,7 @@ message Volume {
HOST_PATH = 4;
SANDBOX_PATH = 2;
SECRET = 3;
+ CSI_VOLUME = 5;
}
message DockerVolume {
@@ -3094,6 +3095,94 @@ message Volume {
required string path = 2;
}
+ // A volume which will be handled by the `volume/csi` isolator.
+ message CSIVolume {
+ // The name of the CSI plugin.
+ required string plugin_name = 1;
+
+ // Specifies a capability of a volume.
+ // https://github.com/container-storage-interface/spec/blob/v1.3.0/csi.proto#L379:L438
+ message VolumeCapability {
+ // Indicates that the volume will be accessed via the block device API.
+ message BlockVolume {
+ // Intentionally empty, for now.
+ }
+
+ // Indicates that the volume will be accessed via the filesystem API.
+ message MountVolume {
+ // The filesystem type. An empty string is equal to an unspecified
+ // field value.
+ optional string fs_type = 1;
+
+ // The mount options that can be used for the volume. This field is
+ // OPTIONAL. `mount_flags` MAY contain sensitive information.
+ // Therefore, Mesos and the Plugin MUST NOT leak this information
+ // to untrusted entities. The total size of this repeated field
+ // SHALL NOT exceed 4 KiB.
+ repeated string mount_flags = 2;
+ }
+
+ // Specifies how a volume can be accessed.
+ message AccessMode {
+ enum Mode {
+ UNKNOWN = 0;
+
+ // Can only be published once as read/write on a single node, at
+ // any given time.
+ SINGLE_NODE_WRITER = 1;
+
+ // Can only be published once as readonly on a single node, at
+ // any given time.
+ SINGLE_NODE_READER_ONLY = 2;
+
+ // Can be published as readonly at multiple nodes simultaneously.
+ MULTI_NODE_READER_ONLY = 3;
+
+ // Can be published at multiple nodes simultaneously. Only one of
+ // the node can be used as read/write. The rest will be readonly.
+ MULTI_NODE_SINGLE_WRITER = 4;
+
+ // Can be published as read/write at multiple nodes
+ // simultaneously.
+ MULTI_NODE_MULTI_WRITER = 5;
+ }
+
+ required Mode mode = 1;
+ }
+
+ // Specifies what API the volume will be accessed using. One of the
+ // following fields MUST be specified.
+ oneof access_type {
+ BlockVolume block = 1;
+ MountVolume mount = 2;
+ }
+
+ required AccessMode access_mode = 3;
+ }
+
+ // Specifies the parameters used to stage/publish a pre-provisioned volume
+ // on an agent host. The fields are merged from `NodeStageVolumeRequest`
+ // and `NodePublishVolumeRequest` protobuf messages defined in CSI spec
+ // except two fields `staging_target_path` and `target_path` which will be
+ // internally determined by Mesos when staging/publishing the volume.
+ message StaticProvisioning {
+ required string volume_id = 1;
+ required VolumeCapability volume_capability = 2;
+ optional bool readonly = 3;
+
+ // The secrets needed for staging/publishing the volume, e.g.:
+ // {
+ // "username": {"type": REFERENCE, "reference": {"name": "U_SECRET"}},
+ // "password": {"type": REFERENCE, "reference": {"name": "P_SECRET"}}
+ // }
+ map<string, Secret> node_stage_secrets = 4;
+ map<string, Secret> node_publish_secrets = 5;
+ map<string, string> volume_context = 6;
+ }
+
+ optional StaticProvisioning static_provisioning = 2;
+ }
+
// Enum fields should be optional, see: MESOS-4997.
optional Type type = 1;
@@ -3109,6 +3198,8 @@ message Volume {
// The volume/secret isolator uses the secret-fetcher module (third-party or
// internal) downloads the secret and makes it available at container_path.
optional Secret secret = 4;
+
+ optional CSIVolume csi_volume = 6;
}
optional Source source = 5;
diff --git a/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp b/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp
index 8b6da3a..e9d8815 100644
--- a/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp
+++ b/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp
@@ -23,8 +23,6 @@
#include <mesos/mesos.hpp>
-#include <mesos/csi/types.hpp>
-
#include <process/future.hpp>
#include <stout/hashset.hpp>
@@ -63,7 +61,7 @@ public:
* of `VolumeCapability` objects, the module will only allow a single
* `VolumeCapability`.
*/
- csi::types::VolumeCapability capability;
+ Volume::Source::CSIVolume::VolumeCapability capability;
/**
* Free-form key-value pairs which should be passed into the body
diff --git a/include/mesos/type_utils.hpp b/include/mesos/type_utils.hpp
index 98a2995..da9fd96 100644
--- a/include/mesos/type_utils.hpp
+++ b/include/mesos/type_utils.hpp
@@ -87,6 +87,9 @@ bool operator==(const TaskStatus& left, const TaskStatus& right);
bool operator==(const URL& left, const URL& right);
bool operator==(const UUID& left, const UUID& right);
bool operator==(const Volume& left, const Volume& right);
+bool operator==(
+ const Volume::Source::CSIVolume::VolumeCapability& left,
+ const Volume::Source::CSIVolume::VolumeCapability& right);
bool operator!=(const CheckStatusInfo& left, const CheckStatusInfo& right);
bool operator!=(const ExecutorInfo& left, const ExecutorInfo& right);
@@ -96,6 +99,9 @@ bool operator!=(const Operation& left, const Operation& right);
bool operator!=(const OperationStatus& left, const OperationStatus& right);
bool operator!=(const TaskStatus& left, const TaskStatus& right);
+bool operator!=(
+ const Volume::Source::CSIVolume::VolumeCapability& left,
+ const Volume::Source::CSIVolume::VolumeCapability& right);
inline bool operator==(const ExecutorID& left, const ExecutorID& right)
{
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index 07d2f40..effcfa1 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -3045,6 +3045,7 @@ message Volume {
HOST_PATH = 4;
SANDBOX_PATH = 2;
SECRET = 3;
+ CSI_VOLUME = 5;
}
message DockerVolume {
@@ -3083,6 +3084,94 @@ message Volume {
required string path = 2;
}
+ // A volume which will be handled by the `volume/csi` isolator.
+ message CSIVolume {
+ // The name of the CSI plugin.
+ required string plugin_name = 1;
+
+ // Specifies a capability of a volume.
+ // https://github.com/container-storage-interface/spec/blob/v1.3.0/csi.proto#L379:L438
+ message VolumeCapability {
+ // Indicates that the volume will be accessed via the block device API.
+ message BlockVolume {
+ // Intentionally empty, for now.
+ }
+
+ // Indicates that the volume will be accessed via the filesystem API.
+ message MountVolume {
+ // The filesystem type. An empty string is equal to an unspecified
+ // field value.
+ optional string fs_type = 1;
+
+ // The mount options that can be used for the volume. This field is
+ // OPTIONAL. `mount_flags` MAY contain sensitive information.
+ // Therefore, Mesos and the Plugin MUST NOT leak this information
+ // to untrusted entities. The total size of this repeated field
+ // SHALL NOT exceed 4 KiB.
+ repeated string mount_flags = 2;
+ }
+
+ // Specifies how a volume can be accessed.
+ message AccessMode {
+ enum Mode {
+ UNKNOWN = 0;
+
+ // Can only be published once as read/write on a single node, at
+ // any given time.
+ SINGLE_NODE_WRITER = 1;
+
+ // Can only be published once as readonly on a single node, at
+ // any given time.
+ SINGLE_NODE_READER_ONLY = 2;
+
+ // Can be published as readonly at multiple nodes simultaneously.
+ MULTI_NODE_READER_ONLY = 3;
+
+ // Can be published at multiple nodes simultaneously. Only one of
+ // the node can be used as read/write. The rest will be readonly.
+ MULTI_NODE_SINGLE_WRITER = 4;
+
+ // Can be published as read/write at multiple nodes
+ // simultaneously.
+ MULTI_NODE_MULTI_WRITER = 5;
+ }
+
+ required Mode mode = 1;
+ }
+
+ // Specifies what API the volume will be accessed using. One of the
+ // following fields MUST be specified.
+ oneof access_type {
+ BlockVolume block = 1;
+ MountVolume mount = 2;
+ }
+
+ required AccessMode access_mode = 3;
+ }
+
+ // Specifies the parameters used to stage/publish a pre-provisioned volume
+ // on an agent host. The fields are merged from `NodeStageVolumeRequest`
+ // and `NodePublishVolumeRequest` protobuf messages defined in CSI spec
+ // except two fields `staging_target_path` and `target_path` which will be
+ // internally determined by Mesos when staging/publishing the volume.
+ message StaticProvisioning {
+ required string volume_id = 1;
+ required VolumeCapability volume_capability = 2;
+ optional bool readonly = 3;
+
+ // The secrets needed for staging/publishing the volume, e.g.:
+ // {
+ // "username": {"type": REFERENCE, "reference": {"name": "U_SECRET"}},
+ // "password": {"type": REFERENCE, "reference": {"name": "P_SECRET"}}
+ // }
+ map<string, Secret> node_stage_secrets = 4;
+ map<string, Secret> node_publish_secrets = 5;
+ map<string, string> volume_context = 6;
+ }
+
+ optional StaticProvisioning static_provisioning = 2;
+ }
+
// Enum fields should be optional, see: MESOS-4997.
optional Type type = 1;
@@ -3098,6 +3187,8 @@ message Volume {
// The volume/secret isolator uses the secret-fetcher module (third-party or
// internal) downloads the secret and makes it available at container_path.
optional Secret secret = 4;
+
+ optional CSIVolume csi_volume = 6;
}
optional Source source = 5;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bcb5128..4e15e3d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -39,7 +39,6 @@ PROTOC_GENERATE(TARGET mesos/allocator/allocator)
PROTOC_GENERATE(TARGET mesos/authentication/authentication)
PROTOC_GENERATE(TARGET mesos/authorizer/acls)
PROTOC_GENERATE(TARGET mesos/authorizer/authorizer)
-PROTOC_GENERATE(TARGET mesos/csi/types)
PROTOC_GENERATE(TARGET mesos/maintenance/maintenance)
PROTOC_GENERATE(TARGET mesos/master/master)
PROTOC_GENERATE(TARGET mesos/module/hook)
@@ -252,7 +251,6 @@ if (NOT WIN32)
endif ()
set(CSI_SRC
- csi/types.cpp
csi/metrics.cpp
csi/paths.cpp
csi/service_manager.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index a89919d..447db32 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -293,7 +293,6 @@ APPC_SPEC_PROTO = $(top_srcdir)/include/mesos/appc/spec.proto
AUTHENTICATION_PROTO = $(top_srcdir)/include/mesos/authentication/authentication.proto
AUTHORIZATION_PROTO = $(top_srcdir)/include/mesos/authorizer/authorizer.proto
CONTAINERIZER_PROTO = $(top_srcdir)/include/mesos/slave/containerizer.proto
-CSI_TYPES_PROTO = $(top_srcdir)/include/mesos/csi/types.proto
DOCKER_SPEC_PROTO = $(top_srcdir)/include/mesos/docker/spec.proto
DOCKER_V1_PROTO = $(top_srcdir)/include/mesos/docker/v1.proto
DOCKER_V2_PROTO = $(top_srcdir)/include/mesos/docker/v2.proto
@@ -431,8 +430,6 @@ CXX_CSI_PROTOS = \
../include/csi/v1/csi.grpc.pb.h \
../include/csi/v1/csi.pb.cc \
../include/csi/v1/csi.pb.h \
- ../include/mesos/csi/types.pb.cc \
- ../include/mesos/csi/types.pb.h \
csi/state.pb.cc \
csi/state.pb.h
@@ -711,14 +708,9 @@ nodist_authorizer_HEADERS = \
csidir = $(pkgincludedir)/csi
csi_HEADERS = \
- $(top_srcdir)/include/mesos/csi/types.hpp \
- $(top_srcdir)/include/mesos/csi/types.proto \
$(top_srcdir)/include/mesos/csi/v0.hpp \
$(top_srcdir)/include/mesos/csi/v1.hpp
-nodist_csi_HEADERS = \
- ../include/mesos/csi/types.pb.h
-
# Install the generated CSI headers into $PREFIX/include.
csi_v0dir = $(includedir)/csi/v0
@@ -1603,7 +1595,6 @@ libcsi_la_SOURCES = \
csi/service_manager.hpp \
csi/state.hpp \
csi/state.proto \
- csi/types.cpp \
csi/v0.cpp \
csi/v0_client.cpp \
csi/v0_client.hpp \
@@ -1698,7 +1689,6 @@ libmesos_la_SOURCES = \
$(AUTHENTICATION_PROTO) \
$(AUTHORIZATION_PROTO) \
$(CONTAINERIZER_PROTO) \
- $(CSI_TYPES_PROTO) \
$(EXECUTOR_PROTO) \
$(DOCKER_SPEC_PROTO) \
$(DOCKER_V1_PROTO) \
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index 5bf7113..bb43784 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -195,6 +195,16 @@ bool operator==(const Volume& left, const Volume& right)
}
+bool operator==(
+ const Volume::Source::CSIVolume::VolumeCapability& left,
+ const Volume::Source::CSIVolume::VolumeCapability& right)
+{
+ // NOTE: `MessageDifferencer::Equivalent` would ignore unknown fields and load
+ // default values for unset fields (which are indistinguishable in proto3).
+ return google::protobuf::util::MessageDifferencer::Equivalent(left, right);
+}
+
+
// TODO(bmahler): Leverage process::http::URL for equality.
bool operator==(const URL& left, const URL& right)
{
@@ -648,6 +658,14 @@ bool operator!=(const TaskStatus& left, const TaskStatus& right)
}
+bool operator!=(
+ const Volume::Source::CSIVolume::VolumeCapability& left,
+ const Volume::Source::CSIVolume::VolumeCapability& right)
+{
+ return !(left == right);
+}
+
+
bool operator==(const CheckStatusInfo& left, const CheckStatusInfo& right)
{
return left.SerializeAsString() == right.SerializeAsString();
diff --git a/src/csi/state.proto b/src/csi/state.proto
index 96ba420..28ad5ef 100644
--- a/src/csi/state.proto
+++ b/src/csi/state.proto
@@ -16,7 +16,7 @@
syntax = "proto3";
-import "mesos/csi/types.proto";
+import "mesos/mesos.proto";
package mesos.csi.state;
@@ -44,7 +44,7 @@ message VolumeState {
State state = 1;
// The capability used to publish the volume. This is a REQUIRED field.
- types.VolumeCapability volume_capability = 2;
+ Volume.Source.CSIVolume.VolumeCapability volume_capability = 2;
// The parameters used when creating the volume. This is an OPTIONAL field.
map<string, string> parameters = 6;
diff --git a/src/csi/types.cpp b/src/csi/types.cpp
deleted file mode 100644
index cb5ee8f..0000000
--- a/src/csi/types.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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 <mesos/csi/types.hpp>
-
-#include <google/protobuf/util/message_differencer.h>
-
-using google::protobuf::util::MessageDifferencer;
-
-namespace mesos {
-namespace csi {
-namespace types {
-
-bool operator==(const VolumeCapability& left, const VolumeCapability& right)
-{
- // NOTE: `MessageDifferencer::Equivalent` would ignore unknown fields and load
- // default values for unset fields (which are indistinguishable in proto3).
- return MessageDifferencer::Equivalent(left, right);
-}
-
-} // namespace types {
-} // namespace csi {
-} // namespace mesos {
diff --git a/src/csi/v0_utils.cpp b/src/csi/v0_utils.cpp
index 248e417..706d880 100644
--- a/src/csi/v0_utils.cpp
+++ b/src/csi/v0_utils.cpp
@@ -35,55 +35,56 @@ RepeatedPtrField<T1> devolve(RepeatedPtrField<T2> from)
}
-types::VolumeCapability::BlockVolume devolve(
+CSIVolume::VolumeCapability::BlockVolume devolve(
const VolumeCapability::BlockVolume& block)
{
- return types::VolumeCapability::BlockVolume();
+ return CSIVolume::VolumeCapability::BlockVolume();
}
-types::VolumeCapability::MountVolume devolve(
+CSIVolume::VolumeCapability::MountVolume devolve(
const VolumeCapability::MountVolume& mount)
{
- types::VolumeCapability::MountVolume result;
+ CSIVolume::VolumeCapability::MountVolume result;
result.set_fs_type(mount.fs_type());
*result.mutable_mount_flags() = mount.mount_flags();
return result;
}
-types::VolumeCapability::AccessMode devolve(
+CSIVolume::VolumeCapability::AccessMode devolve(
const VolumeCapability::AccessMode& accessMode)
{
- types::VolumeCapability::AccessMode result;
+ CSIVolume::VolumeCapability::AccessMode result;
switch (accessMode.mode()) {
case VolumeCapability::AccessMode::UNKNOWN: {
- result.set_mode(types::VolumeCapability::AccessMode::UNKNOWN);
+ result.set_mode(CSIVolume::VolumeCapability::AccessMode::UNKNOWN);
break;
}
case VolumeCapability::AccessMode::SINGLE_NODE_WRITER: {
- result.set_mode(types::VolumeCapability::AccessMode::SINGLE_NODE_WRITER);
+ result.set_mode(
+ CSIVolume::VolumeCapability::AccessMode::SINGLE_NODE_WRITER);
break;
}
case VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY: {
result.set_mode(
- types::VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY);
+ CSIVolume::VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY);
break;
}
case VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY: {
result.set_mode(
- types::VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY);
+ CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY);
break;
}
case VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER: {
result.set_mode(
- types::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER);
+ CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER);
break;
}
case VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER: {
result.set_mode(
- types::VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER);
+ CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER);
break;
}
// NOTE: We avoid using a default clause for the following values in
@@ -99,9 +100,9 @@ types::VolumeCapability::AccessMode devolve(
}
-types::VolumeCapability devolve(const VolumeCapability& capability)
+CSIVolume::VolumeCapability devolve(const VolumeCapability& capability)
{
- types::VolumeCapability result;
+ CSIVolume::VolumeCapability result;
switch (capability.access_type_case()) {
case VolumeCapability::kBlock: {
@@ -125,10 +126,10 @@ types::VolumeCapability devolve(const VolumeCapability& capability)
}
-RepeatedPtrField<types::VolumeCapability> devolve(
+RepeatedPtrField<CSIVolume::VolumeCapability> devolve(
const RepeatedPtrField<VolumeCapability>& capabilities)
{
- return devolve<types::VolumeCapability>(capabilities);
+ return devolve<CSIVolume::VolumeCapability>(capabilities);
}
@@ -146,14 +147,14 @@ RepeatedPtrField<T1> evolve(RepeatedPtrField<T2> from)
VolumeCapability::BlockVolume evolve(
- const types::VolumeCapability::BlockVolume& block)
+ const CSIVolume::VolumeCapability::BlockVolume& block)
{
return VolumeCapability::BlockVolume();
}
VolumeCapability::MountVolume evolve(
- const types::VolumeCapability::MountVolume& mount)
+ const CSIVolume::VolumeCapability::MountVolume& mount)
{
VolumeCapability::MountVolume result;
result.set_fs_type(mount.fs_type());
@@ -163,62 +164,55 @@ VolumeCapability::MountVolume evolve(
VolumeCapability::AccessMode evolve(
- const types::VolumeCapability::AccessMode& accessMode)
+ const CSIVolume::VolumeCapability::AccessMode& accessMode)
{
VolumeCapability::AccessMode result;
switch (accessMode.mode()) {
- case types::VolumeCapability::AccessMode::UNKNOWN: {
+ case CSIVolume::VolumeCapability::AccessMode::UNKNOWN: {
result.set_mode(VolumeCapability::AccessMode::UNKNOWN);
break;
}
- case types::VolumeCapability::AccessMode::SINGLE_NODE_WRITER: {
+ case CSIVolume::VolumeCapability::AccessMode::SINGLE_NODE_WRITER: {
result.set_mode(VolumeCapability::AccessMode::SINGLE_NODE_WRITER);
break;
}
- case types::VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY: {
+ case CSIVolume::VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY: {
result.set_mode(VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY);
break;
}
- case types::VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY: {
+ case CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY: {
result.set_mode(VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY);
break;
}
- case types::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER: {
+ case CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER: {
result.set_mode(VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER);
break;
}
- case types::VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER: {
+ case CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER: {
result.set_mode(VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER);
break;
}
- // NOTE: We avoid using a default clause for the following values in
- // proto3's open enum to enable the compiler to detect missing enum cases
- // for us. See: https://github.com/google/protobuf/issues/3917
- case google::protobuf::kint32min:
- case google::protobuf::kint32max: {
- UNREACHABLE();
- }
}
return result;
}
-VolumeCapability evolve(const types::VolumeCapability& capability)
+VolumeCapability evolve(const CSIVolume::VolumeCapability& capability)
{
VolumeCapability result;
switch (capability.access_type_case()) {
- case types::VolumeCapability::kBlock: {
+ case CSIVolume::VolumeCapability::kBlock: {
*result.mutable_block() = evolve(capability.block());
break;
}
- case types::VolumeCapability::kMount: {
+ case CSIVolume::VolumeCapability::kMount: {
*result.mutable_mount() = evolve(capability.mount());
break;
}
- case types::VolumeCapability::ACCESS_TYPE_NOT_SET: {
+ case CSIVolume::VolumeCapability::ACCESS_TYPE_NOT_SET: {
break;
}
}
@@ -232,7 +226,7 @@ VolumeCapability evolve(const types::VolumeCapability& capability)
RepeatedPtrField<VolumeCapability> devolve(
- const RepeatedPtrField<types::VolumeCapability>& capabilities)
+ const RepeatedPtrField<CSIVolume::VolumeCapability>& capabilities)
{
return evolve<VolumeCapability>(capabilities);
}
diff --git a/src/csi/v0_utils.hpp b/src/csi/v0_utils.hpp
index 468b416..576a938 100644
--- a/src/csi/v0_utils.hpp
+++ b/src/csi/v0_utils.hpp
@@ -19,7 +19,8 @@
#include <google/protobuf/message.h>
-#include <mesos/csi/types.hpp>
+#include <mesos/mesos.hpp>
+
#include <mesos/csi/v0.hpp>
#include <stout/foreach.hpp>
@@ -29,6 +30,9 @@ namespace mesos {
namespace csi {
namespace v0 {
+using CSIVolume = Volume::Source::CSIVolume;
+
+
struct PluginCapabilities
{
PluginCapabilities() = default;
@@ -140,17 +144,17 @@ struct NodeCapabilities
// Helpers to devolve CSI v0 protobufs to their unversioned counterparts.
-types::VolumeCapability devolve(const VolumeCapability& capability);
+CSIVolume::VolumeCapability devolve(const VolumeCapability& capability);
-google::protobuf::RepeatedPtrField<types::VolumeCapability> devolve(
+google::protobuf::RepeatedPtrField<CSIVolume::VolumeCapability> devolve(
const google::protobuf::RepeatedPtrField<VolumeCapability>& capabilities);
// Helpers to evolve unversioned CSI protobufs to their v0 counterparts.
-VolumeCapability evolve(const types::VolumeCapability& capability);
+VolumeCapability evolve(const CSIVolume::VolumeCapability& capability);
google::protobuf::RepeatedPtrField<VolumeCapability> evolve(
- const google::protobuf::RepeatedPtrField<types::VolumeCapability>&
+ const google::protobuf::RepeatedPtrField<CSIVolume::VolumeCapability>&
capabilities);
} // namespace v0 {
diff --git a/src/csi/v0_volume_manager.cpp b/src/csi/v0_volume_manager.cpp
index 4b056e7..b383598 100644
--- a/src/csi/v0_volume_manager.cpp
+++ b/src/csi/v0_volume_manager.cpp
@@ -259,7 +259,7 @@ Future<vector<VolumeInfo>> VolumeManagerProcess::listVolumes()
Future<Bytes> VolumeManagerProcess::getCapacity(
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
if (!controllerCapabilities->getCapacity) {
@@ -280,7 +280,7 @@ Future<Bytes> VolumeManagerProcess::getCapacity(
Future<VolumeInfo> VolumeManagerProcess::createVolume(
const string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
if (!controllerCapabilities->createDeleteVolume) {
@@ -329,7 +329,7 @@ Future<VolumeInfo> VolumeManagerProcess::createVolume(
Future<Option<Error>> VolumeManagerProcess::validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
// If the volume has been checkpointed, the validation succeeds only if the
@@ -1229,7 +1229,7 @@ Future<vector<VolumeInfo>> VolumeManager::listVolumes()
Future<Bytes> VolumeManager::getCapacity(
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
return recovered
@@ -1244,7 +1244,7 @@ Future<Bytes> VolumeManager::getCapacity(
Future<VolumeInfo> VolumeManager::createVolume(
const string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
return recovered
@@ -1260,7 +1260,7 @@ Future<VolumeInfo> VolumeManager::createVolume(
Future<Option<Error>> VolumeManager::validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
return recovered
diff --git a/src/csi/v0_volume_manager.hpp b/src/csi/v0_volume_manager.hpp
index 9d572e7..6920eb8 100644
--- a/src/csi/v0_volume_manager.hpp
+++ b/src/csi/v0_volume_manager.hpp
@@ -24,8 +24,6 @@
#include <mesos/mesos.hpp>
-#include <mesos/csi/types.hpp>
-
#include <process/future.hpp>
#include <process/grpc.hpp>
#include <process/http.hpp>
@@ -74,20 +72,20 @@ public:
process::Future<std::vector<VolumeInfo>> listVolumes() override;
process::Future<Bytes> getCapacity(
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters)
override;
process::Future<VolumeInfo> createVolume(
const std::string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters)
override;
process::Future<Option<Error>> validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters)
override;
diff --git a/src/csi/v0_volume_manager_process.hpp b/src/csi/v0_volume_manager_process.hpp
index 50148ff..d5a5eb2 100644
--- a/src/csi/v0_volume_manager_process.hpp
+++ b/src/csi/v0_volume_manager_process.hpp
@@ -24,8 +24,6 @@
#include <mesos/mesos.hpp>
-#include <mesos/csi/types.hpp>
-
#include <process/future.hpp>
#include <process/grpc.hpp>
#include <process/http.hpp>
@@ -71,18 +69,18 @@ public:
process::Future<std::vector<VolumeInfo>> listVolumes();
process::Future<Bytes> getCapacity(
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters);
process::Future<VolumeInfo> createVolume(
const std::string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters);
process::Future<Option<Error>> validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters);
process::Future<bool> deleteVolume(const std::string& volumeId);
diff --git a/src/csi/v1_utils.cpp b/src/csi/v1_utils.cpp
index e74138b..8d2eca3 100644
--- a/src/csi/v1_utils.cpp
+++ b/src/csi/v1_utils.cpp
@@ -35,55 +35,56 @@ RepeatedPtrField<T1> devolve(RepeatedPtrField<T2> from)
}
-types::VolumeCapability::BlockVolume devolve(
+CSIVolume::VolumeCapability::BlockVolume devolve(
const VolumeCapability::BlockVolume& block)
{
- return types::VolumeCapability::BlockVolume();
+ return CSIVolume::VolumeCapability::BlockVolume();
}
-types::VolumeCapability::MountVolume devolve(
+CSIVolume::VolumeCapability::MountVolume devolve(
const VolumeCapability::MountVolume& mount)
{
- types::VolumeCapability::MountVolume result;
+ CSIVolume::VolumeCapability::MountVolume result;
result.set_fs_type(mount.fs_type());
*result.mutable_mount_flags() = mount.mount_flags();
return result;
}
-types::VolumeCapability::AccessMode devolve(
+CSIVolume::VolumeCapability::AccessMode devolve(
const VolumeCapability::AccessMode& accessMode)
{
- types::VolumeCapability::AccessMode result;
+ CSIVolume::VolumeCapability::AccessMode result;
switch (accessMode.mode()) {
case VolumeCapability::AccessMode::UNKNOWN: {
- result.set_mode(types::VolumeCapability::AccessMode::UNKNOWN);
+ result.set_mode(CSIVolume::VolumeCapability::AccessMode::UNKNOWN);
break;
}
case VolumeCapability::AccessMode::SINGLE_NODE_WRITER: {
- result.set_mode(types::VolumeCapability::AccessMode::SINGLE_NODE_WRITER);
+ result.set_mode(
+ CSIVolume::VolumeCapability::AccessMode::SINGLE_NODE_WRITER);
break;
}
case VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY: {
result.set_mode(
- types::VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY);
+ CSIVolume::VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY);
break;
}
case VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY: {
result.set_mode(
- types::VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY);
+ CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY);
break;
}
case VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER: {
result.set_mode(
- types::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER);
+ CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER);
break;
}
case VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER: {
result.set_mode(
- types::VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER);
+ CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER);
break;
}
// NOTE: We avoid using a default clause for the following values in
@@ -99,9 +100,9 @@ types::VolumeCapability::AccessMode devolve(
}
-types::VolumeCapability devolve(const VolumeCapability& capability)
+CSIVolume::VolumeCapability devolve(const VolumeCapability& capability)
{
- types::VolumeCapability result;
+ CSIVolume::VolumeCapability result;
switch (capability.access_type_case()) {
case VolumeCapability::kBlock: {
@@ -125,10 +126,10 @@ types::VolumeCapability devolve(const VolumeCapability& capability)
}
-RepeatedPtrField<types::VolumeCapability> devolve(
+RepeatedPtrField<CSIVolume::VolumeCapability> devolve(
const RepeatedPtrField<VolumeCapability>& capabilities)
{
- return devolve<types::VolumeCapability>(capabilities);
+ return devolve<CSIVolume::VolumeCapability>(capabilities);
}
@@ -146,14 +147,14 @@ RepeatedPtrField<T1> evolve(RepeatedPtrField<T2> from)
VolumeCapability::BlockVolume evolve(
- const types::VolumeCapability::BlockVolume& block)
+ const CSIVolume::VolumeCapability::BlockVolume& block)
{
return VolumeCapability::BlockVolume();
}
VolumeCapability::MountVolume evolve(
- const types::VolumeCapability::MountVolume& mount)
+ const CSIVolume::VolumeCapability::MountVolume& mount)
{
VolumeCapability::MountVolume result;
result.set_fs_type(mount.fs_type());
@@ -163,62 +164,55 @@ VolumeCapability::MountVolume evolve(
VolumeCapability::AccessMode evolve(
- const types::VolumeCapability::AccessMode& accessMode)
+ const CSIVolume::VolumeCapability::AccessMode& accessMode)
{
VolumeCapability::AccessMode result;
switch (accessMode.mode()) {
- case types::VolumeCapability::AccessMode::UNKNOWN: {
+ case CSIVolume::VolumeCapability::AccessMode::UNKNOWN: {
result.set_mode(VolumeCapability::AccessMode::UNKNOWN);
break;
}
- case types::VolumeCapability::AccessMode::SINGLE_NODE_WRITER: {
+ case CSIVolume::VolumeCapability::AccessMode::SINGLE_NODE_WRITER: {
result.set_mode(VolumeCapability::AccessMode::SINGLE_NODE_WRITER);
break;
}
- case types::VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY: {
+ case CSIVolume::VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY: {
result.set_mode(VolumeCapability::AccessMode::SINGLE_NODE_READER_ONLY);
break;
}
- case types::VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY: {
+ case CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY: {
result.set_mode(VolumeCapability::AccessMode::MULTI_NODE_READER_ONLY);
break;
}
- case types::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER: {
+ case CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER: {
result.set_mode(VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER);
break;
}
- case types::VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER: {
+ case CSIVolume::VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER: {
result.set_mode(VolumeCapability::AccessMode::MULTI_NODE_MULTI_WRITER);
break;
}
- // NOTE: We avoid using a default clause for the following values in
- // proto3's open enum to enable the compiler to detect missing enum cases
- // for us. See: https://github.com/google/protobuf/issues/3917
- case google::protobuf::kint32min:
- case google::protobuf::kint32max: {
- UNREACHABLE();
- }
}
return result;
}
-VolumeCapability evolve(const types::VolumeCapability& capability)
+VolumeCapability evolve(const CSIVolume::VolumeCapability& capability)
{
VolumeCapability result;
switch (capability.access_type_case()) {
- case types::VolumeCapability::kBlock: {
+ case CSIVolume::VolumeCapability::kBlock: {
*result.mutable_block() = evolve(capability.block());
break;
}
- case types::VolumeCapability::kMount: {
+ case CSIVolume::VolumeCapability::kMount: {
*result.mutable_mount() = evolve(capability.mount());
break;
}
- case types::VolumeCapability::ACCESS_TYPE_NOT_SET: {
+ case CSIVolume::VolumeCapability::ACCESS_TYPE_NOT_SET: {
break;
}
}
@@ -232,7 +226,7 @@ VolumeCapability evolve(const types::VolumeCapability& capability)
RepeatedPtrField<VolumeCapability> devolve(
- const RepeatedPtrField<types::VolumeCapability>& capabilities)
+ const RepeatedPtrField<CSIVolume::VolumeCapability>& capabilities)
{
return evolve<VolumeCapability>(capabilities);
}
diff --git a/src/csi/v1_utils.hpp b/src/csi/v1_utils.hpp
index 11a64d7..ca774d8 100644
--- a/src/csi/v1_utils.hpp
+++ b/src/csi/v1_utils.hpp
@@ -19,7 +19,8 @@
#include <google/protobuf/message.h>
-#include <mesos/csi/types.hpp>
+#include <mesos/mesos.hpp>
+
#include <mesos/csi/v1.hpp>
#include <stout/foreach.hpp>
@@ -29,6 +30,9 @@ namespace mesos {
namespace csi {
namespace v1 {
+using CSIVolume = Volume::Source::CSIVolume;
+
+
struct PluginCapabilities
{
PluginCapabilities() = default;
@@ -198,17 +202,17 @@ struct NodeCapabilities
// Helpers to devolve CSI v1 protobufs to their unversioned counterparts.
-types::VolumeCapability devolve(const VolumeCapability& capability);
+CSIVolume::VolumeCapability devolve(const VolumeCapability& capability);
-google::protobuf::RepeatedPtrField<types::VolumeCapability> devolve(
+google::protobuf::RepeatedPtrField<CSIVolume::VolumeCapability> devolve(
const google::protobuf::RepeatedPtrField<VolumeCapability>& capabilities);
// Helpers to evolve unversioned CSI protobufs to their v1 counterparts.
-VolumeCapability evolve(const types::VolumeCapability& capability);
+VolumeCapability evolve(const CSIVolume::VolumeCapability& capability);
google::protobuf::RepeatedPtrField<VolumeCapability> evolve(
- const google::protobuf::RepeatedPtrField<types::VolumeCapability>&
+ const google::protobuf::RepeatedPtrField<CSIVolume::VolumeCapability>&
capabilities);
} // namespace v1 {
diff --git a/src/csi/v1_volume_manager.cpp b/src/csi/v1_volume_manager.cpp
index 9e44947..a9b80d0 100644
--- a/src/csi/v1_volume_manager.cpp
+++ b/src/csi/v1_volume_manager.cpp
@@ -260,7 +260,7 @@ Future<vector<VolumeInfo>> VolumeManagerProcess::listVolumes()
Future<Bytes> VolumeManagerProcess::getCapacity(
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
if (!controllerCapabilities->getCapacity) {
@@ -281,7 +281,7 @@ Future<Bytes> VolumeManagerProcess::getCapacity(
Future<VolumeInfo> VolumeManagerProcess::createVolume(
const string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
if (!controllerCapabilities->createDeleteVolume) {
@@ -331,7 +331,7 @@ Future<VolumeInfo> VolumeManagerProcess::createVolume(
Future<Option<Error>> VolumeManagerProcess::validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
// If the volume has been checkpointed, the validation succeeds only if the
@@ -1263,7 +1263,7 @@ Future<vector<VolumeInfo>> VolumeManager::listVolumes()
Future<Bytes> VolumeManager::getCapacity(
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
return recovered
@@ -1278,7 +1278,7 @@ Future<Bytes> VolumeManager::getCapacity(
Future<VolumeInfo> VolumeManager::createVolume(
const string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
return recovered
@@ -1294,7 +1294,7 @@ Future<VolumeInfo> VolumeManager::createVolume(
Future<Option<Error>> VolumeManager::validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const Map<string, string>& parameters)
{
return recovered
diff --git a/src/csi/v1_volume_manager.hpp b/src/csi/v1_volume_manager.hpp
index ba984a9..4db11b5 100644
--- a/src/csi/v1_volume_manager.hpp
+++ b/src/csi/v1_volume_manager.hpp
@@ -24,8 +24,6 @@
#include <mesos/mesos.hpp>
-#include <mesos/csi/types.hpp>
-
#include <process/future.hpp>
#include <process/grpc.hpp>
#include <process/http.hpp>
@@ -74,20 +72,20 @@ public:
process::Future<std::vector<VolumeInfo>> listVolumes() override;
process::Future<Bytes> getCapacity(
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters)
override;
process::Future<VolumeInfo> createVolume(
const std::string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters)
override;
process::Future<Option<Error>> validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters)
override;
diff --git a/src/csi/v1_volume_manager_process.hpp b/src/csi/v1_volume_manager_process.hpp
index a03e291..df52c3d 100644
--- a/src/csi/v1_volume_manager_process.hpp
+++ b/src/csi/v1_volume_manager_process.hpp
@@ -24,8 +24,6 @@
#include <mesos/mesos.hpp>
-#include <mesos/csi/types.hpp>
-
#include <process/future.hpp>
#include <process/grpc.hpp>
#include <process/http.hpp>
@@ -71,18 +69,18 @@ public:
process::Future<std::vector<VolumeInfo>> listVolumes();
process::Future<Bytes> getCapacity(
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters);
process::Future<VolumeInfo> createVolume(
const std::string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters);
process::Future<Option<Error>> validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters);
process::Future<bool> deleteVolume(const std::string& volumeId);
diff --git a/src/csi/volume_manager.hpp b/src/csi/volume_manager.hpp
index 0aa6337..199cf44 100644
--- a/src/csi/volume_manager.hpp
+++ b/src/csi/volume_manager.hpp
@@ -24,8 +24,6 @@
#include <mesos/mesos.hpp>
-#include <mesos/csi/types.hpp>
-
#include <process/future.hpp>
#include <process/grpc.hpp>
#include <process/http.hpp>
@@ -77,7 +75,7 @@ public:
// given capability and parameters. Returns zero bytes if `GET_CAPACITY`
// controller capability is not supported.
virtual process::Future<Bytes> getCapacity(
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters) = 0;
// The following methods are used to manage volume lifecycles. The lifecycle
@@ -104,7 +102,7 @@ public:
virtual process::Future<VolumeInfo> createVolume(
const std::string& name,
const Bytes& capacity,
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters) = 0;
// Validates a volume against the given capability and parameters. Once
@@ -112,7 +110,7 @@ public:
// untracked then returns None. Otherwise returns the validation error.
virtual process::Future<Option<Error>> validateVolume(
const VolumeInfo& volumeInfo,
- const types::VolumeCapability& capability,
+ const Volume::Source::CSIVolume::VolumeCapability& capability,
const google::protobuf::Map<std::string, std::string>& parameters) = 0;
// Deprovisions a volume and returns true if `CREATE_DELETE_VOLUME` controller
diff --git a/src/examples/test_csi_plugin.cpp b/src/examples/test_csi_plugin.cpp
index 6202173..214a3ee 100644
--- a/src/examples/test_csi_plugin.cpp
+++ b/src/examples/test_csi_plugin.cpp
@@ -31,7 +31,6 @@
#include <mesos/type_utils.hpp>
-#include <mesos/csi/types.hpp>
#include <mesos/csi/v0.hpp>
#include <mesos/csi/v1.hpp>
@@ -99,10 +98,11 @@ using grpc::WriteOptions;
using mesos::csi::VolumeInfo;
-using mesos::csi::types::VolumeCapability;
-
using process::grpc::StatusError;
+using VolumeCapability = mesos::Volume::Source::CSIVolume::VolumeCapability;
+
+
constexpr char PLUGIN_NAME[] = "org.apache.mesos.csi.test";
constexpr char NODE_ID[] = "localhost";
constexpr Bytes DEFAULT_VOLUME_CAPACITY = Megabytes(64);
diff --git a/src/resource_provider/state.proto b/src/resource_provider/state.proto
index e19d609..4192c0d 100644
--- a/src/resource_provider/state.proto
+++ b/src/resource_provider/state.proto
@@ -18,8 +18,6 @@ syntax = "proto2";
import "mesos/mesos.proto";
-import "mesos/csi/types.proto";
-
package mesos.resource_provider;
option java_package = "org.apache.mesos.resource_provider";
@@ -38,7 +36,7 @@ message ResourceProviderState {
// Describes a manifest of CSI properties associated with a profile.
// See DiskProfileAdaptor::ProfileInfo.
message ProfileInfo {
- required csi.types.VolumeCapability capability = 1;
+ required Volume.Source.CSIVolume.VolumeCapability capability = 1;
map<string, string> parameters = 2;
}
diff --git a/src/tests/csi_utils_tests.cpp b/src/tests/csi_utils_tests.cpp
index 5ebd0e1..0457d8c 100644
--- a/src/tests/csi_utils_tests.cpp
+++ b/src/tests/csi_utils_tests.cpp
@@ -21,7 +21,6 @@
#include <gtest/gtest.h>
-#include <mesos/csi/types.hpp>
#include <mesos/csi/v0.hpp>
#include <mesos/csi/v1.hpp>
diff --git a/src/tests/disk_profile_adaptor_tests.cpp b/src/tests/disk_profile_adaptor_tests.cpp
index 2809847..cafbb76 100644
--- a/src/tests/disk_profile_adaptor_tests.cpp
+++ b/src/tests/disk_profile_adaptor_tests.cpp
@@ -19,7 +19,6 @@
#include <tuple>
#include <vector>
-#include <mesos/csi/types.hpp>
#include <mesos/csi/v0.hpp>
#include <mesos/module/disk_profile_adaptor.hpp>
@@ -71,6 +70,9 @@ namespace mesos {
namespace internal {
namespace tests {
+using VolumeCapability = mesos::Volume::Source::CSIVolume::VolumeCapability;
+
+
constexpr char URI_DISK_PROFILE_ADAPTOR_NAME[] =
"org_apache_mesos_UriDiskProfileAdaptor";
@@ -486,7 +488,7 @@ TEST_F(UriDiskProfileAdaptorTest, FetchFromFile)
AWAIT_ASSERT_READY(mapping);
ASSERT_TRUE(mapping->capability.has_block());
ASSERT_EQ(
- csi::types::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER,
+ VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER,
mapping->capability.access_mode().mode());
Clock::resume();
[mesos] 03/04: Introduced a new agent flag
`--csi_plugin_config_dir`.
Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 4d3c3d770eceff12ea5d39dbd57ce6bae602266e
Author: Qian Zhang <zh...@gmail.com>
AuthorDate: Mon Jul 13 17:16:28 2020 +0800
Introduced a new agent flag `--csi_plugin_config_dir`.
Review: https://reviews.apache.org/r/72672
---
docs/configuration/agent.md | 43 +++++++++++++++++++++++++++++++++++++++++++
src/slave/flags.cpp | 39 +++++++++++++++++++++++++++++++++++++++
src/slave/flags.hpp | 1 +
3 files changed, 83 insertions(+)
diff --git a/docs/configuration/agent.md b/docs/configuration/agent.md
index 01ffa38..e8608d9 100644
--- a/docs/configuration/agent.md
+++ b/docs/configuration/agent.md
@@ -1511,6 +1511,49 @@ Example config file in this directory:
</td>
</tr>
+<tr id="csi_plugin_config_dir">
+ <td>
+ --csi_plugin_config_dir=VALUE
+ </td>
+ <td>
+Path to a directory that contains CSI plugin configs.
+Each file in the config dir should contain a JSON object representing
+a <code>CSIPluginInfo</code> object which can be either a managed CSI
+plugin (i.e. the plugin launched by Mesos as a standalone container)
+or an unmanaged CSI plugin (i.e. the plugin launched out of Mesos).
+<p/>
+Example config files in this directory:
+<pre><code>{
+ "type": "org.apache.mesos.csi.managed-plugin",
+ "containers": [
+ {
+ "services": [
+ "CONTROLLER_SERVICE",
+ "NODE_SERVICE"
+ ],
+ "command": {
+ "shell": false,
+ "value": "managed-plugin",
+ "arguments": [
+ "managed-plugin",
+ "--endpoint=$(CSI_ENDPOINT)"
+ ]
+ },
+ "resources": [
+ {"name": "cpus", "type": "SCALAR", "scalar": {"value": 0.1}},
+ {"name": "mem", "type": "SCALAR", "scalar": {"value": 1024}}
+ ]
+ }
+ ]
+}</code></pre>
+<pre><code>{
+ "type": "org.apache.mesos.csi.unmanaged-plugin",
+ "node_service_endpoint": "/var/lib/unmanaged-plugin/csi.sock",
+ "target_path_root": "/mnt/unmanaged-plugin"
+}</code></pre>
+ </td>
+</tr>
+
<tr id="revocable_cpu_low_priority">
<td>
--[no-]revocable_cpu_low_priority
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 2f88b90..02a5568 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -115,6 +115,45 @@ mesos::internal::slave::Flags::Flags()
" \"name\": \"lvm\"\n"
"}");
+ add(&Flags::csi_plugin_config_dir,
+ "csi_plugin_config_dir",
+ "Path to a directory that contains CSI plugin configs.\n"
+ "Each file in the config dir should contain a JSON object representing\n"
+ "a `CSIPluginInfo` object which can be either a managed CSI plugin\n"
+ "(i.e. the plugin launched by Mesos as a standalone container) or an\n"
+ "unmanaged CSI plugin (i.e. the plugin launched out of Mesos).\n"
+ "\n"
+ "Example config files in this directory:\n"
+ "{\n"
+ " \"type\": \"org.apache.mesos.csi.managed-plugin\",\n"
+ " \"containers\": [\n"
+ " {\n"
+ " \"services\": [\n"
+ " \"CONTROLLER_SERVICE\",\n"
+ " \"NODE_SERVICE\"\n"
+ " ],\n"
+ " \"command\": {\n"
+ " \"shell\": false,\n"
+ " \"value\": \"managed-plugin\",\n"
+ " \"arguments\": [\n"
+ " \"managed-plugin\",\n"
+ " \"--endpoint=$(CSI_ENDPOINT)\"\n"
+ " ]\n"
+ " },\n"
+ " \"resources\": [\n"
+ " {\"name\": \"cpus\", \"type\": \"SCALAR\", \"scalar\": {\"value\": 0.1}},\n" // NOLINT(whitespace/line_length)
+ " {\"name\": \"mem\", \"type\": \"SCALAR\", \"scalar\": {\"value\": 1024}}\n" // NOLINT(whitespace/line_length)
+ " ]\n"
+ " }\n"
+ " ]\n"
+ "}\n"
+ "\n"
+ "{\n"
+ " \"type\": \"org.apache.mesos.csi.unmanaged-plugin\",\n"
+ " \"node_service_endpoint\": \"/var/lib/unmanaged-plugin/csi.sock\",\n"
+ " \"target_path_root\": \"/mnt/unmanaged-plugin\"\n"
+ "}");
+
add(&Flags::disk_profile_adaptor,
"disk_profile_adaptor",
"The name of the disk profile adaptor module that storage resource\n"
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index c3ff887..51770f5 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -46,6 +46,7 @@ public:
bool hostname_lookup;
Option<std::string> resources;
Option<std::string> resource_provider_config_dir;
+ Option<std::string> csi_plugin_config_dir;
Option<std::string> disk_profile_adaptor;
std::string isolation;
std::string launcher;
[mesos] 04/04: Improved CSI service manager to support unmanaged
CSI plugins.
Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit d2c84d14b63f137546c00d69b0309c4543811732
Author: Qian Zhang <zh...@gmail.com>
AuthorDate: Wed Jul 15 16:02:48 2020 +0800
Improved CSI service manager to support unmanaged CSI plugins.
Review: https://reviews.apache.org/r/72683
---
src/csi/service_manager.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++-
src/csi/service_manager.hpp | 12 +++++-
2 files changed, 101 insertions(+), 3 deletions(-)
diff --git a/src/csi/service_manager.cpp b/src/csi/service_manager.cpp
index a87df96..7a8d8e5 100644
--- a/src/csi/service_manager.cpp
+++ b/src/csi/service_manager.cpp
@@ -137,6 +137,12 @@ public:
const Runtime& _runtime,
Metrics* _metrics);
+ ServiceManagerProcess(
+ const CSIPluginInfo& _info,
+ const hashset<Service>& services,
+ const Runtime& _runtime,
+ Metrics* _metrics);
+
Future<Nothing> recover();
Future<string> getServiceEndpoint(const Service& service);
@@ -180,8 +186,15 @@ private:
http::Headers headers;
Option<string> apiVersion;
+
+ // This is for the managed CSI plugin which will be launched as
+ // standalone containers.
hashmap<Service, ContainerID> serviceContainers;
+ // This is for the unmanaged CSI plugin which is already deployed
+ // out of Mesos.
+ hashmap<Service, string> serviceEndpoints;
+
hashmap<ContainerID, Owned<ContainerDaemon>> daemons;
hashmap<ContainerID, Owned<Promise<string>>> endpoints;
};
@@ -233,8 +246,45 @@ ServiceManagerProcess::ServiceManagerProcess(
}
+ServiceManagerProcess::ServiceManagerProcess(
+ const CSIPluginInfo& _info,
+ const hashset<Service>& services,
+ const Runtime& _runtime,
+ Metrics* _metrics)
+ : ProcessBase(process::ID::generate("csi-service-manager")),
+ agentUrl(),
+ rootDir(),
+ info(_info),
+ containerPrefix(),
+ authToken(),
+ contentType(ContentType::PROTOBUF),
+ runtime(_runtime),
+ metrics(_metrics)
+{
+ foreach (const Service& service, services) {
+ foreach (const CSIPluginEndpoint& serviceEndpoint, info.endpoints()) {
+ if (serviceEndpoint.csi_service() == service) {
+ serviceEndpoints[service] = serviceEndpoint.endpoint();
+ break;
+ }
+ }
+
+ CHECK(serviceEndpoints.contains(service))
+ << service << " not found for CSI plugin type '" << info.type()
+ << "' and name '" << info.name() << "'";
+ }
+}
+
+
Future<Nothing> ServiceManagerProcess::recover()
{
+ // For the unmanaged CSI plugin, we do not need to recover anything.
+ if (!serviceEndpoints.empty()) {
+ return Nothing();
+ }
+
+ CHECK(!serviceContainers.empty());
+
return getContainers()
.then(process::defer(self(), [=](
const hashmap<ContainerID, Option<ContainerStatus>>& containers)
@@ -346,6 +396,21 @@ Future<Nothing> ServiceManagerProcess::recover()
Future<string> ServiceManagerProcess::getServiceEndpoint(const Service& service)
{
+ // For the unmanaged CSI plugin, get its endpoint from
+ // `serviceEndpoints` directly.
+ if (!serviceEndpoints.empty()) {
+ if (serviceEndpoints.contains(service)) {
+ return serviceEndpoints.at(service);
+ } else {
+ return Failure(
+ stringify(service) + " not found for CSI plugin type '" +
+ info.type() + "' and name '" + info.name() + "'");
+ }
+ }
+
+ // For the managed CSI plugin, get its endpoint via its corresponding
+ // standalone container ID.
+ CHECK(!serviceContainers.empty());
if (!serviceContainers.contains(service)) {
return Failure(
stringify(service) + " not found for CSI plugin type '" + info.type() +
@@ -362,8 +427,15 @@ Future<string> ServiceManagerProcess::getApiVersion()
return apiVersion.get();
}
- // Ensure that the plugin has been probed (which does the API version
- // detection) through `getEndpoint` before returning the API version.
+ // Ensure that the unmanaged CSI plugin has been probed (which does the API
+ // version detection) before returning the API version.
+ if (!serviceEndpoints.empty()) {
+ return probeEndpoint(serviceEndpoints.begin()->second)
+ .then(process::defer(self(), [=] { return CHECK_NOTNONE(apiVersion); }));
+ }
+
+ // For the managed CSI plugin, `probeEndpoint` will be internally called by
+ // `getEndpoint` to do the API version detection.
CHECK(!serviceContainers.empty());
return getEndpoint(serviceContainers.begin()->second)
.then(process::defer(self(), [=] { return CHECK_NOTNONE(apiVersion); }));
@@ -790,6 +862,22 @@ ServiceManager::ServiceManager(
}
+ServiceManager::ServiceManager(
+ const CSIPluginInfo& info,
+ const hashset<Service>& services,
+ const process::grpc::client::Runtime& runtime,
+ Metrics* metrics)
+ : process(new ServiceManagerProcess(
+ info,
+ services,
+ runtime,
+ metrics))
+{
+ process::spawn(CHECK_NOTNULL(process.get()));
+ recovered = process::dispatch(process.get(), &ServiceManagerProcess::recover);
+}
+
+
ServiceManager::~ServiceManager()
{
recovered.discard();
diff --git a/src/csi/service_manager.hpp b/src/csi/service_manager.hpp
index 60a0805..76a80fb 100644
--- a/src/csi/service_manager.hpp
+++ b/src/csi/service_manager.hpp
@@ -47,10 +47,12 @@ constexpr Service NODE_SERVICE = CSIPluginContainerInfo::NODE_SERVICE;
class ServiceManagerProcess;
-// Manages the service containers of a CSI plugin instance.
+// Manages the services of a CSI plugin instance.
class ServiceManager
{
public:
+ // This is for the managed CSI plugins which will be
+ // launched as standalone containers.
ServiceManager(
const process::http::URL& agentUrl,
const std::string& rootDir,
@@ -61,6 +63,14 @@ public:
const process::grpc::client::Runtime& runtime,
Metrics* metrics);
+ // This is for the unmanaged CSI plugins which we assume
+ // are already launched out of Mesos.
+ ServiceManager(
+ const CSIPluginInfo& info,
+ const hashset<Service>& services,
+ const process::grpc::client::Runtime& runtime,
+ Metrics* metrics);
+
// Since this class contains `Owned` members which should not but can be
// copied, explicitly make this class non-copyable.
//