Skip to content

Commit

Permalink
Fixed 404 during sync from registry.redhat.io
Browse files Browse the repository at this point in the history
Whenever a token expires a new token is requested.
The 404 sync problem was triggered because the accept headers that
were passed originally with the expired token were not passed to the
re-newed token. As a result the registry was redirecting to the wrong
schema version (schema1, which is unsupported since july 2022
https://access.redhat.com/articles/6138332) because of absense of the
accept headers.

closes pulp#974
  • Loading branch information
ipanova committed Aug 17, 2022
1 parent 770761c commit 0a0e005
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/974.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed 404 during sync from registry.redhat.io
7 changes: 5 additions & 2 deletions pulp_container/app/downloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ async def _run(self, handle_401=True, extra_data=None):
if extra_data is not None:
headers = extra_data.get("headers", headers)
repo_name = extra_data.get("repo_name", None)
if extra_data is None:
import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=12345, stdoutToServer=True, stderrToServer=True)
this_token = self.registry_auth["bearer"]
basic_auth = self.registry_auth["basic"]
auth_headers = self.auth_header(this_token, basic_auth)
Expand Down Expand Up @@ -78,12 +81,12 @@ async def _run(self, handle_401=True, extra_data=None):

self.registry_auth["bearer"] = None
await self.update_token(response_auth_header, this_token, repo_name)
return await self._run(handle_401=False)
return await self._run(handle_401=False, extra_data=extra_data)
elif "Basic" in response_auth_header:
if self.remote.username:
basic = aiohttp.BasicAuth(self.remote.username, self.remote.password)
self.registry_auth["basic"] = basic.encode()
return await self._run(handle_401=False)
return await self._run(handle_401=False, extra_data=extra_data)
else:
raise
to_return = await self._handle_response(response)
Expand Down

0 comments on commit 0a0e005

Please sign in to comment.