Repository: mesos
Updated Branches:
  refs/heads/master 2b658c42c -> 2cff22113


Fetching docker image manifests with 'Accept' header.

Added 'Accept: application/vnd.docker.distribution.manifest.v1+json'
to the headers of HTTP requests for fetching manifests from any Docker
registry. Some registry services (e.g., Amazon ECR) check the 'Accept'
field strictly and reject the requests if it is not specified.

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


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

Branch: refs/heads/master
Commit: 2cff221131b4d1a4c7fde99be782478cfe76ea2f
Parents: 2b658c4
Author: Chun-Hung Hsiao <[email protected]>
Authored: Fri May 5 14:55:33 2017 -0700
Committer: Jie Yu <[email protected]>
Committed: Fri May 5 14:55:33 2017 -0700

----------------------------------------------------------------------
 src/uri/fetchers/docker.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2cff2211/src/uri/fetchers/docker.cpp
----------------------------------------------------------------------
diff --git a/src/uri/fetchers/docker.cpp b/src/uri/fetchers/docker.cpp
index 44169bf..dbfc1b2 100644
--- a/src/uri/fetchers/docker.cpp
+++ b/src/uri/fetchers/docker.cpp
@@ -329,6 +329,7 @@ private:
       const URI& uri,
       const string& directory,
       const URI& manifestUri,
+      const http::Headers& manifestHeaders,
       const http::Response& response);
 
   Future<Nothing> __fetch(
@@ -469,12 +470,22 @@ Future<Nothing> DockerFetcherPluginProcess::fetch(
 
   URI manifestUri = getManifestUri(uri);
 
-  return curl(manifestUri)
+  // Request a Version 2 Schema 1 manifest. The MIME type of a Schema 1
+  // manifest is described in the following link:
+  // https://docs.docker.com/registry/spec/manifest-v2-1/
+  // Note: The 'Accept' header is required for Amazon ECR. See:
+  // https://forums.aws.amazon.com/message.jspa?messageID=780440
+  http::Headers manifestHeaders = {
+    {"Accept", "application/vnd.docker.distribution.manifest.v1+json"}
+  };
+
+  return curl(manifestUri, manifestHeaders)
     .then(defer(self(),
                 &Self::_fetch,
                 uri,
                 directory,
                 manifestUri,
+                manifestHeaders,
                 lambda::_1));
 }
 
@@ -483,13 +494,14 @@ Future<Nothing> DockerFetcherPluginProcess::_fetch(
     const URI& uri,
     const string& directory,
     const URI& manifestUri,
+    const http::Headers& manifestHeaders,
     const http::Response& response)
 {
   if (response.code == http::Status::UNAUTHORIZED) {
     return getAuthHeader(manifestUri, response)
       .then(defer(self(), [=](
           const http::Headers& authHeaders) -> Future<Nothing> {
-        return curl(manifestUri, authHeaders)
+        return curl(manifestUri, manifestHeaders + authHeaders)
           .then(defer(self(),
                       &Self::__fetch,
                       uri,

Reply via email to