This repository has been archived by the owner on Oct 13, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cgit_atom_feed: Better exception handling
In case of HTTP error on requesting cgit atom feed, you will see an exception like this: ``` python38/root/usr/lib64/python3.8/urllib/request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 404: Not found ``` This is not good for troubleshooting. This PR changes to use `requests` and `tenacity` library to handle HTTP requests and retries. You will see the following exception in case of HTTP error: ``` Traceback (most recent call last): File "/Users/yux/Library/Python/3.10/lib/python/site-packages/tenacity/__init__.py", line 407, in __call__ result = fn(*args, **kwargs) File "/Volumes/Workspaces/projects/openshift/doozer/./doozerlib/metadata.py", line 319, in _make_request resp.raise_for_status() File "/Users/yux/Library/Python/3.10/lib/python/site-packages/requests/models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not found for url: https://pkgs.devel.redhat.com/cgit/rpms/openshift-clients/atom/?h=rhaos-4.8-rhel-7 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Volumes/Workspaces/projects/openshift/doozer/./doozerlib/runtime.py", line 101, in wrapper return func(*args, **kwargs) File "/Volumes/Workspaces/projects/openshift/doozer/./doozerlib/runtime.py", line 113, in wrapper return func(*args) File "/Volumes/Workspaces/projects/openshift/doozer/./doozerlib/runtime.py", line 1584, in <lambda> lambda meta, _: (meta, meta.needs_rebuild()), File "/Volumes/Workspaces/projects/openshift/doozer/./doozerlib/metadata.py", line 624, in needs_rebuild hint = self._target_needs_rebuild(el_target=target) File "/Volumes/Workspaces/projects/openshift/doozer/./doozerlib/metadata.py", line 663, in _target_needs_rebuild atom_entries = self.cgit_atom_feed(commit_hash=distgit_commitish, branch=self.branch()) File "/Volumes/Workspaces/projects/openshift/doozer/./doozerlib/metadata.py", line 322, in cgit_atom_feed content = retry( File "/Users/yux/Library/Python/3.10/lib/python/site-packages/tenacity/__init__.py", line 324, in wrapped_f return self(f, *args, **kw) File "/Users/yux/Library/Python/3.10/lib/python/site-packages/tenacity/__init__.py", line 404, in __call__ do = self.iter(retry_state=retry_state) File "/Users/yux/Library/Python/3.10/lib/python/site-packages/tenacity/__init__.py", line 361, in iter raise retry_exc from fut.exception() tenacity.RetryError: RetryError[<Future at 0x11160beb0 state=finished raised HTTPError>] ```
- Loading branch information