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 2016/11/05 08:40:13 UTC

[6/6] mesos git commit: Removed `ProvisionerProcess::__provision()`.

Removed `ProvisionerProcess::__provision()`.

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


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

Branch: refs/heads/master
Commit: 3b6af1d8d336edeefb14f5a86e028c3b099371f5
Parents: 0f4c15a
Author: Qian Zhang <zh...@cn.ibm.com>
Authored: Sun Oct 23 09:03:14 2016 +0800
Committer: Qian Zhang <zh...@gmail.com>
Committed: Sat Nov 5 16:18:30 2016 +0800

----------------------------------------------------------------------
 .../mesos/provisioner/provisioner.cpp           | 118 +------------------
 .../mesos/provisioner/provisioner.hpp           |   5 -
 2 files changed, 2 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3b6af1d8/src/slave/containerizer/mesos/provisioner/provisioner.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/provisioner.cpp b/src/slave/containerizer/mesos/provisioner/provisioner.cpp
index de2c121..db2d267 100644
--- a/src/slave/containerizer/mesos/provisioner/provisioner.cpp
+++ b/src/slave/containerizer/mesos/provisioner/provisioner.cpp
@@ -311,124 +311,10 @@ Future<ProvisionInfo> ProvisionerProcess::_provision(
       imageInfo.layers,
       rootfs,
       backendDir)
-    .then(defer(self(), &Self::__provision, rootfs, image, imageInfo));
-}
-
-
-// This function is currently docker image specific. Depending
-// on docker v1 spec, a docker image may include filesystem
-// changeset, which may need to delete directories or files.
-// The file/directory to be deleted will be labeled by creating
-// a 'whiteout' file, which is at the same location and with the
-// basename of the deleted file or directory prefixed with '.wh.'.
-// For the directory which has an opaque whiteout file '.wh..wh..opq'
-// under it, we need to delete all the files/directories under it.
-// Please see:
-// https://github.com/docker/docker/blob/master/image/spec/v1.md
-// https://github.com/docker/docker/blob/master/pkg/archive/whiteouts.go
-// And OCI image spec also has the concepts 'whiteout' and 'opaque whiteout':
-// https://github.com/opencontainers/image-spec/blob/master/layer.md#whiteouts
-Future<ProvisionInfo> ProvisionerProcess::__provision(
-    const string& rootfs,
-    const Image& image,
-    const ImageInfo& imageInfo)
-{
-#ifdef __WINDOWS__
-  return ProvisionInfo{
-      rootfs, imageInfo.dockerManifest, imageInfo.appcManifest};
-#else
-  // Skip single-layered images since no 'whiteout' files needs
-  // to be handled, and this excludes any image using the bind
-  // backend.
-  if (imageInfo.layers.size() == 1 || image.type() != Image::DOCKER) {
+    .then([=]() -> Future<ProvisionInfo> {
       return ProvisionInfo{
           rootfs, imageInfo.dockerManifest, imageInfo.appcManifest};
-  }
-
-  // TODO(hausdorff): The FTS API is not available on some platforms, such as
-  // Windows. We will need to either (1) prove that this is not necessary for
-  // Windows Containers, which use much of the Docker spec themselves, or (2)
-  // make this code compatible with Windows, as we did with other code that
-  // depended on FTS, such as `os::rmdir`. See MESOS-5610.
-  char* _rootfs[] = {const_cast<char*>(rootfs.c_str()), nullptr};
-
-  FTS* tree = ::fts_open(_rootfs, FTS_NOCHDIR | FTS_PHYSICAL, nullptr);
-  if (tree == nullptr) {
-    return Failure("Failed to open '" + rootfs + "': " + os::strerror(errno));
-  }
-
-  vector<string> whiteout;
-  vector<string> whiteoutOpaque;
-
-  for (FTSENT *node = ::fts_read(tree);
-       node != nullptr; node = ::fts_read(tree)) {
-    if (node->fts_info == FTS_F &&
-        strings::startsWith(node->fts_name, string(spec::WHITEOUT_PREFIX))) {
-      Path path = Path(node->fts_path);
-      if (node->fts_name == string(spec::WHITEOUT_OPAQUE_PREFIX)) {
-        whiteoutOpaque.push_back(path.dirname());
-      } else {
-        whiteout.push_back(path::join(
-            path.dirname(),
-            path.basename().substr(strlen(spec::WHITEOUT_PREFIX))));
-      }
-
-      Try<Nothing> rm = os::rm(path.string());
-      if (rm.isError()) {
-        ::fts_close(tree);
-        return Failure(
-            "Failed to remove whiteout file '" +
-            path.string() + "': " + rm.error());
-      }
-    }
-  }
-
-  if (errno != 0) {
-    Error error = ErrnoError();
-    ::fts_close(tree);
-    return Failure(error);
-  }
-
-  if (::fts_close(tree) != 0) {
-    return Failure(
-        "Failed to stop traversing file system: " + os::strerror(errno));
-  }
-
-  foreach (const string& path, whiteoutOpaque) {
-    Try<Nothing> rmdir = os::rmdir(path, true, false);
-    if (rmdir.isError()) {
-      return Failure(
-          "Failed to remove the entries under the directory labeled as"
-          " opaque whiteout '" + path + "': " + rmdir.error());
-    }
-  }
-
-  foreach (const string& path, whiteout) {
-    // The file/directory labeled as whiteout may have already been
-    // removed with the code above due to its parent directory labeled
-    // as opaque whiteout, so here we need to check if it still exists
-    // before trying to remove it.
-    if (os::exists(path)) {
-      if (os::stat::isdir(path)) {
-        Try<Nothing> rmdir = os::rmdir(path);
-        if (rmdir.isError()) {
-          return Failure(
-              "Failed to remove the directory labeled as whiteout '" +
-              path + "': " + rmdir.error());
-        }
-      } else {
-        Try<Nothing> rm = os::rm(path);
-        if (rm.isError()) {
-          return Failure(
-              "Failed to remove the file labeled as whiteout '" +
-              path + "': " + rm.error());
-        }
-      }
-    }
-  }
-
-  return ProvisionInfo{rootfs, imageInfo.dockerManifest, None()};
-#endif // __WINDOWS__
+    });
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/3b6af1d8/src/slave/containerizer/mesos/provisioner/provisioner.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/provisioner.hpp b/src/slave/containerizer/mesos/provisioner/provisioner.hpp
index c5481c5..0a48617 100644
--- a/src/slave/containerizer/mesos/provisioner/provisioner.hpp
+++ b/src/slave/containerizer/mesos/provisioner/provisioner.hpp
@@ -134,11 +134,6 @@ private:
       const Image& image,
       const ImageInfo& imageInfo);
 
-  process::Future<ProvisionInfo> __provision(
-      const std::string& rootfs,
-      const Image& image,
-      const ImageInfo& imageInfo);
-
   process::Future<bool> _destroy(const ContainerID& containerId);
 
   const Flags flags;