> On Aug. 16, 2018, 10:34 p.m., Jie Yu wrote:
> > src/uri/fetchers/docker.cpp
> > Lines 682 (patched)
> > <https://reviews.apache.org/r/67931/diff/6/?file=2071252#file2071252line683>
> >
> >     I'd rather treating fetching v2 schema 2 manifest as an impl. details 
> > of supporting fetching foreign urls on windows. Because I don't want the 
> > reader to be confused that we support v2 schema 2 properly on windows.
> >     
> >     So the concrete suggestion here is to always fetch v2 schema 1 manifest 
> > first here (no change to this line) as you need the information in either 
> > case. And then, on windows, additionally fetch the v2 scheme 2 manifest (in 
> > `__fetch`).
> 
> Jie Yu wrote:
>     Correction, you should fetch v2_2 manifest in fetchBlob, not in `__fetch`
> 
> Liangyu Zhao wrote:
>     The manifest uri cannot be derived from blob uri unfortunately. The query 
> part of the manifest uri or digest/tag of the image reference is lost when 
> generating the blob uri, because blob is fetched based on the digest of the 
> blob. This makes `fetchblob` unable to fetch v2_2 manifest.
>     
>     A solution to this, I suggest, is to fetch v2_2 manifest along with v2_1 
> manifest, and save both on disk during fetching manifest, so `fetchBlob` can 
> read the v2_2 manifest from disk without trying to derive the manifest uri.

That sounds ok, this will be my suggestion to make that logic Windows only.

In `__fetch`, right after the schema1 manifest is saved, do the following:
```
Future<Nothing> DockerFetcherPluginProcess::__fetch(...)
{
  Try<spec::v2::ImageManifest> schema1Manifest =
    saveSchema1Manifest(directory, response);
    
  if (schema1Manifest.isError()) {
    return Failure(...);
  }
  
#ifdef WINDOWS
  http::Headers manifestHeaders = {
    {"Accept", "application/vnd.docker.distribution.manifest.v2+json"}
  };
  
  return curl(manifestUri, manifestHeaders + authHeaders, stallTimeout)
    .then(defer(self(),
                &Self::saveSchema2Manifest,
                directory,
                lambda::_1))
    .then(defer(self(),
                &Self::fetchBlobs,
                schema1Manifest.get(),
                lambda::_1)); // `lambda::_1` is schema2 manifest protobuf.
#else
  return fetchBlobs(schema1Manifest.get(), None());
#endif // WINDOWS
}

Future<Nothing> DockerFetcherPluginProcess::fetchBlobs(
    const spec::v2::ImageManifest& schema1Manifest,
    const Option<spec::v2_2::ImageManifest& schema2Manifest)
{
  ...
}

Try<spec::v2::ImageManifest> saveSchema1Manifest(...) {}
Try<spec::v2_2::ImageManifest> saveSchema2Manifest(...) {}
```


- Jie


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/67931/#review207427
-----------------------------------------------------------


On Aug. 6, 2018, 6:45 p.m., Liangyu Zhao wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/67931/
> -----------------------------------------------------------
> 
> (Updated Aug. 6, 2018, 6:45 p.m.)
> 
> 
> Review request for mesos, Akash Gupta, Andrew Schwartzmeyer, Gilbert Song, 
> Jie Yu, Joseph Wu, and Qian Zhang.
> 
> 
> Bugs: MESOS-9159
>     https://issues.apache.org/jira/browse/MESOS-9159
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Added support for parsing schema 2 and fetching blob with multiple
> URLs as specified in schema 2. Also updated `curl` version to 7.61.0
> because of a bug encountered in version 7.57.0.
> 
> 
> Diffs
> -----
> 
>   3rdparty/CMakeLists.txt 629b1968775da4d128b8d36c77d75efa303b0b7c 
>   3rdparty/cmake/Versions.cmake c65d7b3d2d48ce9d0b4777aeb12fdf5b605803ac 
>   include/mesos/docker/spec.hpp 2879414dc42ffe633ac74b51e1bb116698c41162 
>   include/mesos/docker/v2_2.hpp PRE-CREATION 
>   include/mesos/docker/v2_2.proto PRE-CREATION 
>   include/mesos/uri/fetcher.hpp 760d6b33234d8efdc533c0c6f05e83a5c7d1f56b 
>   src/CMakeLists.txt a80b011bbd5c418ae66eb8dd7697d070168462bb 
>   src/Makefile.am cf0cf22b3f582d3d4427f13288af3845aef45263 
>   src/docker/spec.cpp 96fbf1f9cf1c2c4b2383607a97990f3a9156e6d9 
>   src/slave/containerizer/mesos/containerizer.cpp 
> 98129d006cda9b65804b518619b6addc8990410a 
>   src/slave/containerizer/mesos/provisioner/docker/registry_puller.cpp 
> a5683e3fe15dd35596122fcc0c580ae9d3adf7f2 
>   src/uri/fetcher.hpp fbf64c6767dea3aa0798f68db8322ce47cd8ad36 
>   src/uri/fetcher.cpp 489c7ce0198ee6803dcc8eb9710b292fa743a0e8 
>   src/uri/fetchers/docker.hpp 7a6193dd75dc10846f52cb039f6a162cc8805c16 
>   src/uri/fetchers/docker.cpp 55ca118660872a933a2dc186723bec6a39ee80f7 
> 
> 
> Diff: https://reviews.apache.org/r/67931/diff/6/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Liangyu Zhao
> 
>

Reply via email to