Skip to content

Commit

Permalink
Sync logic should not assume on schema1 by default existence.
Browse files Browse the repository at this point in the history
  • Loading branch information
ipanova committed Feb 14, 2018
1 parent 338e879 commit eba6378
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
14 changes: 10 additions & 4 deletions plugins/pulp_docker/plugins/importers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,16 @@ def _process_manifest_list(self, manifest_list, digest, available_blobs, tag):
manifest, digest, _ = manifests[0]
self._process_manifest(manifest, digest, available_blobs, tag=None)
if manifest_list.amd64_digest and manifest_list.amd64_schema_version == 2:
# we set the headers to False in order to get the conversion to schema1
manifests = self.parent.index_repository.get_manifest(tag, headers=False, tag=True)
manifest, digest, _ = manifests[0]
self._process_manifest(manifest, digest, available_blobs, tag=tag)
try:
# for compatibility with older clients, try to fetch schema1 in case it is available
# we set the headers to False in order to get the conversion to schema1
manifests = self.parent.index_repository.get_manifest(tag, headers=False, tag=True)
manifest, digest, _ = manifests[0]
self._process_manifest(manifest, digest, available_blobs, tag=tag)
except IOError as e:
if str(e) != 'Not Found':
raise
pass
# Remember this tag for the SaveTagsStep.
self.parent.save_tags_step.tagged_manifests.append((tag, manifest_list,
constants.MANIFEST_LIST_TYPE))
Expand Down
16 changes: 11 additions & 5 deletions plugins/pulp_docker/plugins/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,17 @@ def get_manifest(self, reference, headers=True, tag=True):
# if it is schema2 we need to ask schema1 for older clients.
if tag and response_headers.get(content_type_header) == constants.MEDIATYPE_MANIFEST_S2:
request_headers['Accept'] = constants.MEDIATYPE_MANIFEST_S1
response_headers, manifest = self._get_path(path, headers=request_headers)
digest = self._digest_check(response_headers, manifest)

# add manifest and digest
manifests.append((manifest, digest, response_headers.get(content_type_header)))
try:
# for compatibility with older clients, try to fetch schema1 in case it is available
response_headers, manifest = self._get_path(path, headers=request_headers)
digest = self._digest_check(response_headers, manifest)

# add manifest and digest
manifests.append((manifest, digest, response_headers.get(content_type_header)))
except IOError as e:
if str(e) != 'Not Found':
raise
pass

# returned list will be whether:
# [(S2, digest, content_type), (S1, digest, content_type)]
Expand Down

0 comments on commit eba6378

Please sign in to comment.