updvercheck: be OK with older update being obsolete too

In the "installed package is newer than the one in the update"
case, also be OK (soft fail) if the update is obsolete, not just
if it's stable.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2023-02-18 13:16:32 -08:00
parent 5e2a91192f
commit 8674e29a8e
1 changed files with 7 additions and 7 deletions

View File

@ -43,7 +43,7 @@ problems = []
warnings = [] warnings = []
post = set() post = set()
ret = 0 ret = 0
updstable = None updstableobs = None
with open(instfname, "r", encoding="utf-8") as ifh: with open(instfname, "r", encoding="utf-8") as ifh:
for iline in ifh.readlines(): for iline in ifh.readlines():
(_, name, epoch, version, release) = iline.strip().split(" ") (_, name, epoch, version, release) = iline.strip().split(" ")
@ -62,19 +62,19 @@ with open(instfname, "r", encoding="utf-8") as ifh:
problems.append(f"{msg} and this is not an update test, please check if this is a problem") problems.append(f"{msg} and this is not an update test, please check if this is a problem")
continue continue
# check if the update is stable # check if the update is stable
if updstable is None: if updstableobs is None:
try: try:
url = f"https://bodhi.fedoraproject.org/updates/{updalias}" url = f"https://bodhi.fedoraproject.org/updates/{updalias}"
resp = json.loads(urlopen(url).read().decode("utf8")) # pylint:disable=consider-using-with resp = json.loads(urlopen(url).read().decode("utf8")) # pylint:disable=consider-using-with
updstable = (resp.get("update", {}).get("status", "") == "stable") updstableobs = (resp.get("update", {}).get("status", "") in ("stable", "obsolete"))
except: # pylint:disable=bare-except except: # pylint:disable=bare-except
problems.append(f"{msg} and Bodhi is unreachable.") problems.append(f"{msg} and Bodhi is unreachable.")
continue continue
if updstable: if updstableobs:
warnings.append(f"{msg} and update is stable, this is probably OK.") warnings.append(f"{msg} and update is stable or obsolete, this is probably OK.")
else: else:
problems.append(f"{msg} and update is not stable.") problems.append(f"{msg} and update is not stable or obsolete.")
post.add("Installed newer than update and update not stable means older version could be pushed over newer if update goes stable.") post.add("Installed newer than update and update not stable or obsolete means older version could be pushed over newer if update goes stable.")
if warnings: if warnings:
print("WARNINGS") print("WARNINGS")