You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/12/11 21:18:19 UTC

[1/2] mesos git commit: Cleaned up docker metadata manager.

Repository: mesos
Updated Branches:
  refs/heads/master 8ff66b1c2 -> 2e3f614bd


Cleaned up docker metadata manager.

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


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

Branch: refs/heads/master
Commit: 1390d226dc1b012ffb1b49d22e1e504eb5723d85
Parents: 8ff66b1
Author: Gilbert Song <so...@gmail.com>
Authored: Fri Dec 11 12:17:43 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 11 12:17:43 2015 -0800

----------------------------------------------------------------------
 .../provisioner/docker/metadata_manager.cpp     | 41 ++++++++++++--------
 1 file changed, 24 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1390d226/src/slave/containerizer/mesos/provisioner/docker/metadata_manager.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/docker/metadata_manager.cpp b/src/slave/containerizer/mesos/provisioner/docker/metadata_manager.cpp
index f1005a7..bf85038 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/metadata_manager.cpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/metadata_manager.cpp
@@ -14,8 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "slave/containerizer/mesos/provisioner/docker/metadata_manager.hpp"
-
+#include <string>
 #include <vector>
 
 #include <glog/logging.h>
@@ -31,10 +30,11 @@
 
 #include "common/status_utils.hpp"
 
+#include "slave/state.hpp"
+
 #include "slave/containerizer/mesos/provisioner/docker/paths.hpp"
 #include "slave/containerizer/mesos/provisioner/docker/message.hpp"
-
-#include "slave/state.hpp"
+#include "slave/containerizer/mesos/provisioner/docker/metadata_manager.hpp"
 
 using namespace process;
 
@@ -58,7 +58,7 @@ public:
 
   Future<Image> put(
       const Image::Name& name,
-      const std::vector<std::string>& layerIds);
+      const vector<string>& layerIds);
 
   Future<Option<Image>> get(const Image::Name& name);
 
@@ -71,9 +71,9 @@ private:
   const Flags flags;
 
   // This is a lookup table for images that are stored in memory. It is keyed
-  // by the name of the Image.
+  // by image name.
   // For example, "ubuntu:14.04" -> ubuntu14:04 Image.
-  hashmap<std::string, Image> storedImages;
+  hashmap<string, Image> storedImages;
 };
 
 
@@ -88,20 +88,20 @@ Try<Owned<MetadataManager>> MetadataManager::create(const Flags& flags)
 MetadataManager::MetadataManager(Owned<MetadataManagerProcess> process)
   : process(process)
 {
-  process::spawn(CHECK_NOTNULL(process.get()));
+  spawn(CHECK_NOTNULL(process.get()));
 }
 
 
 MetadataManager::~MetadataManager()
 {
-  process::terminate(process.get());
-  process::wait(process.get());
+  terminate(process.get());
+  wait(process.get());
 }
 
 
 Future<Nothing> MetadataManager::recover()
 {
-  return process::dispatch(process.get(), &MetadataManagerProcess::recover);
+  return dispatch(process.get(), &MetadataManagerProcess::recover);
 }
 
 
@@ -189,13 +189,20 @@ Future<Nothing> MetadataManagerProcess::recover()
 
   Result<Images> images = ::protobuf::read<Images>(storedImagesPath);
   if (images.isError()) {
-    return Failure("Failed to read protobuf for Docker provisioner image: " +
+    return Failure("Failed to read images from '" + storedImagesPath + "' " +
                    images.error());
   }
 
-  foreach (const Image image, images.get().images()) {
+  if (images.isNone()) {
+    // This could happen if the slave died after opening the file for
+    // writing but before persisted on disk.
+    return Failure("Unexpected empty images file '" + storedImagesPath + "'");
+  }
+
+  foreach (const Image& image, images.get().images()) {
     vector<string> missingLayerIds;
-    foreach (const string layerId, image.layer_ids()) {
+
+    foreach (const string& layerId, image.layer_ids()) {
       const string rootfsPath =
         paths::getImageLayerRootfsPath(flags.docker_store_dir, layerId);
 
@@ -204,13 +211,13 @@ Future<Nothing> MetadataManagerProcess::recover()
       }
     }
 
+    const string imageName = stringify(image.name());
+
     if (!missingLayerIds.empty()) {
-      LOG(WARNING) << "Skipped loading image  '" << stringify(image.name())
-                   << "' due to missing layers: " << stringify(missingLayerIds);
+      LOG(WARNING) << "Skipped loading image '" << imageName << "'";
       continue;
     }
 
-    const string imageName = stringify(image.name());
     if (storedImages.contains(imageName)) {
       LOG(WARNING) << "Found duplicate image in recovery for image name '"
                    << imageName << "'";


[2/2] mesos git commit: Cleaned up unneccessary os exists check in linux filesystem isolator.

Posted by ji...@apache.org.
Cleaned up unneccessary os exists check in linux filesystem isolator.

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


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

Branch: refs/heads/master
Commit: 2e3f614bd0b10a28d7d46a31a5e292c119420e3d
Parents: 1390d22
Author: Gilbert Song <so...@gmail.com>
Authored: Fri Dec 11 12:17:57 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 11 12:17:58 2015 -0800

----------------------------------------------------------------------
 .../mesos/isolators/filesystem/linux.cpp        | 40 +++++++++-----------
 1 file changed, 17 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2e3f614b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
index 8442e9c..0df27d6 100644
--- a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
+++ b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
@@ -378,13 +378,11 @@ Future<Option<ContainerPrepareInfo>> LinuxFilesystemIsolatorProcess::__prepare(
     // Save the path 'sandbox' which will be used in 'cleanup()'.
     info->sandbox = sandbox;
 
-    if (!os::exists(sandbox)) {
-      Try<Nothing> mkdir = os::mkdir(sandbox);
-      if (mkdir.isError()) {
-        return Failure(
-            "Failed to create sandbox mount point at '" +
-            sandbox + "': " + mkdir.error());
-      }
+    Try<Nothing> mkdir = os::mkdir(sandbox);
+    if (mkdir.isError()) {
+      return Failure(
+          "Failed to create sandbox mount point at '" +
+          sandbox + "': " + mkdir.error());
     }
 
     LOG(INFO) << "Bind mounting work directory from '" << directory
@@ -530,16 +528,14 @@ Try<string> LinuxFilesystemIsolatorProcess::script(
       // work directory because a user can potentially use a container
       // path like '../../abc'.
 
-      if (!os::exists(source)) {
-        Try<Nothing> mkdir = os::mkdir(source);
-        if (mkdir.isError()) {
-          return Error(
-              "Failed to create the source of the mount at '" +
-              source + "': " + mkdir.error());
-        }
-
-        // TODO(idownes): Consider setting ownership and mode.
+      Try<Nothing> mkdir = os::mkdir(source);
+      if (mkdir.isError()) {
+        return Error(
+            "Failed to create the source of the mount at '" +
+            source + "': " + mkdir.error());
       }
+
+      // TODO(idownes): Consider setting ownership and mode.
     }
 
     // Determine the target of the mount.
@@ -575,13 +571,11 @@ Try<string> LinuxFilesystemIsolatorProcess::script(
       // sandbox because a user can potentially use a container path
       // like '../../abc'.
 
-      if (!os::exists(target)) {
-        Try<Nothing> mkdir = os::mkdir(target);
-        if (mkdir.isError()) {
-          return Error(
-              "Failed to create the target of the mount at '" +
-              target + "': " + mkdir.error());
-        }
+      Try<Nothing> mkdir = os::mkdir(target);
+      if (mkdir.isError()) {
+        return Error(
+            "Failed to create the target of the mount at '" +
+            target + "': " + mkdir.error());
       }
     }