From 3a17b0fb909e6dfc47aea0bac420592b49c42af0 Mon Sep 17 00:00:00 2001 From: soksanichenko Date: Fri, 1 Jul 2022 13:45:23 +0300 Subject: [PATCH] Issues #562,#561,#560: - No source of entropy in _get_nearest_mirrors_by_network_data() - _get_nearest_mirrors_by_network_data() fails to exclude near-by private mirrors for extra options. - Exclude the private mirrors from the mirrors list in the case of fallback behavior - The Azure mirrors have allowed list of arches - Decrease level of logging messages in some cases - Cache subnets of Azure/AWS cloud --- utils.py | 97 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 19 deletions(-) diff --git a/utils.py b/utils.py index 3d391756..f69a3931 100644 --- a/utils.py +++ b/utils.py @@ -39,23 +39,79 @@ WHITELIST_MIRRORS = ( 'repo.almalinux.org', ) -WHITELIST_MIRRORS_PER_ARCH = { - 'eastus.azure.repo.almalinux.org': [ - 'x86_64', - 'aarch64', - ], - 'germanywestcentral.azure.repo.almalinux.org': [ - 'x86_64', - 'aarch64', - ], - 'southeastasia.azure.repo.almalinux.org': [ - 'x86_64', - 'aarch64', - ], - 'westus2.azure.repo.almalinux.org': [ - 'x86_64', - 'aarch64', - ], +WHITELIST_MIRRORS_PER_ARCH_REPO = { + 'eastus.azure.repo.almalinux.org': { + 'arches': [ + 'x86_64', + 'aarch64', + ], + 'repos': [ + 'AppStream', + 'BaseOS', + 'HighAvailability', + 'NFV', + 'PowerTools', + 'RT', + 'ResilientStorage', + 'devel', + 'extras', + 'plus', + ] + }, + 'germanywestcentral.azure.repo.almalinux.org': { + 'arches': [ + 'x86_64', + 'aarch64', + ], + 'repos': [ + 'AppStream', + 'BaseOS', + 'HighAvailability', + 'NFV', + 'PowerTools', + 'RT', + 'ResilientStorage', + 'devel', + 'extras', + 'plus', + ] + }, + 'southeastasia.azure.repo.almalinux.org': { + 'arches': [ + 'x86_64', + 'aarch64', + ], + 'repos': [ + 'AppStream', + 'BaseOS', + 'HighAvailability', + 'NFV', + 'PowerTools', + 'RT', + 'ResilientStorage', + 'devel', + 'extras', + 'plus', + ] + }, + 'westus2.azure.repo.almalinux.org': { + 'arches': [ + 'x86_64', + 'aarch64', + ], + 'repos': [ + 'AppStream', + 'BaseOS', + 'HighAvailability', + 'NFV', + 'PowerTools', + 'RT', + 'ResilientStorage', + 'devel', + 'extras', + 'plus', + ] + }, } NUMBER_OF_PROCESSES_FOR_MIRRORS_CHECK = 15 AIOHTTP_TIMEOUT = 30 @@ -397,6 +453,9 @@ async def mirror_available( if version in main_config.duplicated_versions: continue for repo_data in main_config.repos: + if mirror_info.name in WHITELIST_MIRRORS_PER_ARCH_REPO and \ + repo_data.name not in WHITELIST_MIRRORS_PER_ARCH_REPO[mirror_info.name]['repos']: + continue if repo_data.vault: continue arches = _get_arches_for_version( @@ -407,8 +466,8 @@ async def mirror_available( if repo_versions and version not in repo_versions: continue for arch in arches: - if mirror_info.name in WHITELIST_MIRRORS_PER_ARCH and \ - arch not in WHITELIST_MIRRORS_PER_ARCH[mirror_info.name]: + if mirror_info.name in WHITELIST_MIRRORS_PER_ARCH_REPO and \ + arch not in WHITELIST_MIRRORS_PER_ARCH_REPO[mirror_info.name]['arches']: continue if not _is_permitted_arch_for_this_version_and_repo( version=version,