koji_block_retired: Solve the new branch creation by checking on distgit, not time restricting
Signed-off-by: Lenka Segura <lsegura@redhat.com>
This commit is contained in:
parent
188ce265e0
commit
1c910f1215
2 changed files with 30 additions and 2 deletions
|
@ -6,7 +6,7 @@ Authors: Anton Medvedev <amedvede@redhat.com>
|
|||
|
||||
import argparse
|
||||
from collections import defaultdict
|
||||
import datetime
|
||||
import time
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
|
@ -18,7 +18,7 @@ import requests
|
|||
import toml
|
||||
|
||||
from toddlers.base import ToddlerBase
|
||||
from toddlers.utils import bodhi
|
||||
from toddlers.utils import bodhi, pagure
|
||||
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
|
@ -42,6 +42,7 @@ class KojiBlockRetired(ToddlerBase):
|
|||
self.koji_principal = None
|
||||
self.koji_keytab = None
|
||||
self.bodhi = None
|
||||
self.distgit = None
|
||||
|
||||
def accepts_topic(self, topic):
|
||||
"""Returns a boolean whether this toddler is interested in messages
|
||||
|
|
|
@ -1192,6 +1192,33 @@ class Pagure:
|
|||
else:
|
||||
return False
|
||||
|
||||
def has_dead_package_on_branch(self, package: str, branch: str) -> bool:
|
||||
"""
|
||||
Check if the given package has dead.package in distgit on particular
|
||||
branch. Might look the same as the function `is_retired_on_branch`.
|
||||
The difference is that the json files in lookaside reflects the status
|
||||
of the packages with a small delay (up to 1 day).
|
||||
"""
|
||||
endpoint_url = f"https://src.fedoraproject.org/api/0/rpms/{package}/tree/{branch}/f/dead.package"
|
||||
headers = self.get_auth_header()
|
||||
|
||||
log.debug(f"Checking if the dead.package is present on branch {branch}")
|
||||
response = self._requests_session.get(endpoint_url, headers=headers)
|
||||
|
||||
if response.ok:
|
||||
if response.json()["name"] == "dead.package":
|
||||
return True
|
||||
# When the branch doesn't exist return empty list
|
||||
elif response.status_code == 404:
|
||||
return False
|
||||
else:
|
||||
log.error(
|
||||
"Error when checking for dead.package for '%s'. "
|
||||
"Got status_code '%s'.",
|
||||
branch,
|
||||
response.status_code,
|
||||
)
|
||||
|
||||
def orphan_package(
|
||||
self, namespace: str, package: str, reason: str, info: str
|
||||
) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue