nixguix: Deal with impossible communication with server

When that arises, we skip the origins.

Related to T3781
This commit is contained in:
Antoine R. Dumont (@ardumont) 2022-10-04 14:07:42 +02:00
parent a94b75f366
commit 06b11dd5f6
No known key found for this signature in database
GPG key ID: 52E2E9840D10C3B8
3 changed files with 12 additions and 1 deletions

View file

@ -25,6 +25,7 @@ from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
from urllib.parse import urlparse
import requests
from requests.exceptions import InvalidSchema, SSLError
from swh.core.github.utils import GitHubSession
from swh.core.tarball import MIMETYPE_TO_ARCHIVE_FORMAT
@ -155,7 +156,7 @@ def is_tarball(urls: List[str], request: Optional[Any] = None) -> Tuple[bool, st
try:
response = request.head(url)
except requests.exceptions.InvalidSchema:
except (InvalidSchema, SSLError):
raise ArtifactNatureUndetected(
f"Cannot determine artifact type from url <{url}>"
)

View file

@ -24,6 +24,11 @@
"type": "url",
"urls": [ "unknown://example.org/wrong-scheme-so-skipped.txt" ],
"integrity": "sha256-wAEswtkl3ulAw3zq4perrGS6Wlww5XXnQYsEAoYT9fI="
},
{
"type": "url",
"urls": [ "https://code.9front.org/hg/plan9front" ],
"integrity": "sha256-wAEswtkl3ulAw3zq4perrGS6Wlww5XXnQYsEAoYT9fI="
}
],
"version":"1",

View file

@ -235,6 +235,11 @@ def test_lister_nixguix_mostly_noop(datadir, swh_scheduler, requests_mock):
"ftp://ftp.ourproject.org/file-with-no-extension",
exc=requests.exceptions.InvalidSchema,
)
# Cannot communicate with an expired cert so skip
requests_mock.head(
"https://code.9front.org/hg/plan9front",
exc=requests.exceptions.SSLError,
)
listed_result = lister.run()
# only the origin upstream is listed, every other entries are unsupported or incomplete