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:36:58 UTC

[1/3] mesos git commit: Some consistency style fixes in Docker puller.

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


Some consistency style fixes in Docker puller.

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


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

Branch: refs/heads/master
Commit: b32ccac3e5d3eea59a85f61a013fde80231a44a0
Parents: fb0c2db
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Dec 10 17:57:37 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 11 12:19:28 2015 -0800

----------------------------------------------------------------------
 .../mesos/provisioner/docker/puller.cpp         | 30 +++++++++-----------
 1 file changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b32ccac3/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/docker/puller.cpp b/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
index 74498da..a8936e3 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
@@ -132,11 +132,9 @@ Future<pair<string, string>> untarLayer(
     const string& directory,
     const string& layerId)
 {
-  // We untar the layer from source into a directory, then move the
-  // layer into store. We do this instead of untarring directly to
-  // store to make sure we don't end up with partially untarred layer
-  // rootfs.
-
+  // We untar the layer from source into a directory, then move the layer
+  // into store. We do this instead of untarring directly to store to make
+  // sure we don't end up with partially untarred layer rootfs.
   const string localRootfsPath =
     paths::getImageArchiveLayerRootfsPath(directory, layerId);
 
@@ -149,29 +147,29 @@ Future<pair<string, string>> untarLayer(
 
     Try<Nothing> rmdir = os::rmdir(localRootfsPath);
     if (rmdir.isError()) {
-      return Failure("Failed to remove incomplete staged rootfs for layer '" +
-                     layerId + "': " + rmdir.error());
+      return Failure(
+          "Failed to remove incomplete staged rootfs for layer "
+          "'" + layerId + "': " + rmdir.error());
     }
   }
 
   Try<Nothing> mkdir = os::mkdir(localRootfsPath);
   if (mkdir.isError()) {
-    return Failure("Failed to create rootfs path '" + localRootfsPath +
-                   "': " + mkdir.error());
+    return Failure(
+        "Failed to create rootfs path '" + localRootfsPath + "'"
+        ": " + mkdir.error());
   }
 
-  // The tar file will be removed when the staging directory is
-  // removed.
-  return untar(
-      layerPath,
-      localRootfsPath)
+  // The tar file will be removed when the staging directory is removed.
+  return untar(layerPath, localRootfsPath)
     .then([directory, layerId]() -> Future<pair<string, string>> {
       const string rootfsPath =
         paths::getImageArchiveLayerRootfsPath(directory, layerId);
 
       if (!os::exists(rootfsPath)) {
-        return Failure("Failed to find the rootfs path after extracting layer"
-                       " '" + layerId + "'");
+        return Failure(
+            "Failed to find the rootfs path after extracting layer"
+            " '" + layerId + "'");
       }
 
       return pair<string, string>(layerId, rootfsPath);


[3/3] mesos git commit: Renamed a function parameter in Docker puller.

Posted by ji...@apache.org.
Renamed a function parameter in Docker puller.

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


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

Branch: refs/heads/master
Commit: c50f332eb8e22fec8d1dd54b57626f04e99003d9
Parents: b32ccac
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Dec 10 18:01:09 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 11 12:19:29 2015 -0800

----------------------------------------------------------------------
 src/slave/containerizer/mesos/provisioner/docker/puller.cpp | 4 ++--
 src/slave/containerizer/mesos/provisioner/docker/puller.hpp | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c50f332e/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/docker/puller.cpp b/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
index a8936e3..7e830bc 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
@@ -128,7 +128,7 @@ Future<Nothing> untar(const string& file, const string& directory)
 
 
 Future<pair<string, string>> untarLayer(
-    const string& layerPath,
+    const string& file,
     const string& directory,
     const string& layerId)
 {
@@ -161,7 +161,7 @@ Future<pair<string, string>> untarLayer(
   }
 
   // The tar file will be removed when the staging directory is removed.
-  return untar(layerPath, localRootfsPath)
+  return untar(file, localRootfsPath)
     .then([directory, layerId]() -> Future<pair<string, string>> {
       const string rootfsPath =
         paths::getImageArchiveLayerRootfsPath(directory, layerId);

http://git-wip-us.apache.org/repos/asf/mesos/blob/c50f332e/src/slave/containerizer/mesos/provisioner/docker/puller.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/docker/puller.hpp b/src/slave/containerizer/mesos/provisioner/docker/puller.hpp
index 31bcc86..d12b3d0 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/puller.hpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/puller.hpp
@@ -79,12 +79,12 @@ process::Future<Nothing> untar(
  *        |-- <layer_id>
  *            |-- rootfs
  *
- * @param layerPath path to the tar file holding the Docker layer.
+ * @param file path to the tar file holding the Docker layer.
  * @param directory staging directory.
  * @return layer Id mapping to the rootfs path of the layer.
  */
 process::Future<std::pair<std::string, std::string>> untarLayer(
-    const std::string& layerPath,
+    const std::string& file,
     const std::string& directory,
     const std::string& layerId);
 


[2/3] mesos git commit: Cleaned up the untar method in docker puller.

Posted by ji...@apache.org.
Cleaned up the untar method in docker puller.

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


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

Branch: refs/heads/master
Commit: fb0c2dbb886d1d25ba4c6c3a8624d743ab965b0c
Parents: 2e3f614
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Dec 10 17:32:51 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 11 12:19:28 2015 -0800

----------------------------------------------------------------------
 .../mesos/provisioner/docker/puller.cpp         | 82 ++++++++------------
 1 file changed, 34 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/fb0c2dbb/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/docker/puller.cpp b/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
index 4aa4a9c..74498da 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/puller.cpp
@@ -14,29 +14,33 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "slave/containerizer/mesos/provisioner/docker/puller.hpp"
-
+#include <string>
+#include <tuple>
+#include <utility>
 #include <vector>
 
 #include <stout/os.hpp>
 
+#include <process/check.hpp>
+#include <process/collect.hpp>
 #include <process/io.hpp>
 #include <process/subprocess.hpp>
 
 #include "common/status_utils.hpp"
 
-#include "slave/containerizer/mesos/provisioner/docker/paths.hpp"
 #include "slave/containerizer/mesos/provisioner/docker/local_puller.hpp"
+#include "slave/containerizer/mesos/provisioner/docker/paths.hpp"
+#include "slave/containerizer/mesos/provisioner/docker/puller.hpp"
 #include "slave/containerizer/mesos/provisioner/docker/registry_puller.hpp"
 
 using std::pair;
 using std::string;
+using std::tuple;
 using std::vector;
 
 using process::Failure;
 using process::Future;
 using process::Owned;
-using process::Promise;
 using process::Subprocess;
 
 namespace mesos {
@@ -84,60 +88,42 @@ Future<Nothing> untar(const string& file, const string& directory)
       Subprocess::PIPE());
 
   if (s.isError()) {
-    return Failure(
-        "Failed to create untar subprocess for file '" +
-        file + "': " + s.error());
+    return Failure("Failed to execute the subprocess: " + s.error());
   }
 
-  Owned<Promise<Nothing>> promise(new Promise<Nothing>());
-  s.get().status()
-    .onAny([s, file, promise](const Future<Option<int>>& future) {
-      if (!future.isReady()) {
-        promise->fail(
-            "Failed to launch untar subprocess for file '" + file
-            + "': " +
-            (future.isFailed() ? future.failure() : "future discarded"));
-
-        return;
+  return await(
+      s.get().status(),
+      process::io::read(s.get().err().get()))
+    .then([](const tuple<
+        Future<Option<int>>,
+        Future<string>>& t) -> Future<Nothing> {
+      Future<Option<int>> status = std::get<0>(t);
+      if (!status.isReady()) {
+        return Failure(
+          "Failed to get the exit status of the subprocess: " +
+          (status.isFailed() ? status.failure() : "discarded"));
       }
 
-      if (future.get().isNone()) {
-        promise->fail(
-            "Failed to get status for untar subprocess for file '" +
-            file + "'");
+      Future<string> error = std::get<1>(t);
+      if (!error.isReady()) {
+        return Failure(
+          "Failed to read stderr from the subprocess: " +
+          (error.isFailed() ? error.failure() : "discarded"));
+      }
 
-        return;
+      if (status->isNone()) {
+        return Failure("Failed to reap the subprocess");
       }
 
-      int status = future.get().get();
-
-      if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
-        const string errorMessage =
-          "Failed to run ntar process for file '" + file + "' (exit code: " +
-          WSTRINGIFY(status) + ")";
-
-        // Read stderr from the process(if any) to add to the failure report.
-        process::io::read(s.get().err().get())
-          .onAny([file, promise, errorMessage](const Future<string>& future) {
-            if (!future.isReady()) {
-              LOG(WARNING) << "Failed to read stderr from untar process for"
-                           << "file: '" << file << "': "
-                           << (future.isFailed() ? future.failure()
-                              : "future discarded");
-
-              promise->fail(errorMessage);
-            } else {
-              promise->fail(errorMessage + ": " + future.get());
-            }
-          });
-
-        return;
+      if (status->get() != 0) {
+        return Failure(
+            "Unexpected result from the subprocess: " +
+            WSTRINGIFY(status->get()) +
+            ", stderr='" + error.get() + "'");
       }
 
-      promise->set(Nothing());
+      return Nothing();
     });
-
-    return promise->future();
 }