Skip to content

Commit

Permalink
Merge pull request #105 from matyasselmeci/pr/master-check-if-migrated
Browse files Browse the repository at this point in the history
Exclude mirrors from the el7 repo mirrorlist if they have migrated to the el9 layout
  • Loading branch information
mwestphall authored Dec 11, 2024
2 parents e7d44df + db1d9f5 commit b8c1eb5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bin/update_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ def mkarchurl(host,tag,arch):
series,dver,repo = tagsplit(tag)
return '/'.join([host,'osg',series,dver,repo,arch])


def is_migrated(url):
# type: (str) -> bool
"""
Check if the repo is using the el9/distrepos repo layout, which has a
list of RPMs in a pkglist file.
"""
pkglist_url = url + "/pkglist"
log("checking: " + pkglist_url)
try:
response = urllib2.urlopen(pkglist_url, timeout=10)
if response.code == 200:
return True
except EnvironmentError:
pass
return False


def test(hosts,tag,arch):
# always include repo.opensciencegrid.org in list
list = [mkarchurl('https://'+hostname,tag,arch)]
Expand Down Expand Up @@ -106,6 +124,9 @@ def test(hosts,tag,arch):
mirrorhosts.remove(host)
except Exception, e:
log("\tException caught while processing url:"+url+" "+str(e))
if is_migrated(url):
log("\tExcluding url " + url + " because it is using the EL9 layout")
mirrorhosts.remove(host)

return list

Expand Down

0 comments on commit b8c1eb5

Please sign in to comment.