Repository: mesos Updated Branches: refs/heads/master dbaf85773 -> c399377f0
Used a wrapper message for storage resource provider info. This is more future proof in case we want to add more storage resource provider specific information. Review: https://reviews.apache.org/r/64389 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c399377f Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c399377f Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c399377f Branch: refs/heads/master Commit: c399377f020d446053764f6e26fcbda939966a7a Parents: dbaf857 Author: Jie Yu <[email protected]> Authored: Wed Dec 6 11:38:34 2017 -0800 Committer: Jie Yu <[email protected]> Committed: Wed Dec 6 11:46:47 2017 -0800 ---------------------------------------------------------------------- include/mesos/mesos.proto | 7 +++- include/mesos/v1/mesos.proto | 7 +++- src/common/type_utils.cpp | 8 +++++ src/resource_provider/storage/provider.cpp | 47 +++++++++++++------------ src/v1/mesos.cpp | 8 +++++ 5 files changed, 52 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/c399377f/include/mesos/mesos.proto ---------------------------------------------------------------------- diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto index 5b93478..839ddb1 100644 --- a/include/mesos/mesos.proto +++ b/include/mesos/mesos.proto @@ -1082,7 +1082,12 @@ message ResourceProviderInfo { // new reservation's role must be a child of the current one. repeated Resource.ReservationInfo default_reservations = 5; // EXPERIMENTAL. - optional CSIPluginInfo storage = 6; // EXPERIMENTAL. + // Storage resource provider related information. + message Storage { + required CSIPluginInfo plugin = 1; + } + + optional Storage storage = 6; // EXPERIMENTAL. } http://git-wip-us.apache.org/repos/asf/mesos/blob/c399377f/include/mesos/v1/mesos.proto ---------------------------------------------------------------------- diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto index 22b3c68..0ea17a8 100644 --- a/include/mesos/v1/mesos.proto +++ b/include/mesos/v1/mesos.proto @@ -1074,7 +1074,12 @@ message ResourceProviderInfo { // new reservation's role must be a child of the current one. repeated Resource.ReservationInfo default_reservations = 5; // EXPERIMENTAL. - optional CSIPluginInfo storage = 6; // EXPERIMENTAL. + // Storage resource provider related information. + message Storage { + required CSIPluginInfo plugin = 1; + } + + optional Storage storage = 6; // EXPERIMENTAL. } http://git-wip-us.apache.org/repos/asf/mesos/blob/c399377f/src/common/type_utils.cpp ---------------------------------------------------------------------- diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp index 1b466fc..8cc987c 100644 --- a/src/common/type_utils.cpp +++ b/src/common/type_utils.cpp @@ -401,6 +401,14 @@ bool operator==(const MasterInfo& left, const MasterInfo& right) bool operator==( + const ResourceProviderInfo::Storage& left, + const ResourceProviderInfo::Storage& right) +{ + return left.plugin() == right.plugin(); +} + + +bool operator==( const ResourceProviderInfo& left, const ResourceProviderInfo& right) { http://git-wip-us.apache.org/repos/asf/mesos/blob/c399377f/src/resource_provider/storage/provider.cpp ---------------------------------------------------------------------- diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp index d35b0d0..dc77368 100644 --- a/src/resource_provider/storage/provider.cpp +++ b/src/resource_provider/storage/provider.cpp @@ -169,8 +169,8 @@ static inline ContainerID getContainerId( value += strings::join( "-", - strings::replace(info.storage().type(), ".", "-"), - info.storage().name(), + strings::replace(info.storage().plugin().type(), ".", "-"), + info.storage().plugin().name(), ""); for (int i = 0; i < container.services_size(); i++) { @@ -189,7 +189,7 @@ static Option<CSIPluginContainerInfo> getCSIPluginContainerInfo( const ContainerID& containerId) { foreach (const CSIPluginContainerInfo& container, - info.storage().containers()) { + info.storage().plugin().containers()) { if (getContainerId(info, container) == containerId) { return container; } @@ -371,7 +371,7 @@ void StorageLocalResourceProviderProcess::initialize() csiVersion.set_patch(0); foreach (const CSIPluginContainerInfo& container, - info.storage().containers()) { + info.storage().plugin().containers()) { auto it = find( container.services().begin(), container.services().end(), @@ -383,7 +383,7 @@ void StorageLocalResourceProviderProcess::initialize() } foreach (const CSIPluginContainerInfo& container, - info.storage().containers()) { + info.storage().plugin().containers()) { auto it = find( container.services().begin(), container.services().end(), @@ -493,13 +493,14 @@ Future<Nothing> StorageLocalResourceProviderProcess::recoverServices() { Try<list<string>> containerPaths = csi::paths::getContainerPaths( slave::paths::getCsiRootDir(workDir), - info.storage().type(), - info.storage().name()); + info.storage().plugin().type(), + info.storage().plugin().name()); if (containerPaths.isError()) { return Failure( "Failed to find plugin containers for CSI plugin type '" + - info.storage().type() + "' and name '" + info.storage().name() + ": " + + info.storage().plugin().type() + "' and name '" + + info.storage().plugin().name() + ": " + containerPaths.error()); } @@ -515,8 +516,8 @@ Future<Nothing> StorageLocalResourceProviderProcess::recoverServices() containerId == nodeContainerId) { const string configPath = csi::paths::getContainerInfoPath( slave::paths::getCsiRootDir(workDir), - info.storage().type(), - info.storage().name(), + info.storage().plugin().type(), + info.storage().plugin().name(), containerId); Result<CSIPluginContainerInfo> config = @@ -539,8 +540,8 @@ Future<Nothing> StorageLocalResourceProviderProcess::recoverServices() Result<string> endpointDir = os::realpath(csi::paths::getEndpointDirSymlinkPath( slave::paths::getCsiRootDir(workDir), - info.storage().type(), - info.storage().name(), + info.storage().plugin().type(), + info.storage().plugin().name(), containerId)); if (endpointDir.isSome()) { @@ -720,8 +721,8 @@ Future<csi::Client> StorageLocalResourceProviderProcess::getService( // Set the `CSI_ENDPOINT` environment variable. Try<string> endpoint = csi::paths::getEndpointSocketPath( slave::paths::getCsiRootDir(workDir), - info.storage().type(), - info.storage().name(), + info.storage().plugin().type(), + info.storage().plugin().name(), containerId); if (endpoint.isError()) { @@ -754,8 +755,8 @@ Future<csi::Client> StorageLocalResourceProviderProcess::getService( // Prepare the directory where the mount points will be placed. const string mountDir = csi::paths::getMountRootDir( slave::paths::getCsiRootDir(workDir), - info.storage().type(), - info.storage().name()); + info.storage().plugin().type(), + info.storage().plugin().name()); Try<Nothing> mkdir = os::mkdir(mountDir); if (mkdir.isError()) { @@ -823,8 +824,8 @@ Future<csi::Client> StorageLocalResourceProviderProcess::getService( // Checkpoint the plugin container config. const string configPath = csi::paths::getContainerInfoPath( slave::paths::getCsiRootDir(workDir), - info.storage().type(), - info.storage().name(), + info.storage().plugin().type(), + info.storage().plugin().name(), containerId); Try<Nothing> checkpoint = slave::state::checkpoint(configPath, config.get()); @@ -1052,11 +1053,11 @@ Try<Owned<LocalResourceProvider>> StorageLocalResourceProvider::create( // naming convention. // TODO(chhsiao): We should move this check to a validation function // for `CSIPluginInfo`. - if (!isValidType(info.storage().type()) || - !isValidName(info.storage().name())) { + if (!isValidType(info.storage().plugin().type()) || + !isValidName(info.storage().plugin().name())) { return Error( - "CSI plugin type '" + info.storage().type() + - "' and name '" + info.storage().name() + + "CSI plugin type '" + info.storage().plugin().type() + + "' and name '" + info.storage().plugin().name() + "' does not follow Java package naming convention"); } @@ -1064,7 +1065,7 @@ Try<Owned<LocalResourceProvider>> StorageLocalResourceProvider::create( bool hasNodeService = false; foreach (const CSIPluginContainerInfo& container, - info.storage().containers()) { + info.storage().plugin().containers()) { for (int i = 0; i < container.services_size(); i++) { const CSIPluginContainerInfo::Service service = container.services(i); if (service == CSIPluginContainerInfo::CONTROLLER_SERVICE) { http://git-wip-us.apache.org/repos/asf/mesos/blob/c399377f/src/v1/mesos.cpp ---------------------------------------------------------------------- diff --git a/src/v1/mesos.cpp b/src/v1/mesos.cpp index 2c81b37..190c999 100644 --- a/src/v1/mesos.cpp +++ b/src/v1/mesos.cpp @@ -395,6 +395,14 @@ bool operator==(const MasterInfo& left, const MasterInfo& right) bool operator==( + const ResourceProviderInfo::Storage& left, + const ResourceProviderInfo::Storage& right) +{ + return left.plugin() == right.plugin(); +} + + +bool operator==( const ResourceProviderInfo& left, const ResourceProviderInfo& right) {
