Used `csi::v0::VolumeCapability` in disk profile adaptors. To adapt the change in CSI package names (from `csi` to `csi.v0`), we now use `csi::v0::VolumeCapability` in the disk profile adaptor module interface.
NOTE: This is not future-proof if there is a breaking change in `VolumeCapability`, we might need to change the module interface to support multiple CSI versions in the future. Review: https://reviews.apache.org/r/66409/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6dfd2594 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6dfd2594 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6dfd2594 Branch: refs/heads/master Commit: 6dfd2594123b6218254081bf230c3fba11c65027 Parents: ea5d108 Author: Chun-Hung Hsiao <chhs...@apache.org> Authored: Thu Apr 12 12:07:17 2018 -0700 Committer: Chun-Hung Hsiao <chhs...@mesosphere.io> Committed: Thu Apr 12 14:01:52 2018 -0700 ---------------------------------------------------------------------- .../mesos/resource_provider/storage/disk_profile_adaptor.hpp | 2 +- src/resource_provider/storage/disk_profile.proto | 2 +- src/resource_provider/storage/disk_profile_utils.cpp | 4 ++-- src/resource_provider/storage/disk_profile_utils.hpp | 4 +++- src/tests/disk_profile_adaptor_tests.cpp | 6 +++--- 5 files changed, 10 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/6dfd2594/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp ---------------------------------------------------------------------- diff --git a/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp b/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp index 3a2d86a..739585b 100644 --- a/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp +++ b/include/mesos/resource_provider/storage/disk_profile_adaptor.hpp @@ -63,7 +63,7 @@ public: * of `VolumeCapability` objects, the module will only allow a single * `VolumeCapability`. */ - csi::VolumeCapability capability; + csi::v0::VolumeCapability capability; /** * Free-form key-value pairs which should be passed into the body http://git-wip-us.apache.org/repos/asf/mesos/blob/6dfd2594/src/resource_provider/storage/disk_profile.proto ---------------------------------------------------------------------- diff --git a/src/resource_provider/storage/disk_profile.proto b/src/resource_provider/storage/disk_profile.proto index b9448d7..1c97e9c 100644 --- a/src/resource_provider/storage/disk_profile.proto +++ b/src/resource_provider/storage/disk_profile.proto @@ -52,7 +52,7 @@ message DiskProfileMapping { // NOTE: The name of this field is plural because some CSI requests // support multiple capabilities. However, Mesos currently does not // support this. - .csi.VolumeCapability volume_capabilities = 1; + .csi.v0.VolumeCapability volume_capabilities = 1; // Parameters passed to the CSI CreateVolume RPC. // This field is OPTIONAL. http://git-wip-us.apache.org/repos/asf/mesos/blob/6dfd2594/src/resource_provider/storage/disk_profile_utils.cpp ---------------------------------------------------------------------- diff --git a/src/resource_provider/storage/disk_profile_utils.cpp b/src/resource_provider/storage/disk_profile_utils.cpp index d07c11f..82c69d8 100644 --- a/src/resource_provider/storage/disk_profile_utils.cpp +++ b/src/resource_provider/storage/disk_profile_utils.cpp @@ -178,7 +178,7 @@ Option<Error> validate(const DiskProfileMapping& mapping) // TODO(chhsiao): Move this to CSI validation implementation file. -Option<Error> validate(const csi::VolumeCapability& capability) +Option<Error> validate(const csi::v0::VolumeCapability& capability) { if (capability.has_mount()) { // The total size of this repeated field may not exceed 4 KB. @@ -201,7 +201,7 @@ Option<Error> validate(const csi::VolumeCapability& capability) } if (capability.access_mode().mode() == - csi::VolumeCapability::AccessMode::UNKNOWN) { + csi::v0::VolumeCapability::AccessMode::UNKNOWN) { return Error("'access_mode.mode' is unknown or not set"); } http://git-wip-us.apache.org/repos/asf/mesos/blob/6dfd2594/src/resource_provider/storage/disk_profile_utils.hpp ---------------------------------------------------------------------- diff --git a/src/resource_provider/storage/disk_profile_utils.hpp b/src/resource_provider/storage/disk_profile_utils.hpp index 9a0a31b..8a83a15 100644 --- a/src/resource_provider/storage/disk_profile_utils.hpp +++ b/src/resource_provider/storage/disk_profile_utils.hpp @@ -17,6 +17,8 @@ #ifndef __RESOURCE_PROVIDER_URI_DISK_PROFILE_UTILS_HPP__ #define __RESOURCE_PROVIDER_URI_DISK_PROFILE_UTILS_HPP__ +#include <csi/spec.hpp> + #include <mesos/mesos.hpp> #include <stout/option.hpp> @@ -47,7 +49,7 @@ Option<Error> validate(const resource_provider::DiskProfileMapping& mapping); // Checks the fields inside a `VolumeCapability` according to the // comments above the protobuf. -Option<Error> validate(const csi::VolumeCapability& capability); +Option<Error> validate(const csi::v0::VolumeCapability& capability); } // namespace storage { } // namespace internal { http://git-wip-us.apache.org/repos/asf/mesos/blob/6dfd2594/src/tests/disk_profile_adaptor_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/disk_profile_adaptor_tests.cpp b/src/tests/disk_profile_adaptor_tests.cpp index 948f6ef..3337741 100644 --- a/src/tests/disk_profile_adaptor_tests.cpp +++ b/src/tests/disk_profile_adaptor_tests.cpp @@ -139,13 +139,13 @@ TEST_F(UriDiskProfileAdaptorTest, ParseExample) const string key = "my-profile"; ASSERT_EQ(1u, parsed->profile_matrix().count(key)); - csi::VolumeCapability capability = + csi::v0::VolumeCapability capability = parsed->profile_matrix().at(key).volume_capabilities(); ASSERT_TRUE(capability.has_block()); ASSERT_TRUE(capability.has_access_mode()); ASSERT_EQ( - csi::VolumeCapability::AccessMode::SINGLE_NODE_WRITER, + csi::v0::VolumeCapability::AccessMode::SINGLE_NODE_WRITER, capability.access_mode().mode()); Map<string, string> parameters = @@ -480,7 +480,7 @@ TEST_F(UriDiskProfileAdaptorTest, DISABLED_FetchFromFile) AWAIT_ASSERT_READY(mapping); ASSERT_TRUE(mapping.get().capability.has_block()); ASSERT_EQ( - csi::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER, + csi::v0::VolumeCapability::AccessMode::MULTI_NODE_SINGLE_WRITER, mapping.get().capability.access_mode().mode()); Clock::resume();