mirror of
https://git.centos.org/centos/centpkg.git
synced 2025-02-23 08:12:55 +00:00
Update Stabilization Phase Detection
Signed-off-by: Troy Dawson <tdawson@redhat.com>
This commit is contained in:
parent
739c746983
commit
6b939c428f
2 changed files with 8 additions and 72 deletions
|
@ -205,6 +205,7 @@ class centpkgClient(cliClient):
|
|||
divergent_branch = centpkg.utils.does_divergent_branch_exist(
|
||||
self.cmd.repo_name,
|
||||
rhel_version,
|
||||
active_y,
|
||||
rhel_dist_git,
|
||||
pp_api_url,
|
||||
"rpms")
|
||||
|
|
|
@ -286,17 +286,12 @@ def stream_mapping(csname):
|
|||
return "rhel-11"
|
||||
return None
|
||||
|
||||
def does_divergent_branch_exist(repo_name, rhel_version, rhel_dist_git, pp_api_url, namespace):
|
||||
def does_divergent_branch_exist(repo_name, rhel_version, active_y, rhel_dist_git, pp_api_url, namespace):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Determine if the Y-1 branch exists for this repo
|
||||
|
||||
# Look up the Y-1 branch name
|
||||
divergent_branch = determine_divergent_branch(
|
||||
rhel_version,
|
||||
pp_api_url,
|
||||
namespace,
|
||||
)
|
||||
divergent_branch = active_y - 1
|
||||
logger.debug("Divergent branch: {}".format(divergent_branch))
|
||||
|
||||
g = gitpython.cmd.Git()
|
||||
|
@ -316,48 +311,6 @@ def does_divergent_branch_exist(repo_name, rhel_version, rhel_dist_git, pp_api_u
|
|||
raise
|
||||
return branch_exists
|
||||
|
||||
def determine_divergent_branch(rhel_version, pp_api_url, namespace):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Query the "package pages" API for the current active Y-stream release
|
||||
# Phase 230 is "Planning / Development / Testing" (AKA DeveTestDoc)
|
||||
request_params = {
|
||||
"phase": 230,
|
||||
"product__shortname": "rhel",
|
||||
"relgroup__shortname": rhel_version,
|
||||
"format": "json",
|
||||
}
|
||||
|
||||
res = requests.get(
|
||||
os.path.join(pp_api_url, "latest", "releases"),
|
||||
params=request_params,
|
||||
timeout=60,
|
||||
)
|
||||
res.raise_for_status()
|
||||
payload = json.loads(res.text)
|
||||
logger.debug(
|
||||
"Response from PP API: {}".format(json.dumps(payload, indent=2))
|
||||
)
|
||||
if len(payload) < 1:
|
||||
raise RuntimeError("Received zero potential release matches)")
|
||||
|
||||
active_y_version = -1
|
||||
for entry in payload:
|
||||
shortname = entry["shortname"]
|
||||
|
||||
# The shortname is in the form rhel-9-1.0
|
||||
# Extract the active Y-stream version
|
||||
m = re.search("(?<={}-)\d+(?=\.0)".format(rhel_version), shortname)
|
||||
if not m:
|
||||
raise RuntimeError(
|
||||
"Could not determine active Y-stream version from shortname"
|
||||
)
|
||||
y_version = int(m.group(0))
|
||||
if y_version > active_y_version:
|
||||
active_y_version = y_version
|
||||
|
||||
# The divergent branch is Y-1
|
||||
return "{}.{}.0".format(rhel_version, active_y_version - 1)
|
||||
|
||||
def _datesplit(isodate):
|
||||
date_string_tuple = isodate.split('-')
|
||||
|
@ -372,9 +325,10 @@ def determine_active_y_version(rhel_version, pp_api_url):
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Query the "package pages" API for the current active Y-stream release
|
||||
# Phase 230 is "Planning / Development / Testing" (AKA DeveTestDoc)
|
||||
# Phase 230 is "Planning / Development / Testing" (AKA DevTestDoc)
|
||||
# Phase 450 is "Stabilization"
|
||||
request_params = {
|
||||
"phase": 230,
|
||||
"phase__in": "230,450",
|
||||
"product__shortname": "rhel",
|
||||
"relgroup__shortname": rhel_version,
|
||||
"format": "json",
|
||||
|
@ -391,7 +345,7 @@ def determine_active_y_version(rhel_version, pp_api_url):
|
|||
"Response from PP API: {}".format(json.dumps(payload, indent=2))
|
||||
)
|
||||
if len(payload) < 1:
|
||||
raise RuntimeError("Received zero potential release matches)")
|
||||
raise RuntimeError("Received zero potential release matches")
|
||||
|
||||
release_id = -1
|
||||
active_y_version = -1
|
||||
|
@ -410,26 +364,7 @@ def determine_active_y_version(rhel_version, pp_api_url):
|
|||
active_y_version = y_version
|
||||
release_id = entry["id"]
|
||||
|
||||
# Now look up whether we are in the Exception Phase for this Y-stream release
|
||||
request_params = {
|
||||
"name__regex": "(Excep|Stabiliza)tion Phase",
|
||||
"format": "json",
|
||||
}
|
||||
res = requests.get(os.path.join(pp_api_url, "latest", "releases", str(release_id), "schedule-tasks"), params=request_params)
|
||||
res.raise_for_status()
|
||||
payload = json.loads(res.text)
|
||||
logger.debug(
|
||||
"Response from phase lookup: {}".format(json.dumps(payload, indent=2))
|
||||
)
|
||||
|
||||
# This lookup *must* return exactly one value or the Product Pages are
|
||||
# wrong and must be fixed.
|
||||
assert len(payload) == 1
|
||||
|
||||
# Determine if this Y-stream release is in the exception phase
|
||||
today = datetime.now(tz=pytz.utc).date()
|
||||
exception_start_date = date(*_datesplit(payload[0]["date_start"]))
|
||||
in_exception_phase = today >= exception_start_date
|
||||
in_exception_phase = entry["phase"] == 450
|
||||
|
||||
logger.debug("Active Y-stream: {}, Enforcing: {}".format(active_y_version, in_exception_phase))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue