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 2017/02/05 01:43:53 UTC

[2/2] mesos git commit: Added skipping already stored layers to local Docker puller.

Added skipping already stored layers to local Docker puller.

If a layer is already in the store, there's no need to extract it.
`RegistryPuller` already does this and `Store` is ready for such
puller behaviour.

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


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

Branch: refs/heads/master
Commit: 6043624aba9b3315eccf2ab19ddaf3a30ac9952c
Parents: aefae58
Author: Ilya Pronin <ip...@twopensource.com>
Authored: Sat Feb 4 17:14:18 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Sat Feb 4 17:31:55 2017 -0800

----------------------------------------------------------------------
 .../mesos/provisioner/docker/local_puller.cpp        | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6043624a/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp b/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
index ee391af..5bc68d2 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
@@ -51,8 +51,9 @@ namespace docker {
 class LocalPullerProcess : public Process<LocalPullerProcess>
 {
 public:
-  LocalPullerProcess(const string& _archivesDir)
+  LocalPullerProcess(const string& _storeDir, const string& _archivesDir)
     : ProcessBase(process::ID::generate("docker-provisioner-local-puller")),
+      storeDir(_storeDir),
       archivesDir(_archivesDir) {}
 
   ~LocalPullerProcess() {}
@@ -82,6 +83,7 @@ private:
       const string& layerId,
       const string& backend);
 
+  const string storeDir;
   const string archivesDir;
 };
 
@@ -97,7 +99,7 @@ Try<Owned<Puller>> LocalPuller::create(const Flags& flags)
           << flags.docker_registry << "'";
 
   Owned<LocalPullerProcess> process(
-      new LocalPullerProcess(flags.docker_registry));
+      new LocalPullerProcess(flags.docker_store_dir, flags.docker_registry));
 
   return Owned<Puller>(new LocalPuller(process));
 }
@@ -282,6 +284,15 @@ Future<Nothing> LocalPullerProcess::extractLayers(
 {
   list<Future<Nothing>> futures;
   foreach (const string& layerId, layerIds) {
+    // Check if the layer is already in the store. If yes, skip the
+    // unnecessary extracting.
+    if (os::exists(paths::getImageLayerRootfsPath(
+            storeDir,
+            layerId,
+            backend))) {
+      continue;
+    }
+
     futures.push_back(extractLayer(directory, layerId, backend));
   }