You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ch...@apache.org on 2018/07/13 21:41:08 UTC

[03/17] mesos git commit: Made SLRP be able to handle disappeared profiles.

Made SLRP be able to handle disappeared profiles.

When profile disappears, SLRP will remove it from its profile metadata.
Since we maintain an invariant that profiles of all accepted operations
must exist, the assertions related to profile existence remain true.

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


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

Branch: refs/heads/master
Commit: 0449b5f0b2d3fb1b1927637b4a8341ea643d4846
Parents: 16d19ac
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Jun 19 20:53:02 2018 -0700
Committer: Chun-Hung Hsiao <ch...@mesosphere.io>
Committed: Fri Jul 13 14:30:06 2018 -0700

----------------------------------------------------------------------
 src/resource_provider/storage/provider.cpp | 35 +++++++++++++++++--------
 1 file changed, 24 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0449b5f0/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index 07645fc..a882080 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -1434,11 +1434,18 @@ void StorageLocalResourceProviderProcess::watchProfiles()
 Future<Nothing> StorageLocalResourceProviderProcess::updateProfiles(
     const hashset<string>& profiles)
 {
+  // Remove disappeared profiles.
+  foreach (const string& profile, profileInfos.keys()) {
+    if (!profiles.contains(profile)) {
+      profileInfos.erase(profile);
+    }
+  }
+
+  // Translate and add newly appeared profiles.
   vector<Future<Nothing>> futures;
   foreach (const string& profile, profiles) {
     // Since profiles are immutable after creation, we do not need to
     // translate any profile that is already in the mapping.
-    // TODO(chhsiao): Handle profile deactivation.
     if (profileInfos.contains(profile)) {
       continue;
     }
@@ -3087,12 +3094,15 @@ StorageLocalResourceProviderProcess::applyCreateVolumeOrBlock(
     case Resource::DiskInfo::Source::PATH:
     case Resource::DiskInfo::Source::MOUNT: {
       if (resource.disk().source().has_profile()) {
-        CHECK(profileInfos.contains(resource.disk().source().profile()));
+        // The profile exists since any operation with a stale profile must have
+        // been dropped for a mismatched resource version or a reconciliation.
+        CHECK(profileInfos.contains(resource.disk().source().profile()))
+          << "Profile '" << resource.disk().source().profile() << "' not found";
 
-        // TODO(chhsiao): Reject if the source has an inactive profile.
+        const DiskProfileAdaptor::ProfileInfo& profileInfo =
+          profileInfos.at(resource.disk().source().profile());
 
-        if (!profileInfos.at(resource.disk().source().profile())
-               .capability.has_mount()) {
+        if (!profileInfo.capability.has_mount()) {
           return Failure(
               "Profile '" + resource.disk().source().profile() +
               "' cannot be used for CREATE_VOLUME operation");
@@ -3104,7 +3114,7 @@ StorageLocalResourceProviderProcess::applyCreateVolumeOrBlock(
         created = createVolume(
             operationUuid.toString(),
             Bytes(resource.scalar().value() * Bytes::MEGABYTES),
-            profileInfos.at(resource.disk().source().profile()));
+            profileInfo);
       } else {
         const string& volumeId = resource.disk().source().id();
 
@@ -3130,12 +3140,15 @@ StorageLocalResourceProviderProcess::applyCreateVolumeOrBlock(
     }
     case Resource::DiskInfo::Source::BLOCK: {
       if (resource.disk().source().has_profile()) {
-        CHECK(profileInfos.contains(resource.disk().source().profile()));
+        // The profile exists since any operation with a stale profile must have
+        // been dropped for a mismatched resource version or a reconciliation.
+        CHECK(profileInfos.contains(resource.disk().source().profile()))
+          << "Profile '" << resource.disk().source().profile() << "' not found";
 
-        // TODO(chhsiao): Reject if the source has an inactive profile.
+        const DiskProfileAdaptor::ProfileInfo& profileInfo =
+          profileInfos.at(resource.disk().source().profile());
 
-        if (!profileInfos.at(resource.disk().source().profile())
-               .capability.has_block()) {
+        if (!profileInfo.capability.has_block()) {
           return Failure(
               "Profile '" + resource.disk().source().profile() +
               "' cannot be used for CREATE_BLOCK operation");
@@ -3147,7 +3160,7 @@ StorageLocalResourceProviderProcess::applyCreateVolumeOrBlock(
         created = createVolume(
             operationUuid.toString(),
             Bytes(resource.scalar().value() * Bytes::MEGABYTES),
-            profileInfos.at(resource.disk().source().profile()));
+            profileInfo);
       } else {
         const string& volumeId = resource.disk().source().id();