You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/04/25 23:15:33 UTC

[17/24] mesos git commit: Fix the local Docker puller for private registries.

Fix the local Docker puller for private registries.

If you use the unified containerizer and the local docker puller with a
Docker image from a private registry, the local puller fails to find any
layers in the image's repository manifest. This happens because the top
layer repository is qualified by the private registry name.

The fix is to also try the fully-qualified repository name if we have a
registry name.

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


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

Branch: refs/heads/0.28.x
Commit: 885e00a28b157862d5e0c308d099c896781acf81
Parents: 447f1e8
Author: James Peach <jp...@apache.org>
Authored: Thu Mar 31 09:34:09 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Apr 5 15:17:52 2016 -0700

----------------------------------------------------------------------
 .../mesos/provisioner/docker/local_puller.cpp   | 32 ++++++++++++--------
 1 file changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/885e00a2/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 74254c1..4be26fa 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
@@ -169,8 +169,18 @@ Future<vector<string>> LocalPullerProcess::_pull(
     return Failure("Failed to parse 'repositories': " + repositories.error());
   }
 
+  // We are looking for the topmost layer, so we know that is it OK to
+  // use at() rather than find() on the JSON object.
   Result<JSON::Object> repository =
-    repositories->find<JSON::Object>(reference.repository());
+    repositories->at<JSON::Object>(reference.repository());
+
+  // If we didn't find the bare repository name, try
+  // with the registry-qualified name. This would look like
+  // "registry.example.com/image".
+  if (repository.isNone() && reference.has_registry()) {
+    repository = repositories->at<JSON::Object>(
+        path::join(reference.registry(), reference.repository()));
+  }
 
   if (repository.isError()) {
     return Failure(
@@ -187,22 +197,20 @@ Future<vector<string>> LocalPullerProcess::_pull(
     : "latest";
 
   // NOTE: We don't use JSON find here since a tag might contain '.'.
-  if (repository->values.count(tag) == 0) {
-    return Failure("Tag '" + tag + "' is not found");
-  }
+  Result<JSON::String> layerId = repository->at<JSON::String>(tag);
 
-  JSON::Value _layerId = repository->values.at(tag);
-  if (!_layerId.is<JSON::String>()) {
-    return Failure("Layer id is not a string");
+  if (layerId.isError()) {
+    return Failure(
+        "Failed to access layer id '" + tag + "': " + layerId.error());
+  } else if (layerId.isNone()) {
+    return Failure("Layer id '" + tag + "' is not found");
   }
 
-  string layerId = _layerId.as<JSON::String>().value;
-
   // Do a traverse to find all parent image layer ids. Here, we assume
   // that all the parent layers are part of the archive tar, thus are
   // already extracted under 'directory'.
-  vector<string> layerIds = { layerId };
-  Result<string> parentLayerId = getParentLayerId(directory, layerId);
+  vector<string> layerIds = { layerId->value };
+  Result<string> parentLayerId = getParentLayerId(directory, layerId->value);
   while (parentLayerId.isSome()) {
     // NOTE: We put parent layer ids in front because that's what the
     // provisioner backends assume.
@@ -212,7 +220,7 @@ Future<vector<string>> LocalPullerProcess::_pull(
 
   if (parentLayerId.isError()) {
     return Failure(
-        "Failed to find parent layer id for layer '" + layerId +
+        "Failed to find parent layer id for layer '" + layerId->value +
         "': " + parentLayerId.error());
   }