debian: Do not raise when a component cannot be found for a suite

All debian suites do not necessarily have the same set of components.

So prefer to log that a component is missing for a suite instead of
raising an excption that will stop the listing.
This commit is contained in:
Antoine Lambert 2021-12-03 14:29:08 +01:00
parent 4ff3e44643
commit 605b13a676
2 changed files with 14 additions and 12 deletions

View file

@ -134,19 +134,17 @@ class DebianLister(Lister[DebianListerState, DebianPageType]):
response = requests.get(url, stream=True)
logging.debug("Fetched URL: %s, status code: %s", url, response.status_code)
if response.status_code == 200:
decompressor = decompressors.get(compression)
if decompressor:
data = decompressor(response.raw).readlines()
else:
data = response.raw.readlines()
break
else:
raise Exception(
"Could not retrieve sources index for %s/%s", suite, component
)
data = ""
logger.debug("Could not retrieve sources index for %s/%s", suite, component)
decompressor = decompressors.get(compression)
if decompressor:
data = decompressor(response.raw)
else:
data = response.raw
return Sources.iter_paragraphs(data.readlines())
return Sources.iter_paragraphs(data)
def get_pages(self) -> Iterator[DebianPageType]:
"""Return an iterator on parsed debian package Sources files, one per combination

View file

@ -36,7 +36,7 @@ from swh.scheduler.interface import SchedulerInterface
_mirror_url = "http://deb.debian.org/debian"
_suites = ["stretch", "buster", "bullseye"]
_components = ["main"]
_components = ["main", "foo"]
SourcesText = str
@ -59,6 +59,7 @@ def _init_test(
debian_sources: Dict[Suite, SourcesText],
requests_mock,
) -> Tuple[DebianLister, DebianSuitePkgSrcInfo]:
lister = DebianLister(
scheduler=swh_scheduler,
mirror_url=_mirror_url,
@ -79,6 +80,9 @@ def _init_test(
else:
requests_mock.get(idx_url, text=sources)
for idx_url, _ in lister.debian_index_urls(suite, _components[1]):
requests_mock.get(idx_url, status_code=404)
return lister, suite_pkg_info
@ -198,7 +202,7 @@ def test_lister_debian_updated_packages(
lister_previous_state=lister_previous_state,
)
assert stats.pages == len(sources)
assert stats.pages == len(sources) * len(_components)
assert stats.origins == len(origin_urls)
lister_previous_state = lister.state.package_versions