mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-10-31 06:26:19 -02:30
Skip component releases published without binary artifacts (#13381)
* Skip component releases published without binary artifacts Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com> * Don't use intermediate variable Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com> * Fail update-hashes when a component only returns 404s Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com> --------- Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com>
This commit is contained in:
@@ -250,13 +250,30 @@ def download_hash(downloads: {str: {str: Any}}) -> None:
|
|||||||
).hexdigest()
|
).hexdigest()
|
||||||
return hash_file.content.decode().split()[0]
|
return hash_file.content.decode().split()[0]
|
||||||
|
|
||||||
|
skipped_404 = set()
|
||||||
|
fetched = set()
|
||||||
for component, versions in chain(new_versions.items(), hash_set_to_0.items()):
|
for component, versions in chain(new_versions.items(), hash_set_to_0.items()):
|
||||||
c = component + "_checksums"
|
c = component + "_checksums"
|
||||||
for arch in components_supported_arch[component]:
|
for arch in components_supported_arch[component]:
|
||||||
for version in versions:
|
for version in versions:
|
||||||
data[c][arch][
|
# Some releases are published without binary artifacts
|
||||||
str(version)
|
try:
|
||||||
] = f"{downloads[component].get('hashtype', 'sha256')}:{get_hash(component, version, arch)}"
|
data[c][arch][
|
||||||
|
str(version)
|
||||||
|
] = f"{downloads[component].get('hashtype', 'sha256')}:{get_hash(component, version, arch)}"
|
||||||
|
fetched.add(component)
|
||||||
|
except requests.exceptions.HTTPError as e:
|
||||||
|
if e.response is not None and e.response.status_code == 404:
|
||||||
|
logger.warning(
|
||||||
|
"Skipping %s %s (%s): release asset not found (404) at %s",
|
||||||
|
component,
|
||||||
|
version,
|
||||||
|
arch,
|
||||||
|
e.response.url,
|
||||||
|
)
|
||||||
|
skipped_404.add(component)
|
||||||
|
continue
|
||||||
|
raise
|
||||||
|
|
||||||
data[c] = {
|
data[c] = {
|
||||||
arch: {
|
arch: {
|
||||||
@@ -268,6 +285,15 @@ def download_hash(downloads: {str: {str: Any}}) -> None:
|
|||||||
for arch, versions in data[c].items()
|
for arch, versions in data[c].items()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Only 404s for a component means its release layout probably changed
|
||||||
|
all_missing = sorted(skipped_404 - fetched)
|
||||||
|
if all_missing:
|
||||||
|
logger.error(
|
||||||
|
"All hash fetches returned 404 for: %s",
|
||||||
|
", ".join(all_missing),
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
with open(checksums_file, "w") as checksums_yml:
|
with open(checksums_file, "w") as checksums_yml:
|
||||||
yaml.dump(data, checksums_yml)
|
yaml.dump(data, checksums_yml)
|
||||||
logger.info("Updated %s", checksums_file)
|
logger.info("Updated %s", checksums_file)
|
||||||
|
|||||||
Reference in New Issue
Block a user