Handle maintenance releases better

Maintenance releases may have prior releases that are in Unsupported
Phase. We need to retrieve this information and use it properly to
ensure that we use the rules from the cXs branch in this situation.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2024-09-20 15:30:00 -04:00
parent 84955b3fea
commit 672800359d

View file

@ -44,6 +44,10 @@ pp_phase_name_lookup[pp_phase_stabilization] = "Stabilization"
pp_phase_maintenance = 600 pp_phase_maintenance = 600
pp_phase_name_lookup[pp_phase_maintenance] = "Maintenance" pp_phase_name_lookup[pp_phase_maintenance] = "Maintenance"
# Phase 1000 is "Unsupported" (AKA, end-of-life)
pp_phase_unsupported = 1000
pp_phase_name_lookup[pp_phase_unsupported] = "Unsupported"
# Default lookup location for unsynced packages # Default lookup location for unsynced packages
default_distrobaker_config = "https://gitlab.cee.redhat.com/osci/distrobaker_config/-/raw/rhel9/distrobaker.yaml?ref_type=heads" default_distrobaker_config = "https://gitlab.cee.redhat.com/osci/distrobaker_config/-/raw/rhel9/distrobaker.yaml?ref_type=heads"
@ -525,9 +529,7 @@ def determine_rhel_state(
# Query the "package pages" API for the current active Y-stream release # Query the "package pages" API for the current active Y-stream release
request_params = { request_params = {
"phase__in": "{},{},{}".format( "phase__in": f"{pp_phase_devtestdoc},{pp_phase_stabilization},{pp_phase_maintenance},{pp_phase_unsupported}",
pp_phase_devtestdoc, pp_phase_stabilization, pp_phase_maintenance
),
"product__shortname": "rhel", "product__shortname": "rhel",
"relgroup__shortname": rhel_version, "relgroup__shortname": rhel_version,
"format": "json", "format": "json",
@ -616,28 +618,40 @@ def determine_rhel_state(
logger.debug("Prior release branch: {}".format(prior_release_branch)) logger.debug("Prior release branch: {}".format(prior_release_branch))
try: # Determine which phase the prior release is in:
branch_exists = does_branch_exist( prior_release_phase = phase_lookup[prior_release_branch]
rhel_dist_git, namespace, repo_name, prior_release_branch
)
except gitpython.GitCommandError as e:
raise RHELError("Could not read from RHEL dist-git. Are you on the VPN?")
if branch_exists: # If the prior release is in the Unsupported Phase, it probably means
# The branch is there, so work on the active Y-stream, which is always # that we're dealing with an EOL CentOS Stream (like 8.10). We need
# in either DevTestDoc Phase or Maintenance Phase (in the case of an # to use the stream rules in this case.
# end-of-life CentOS Stream) prior_is_eol = bool(prior_release_phase == pp_phase_unsupported)
if not prior_is_eol:
try:
branch_exists = does_branch_exist(
rhel_dist_git, namespace, repo_name, prior_release_branch
)
except gitpython.GitCommandError as e:
raise RHELError("Could not read from RHEL dist-git. Are you on the VPN?")
if prior_is_eol or branch_exists:
# The branch is there or the previous branch is EOL, so work on the
# active Y-stream, which is always in either DevTestDoc Phase or
# Maintenance Phase (in the case of an end-of-life CentOS Stream)
# We'll catch the unexpected case of Unsupported Phase as well, just
# to be safe.
phase = phase_lookup[current_release_branch] phase = phase_lookup[current_release_branch]
check_tickets_branch = cs_branch check_tickets_branch = cs_branch
rhel_target_default = "latest" rhel_target_default = "latest"
target_version = latest_version target_version = latest_version
if phase == pp_phase_maintenance: if phase >= pp_phase_maintenance:
enforcing = True enforcing = True
else: else:
enforcing = False enforcing = False
else: else:
# The branch is not present, so we'll work on the prior Y-stream # The branch is not present, so we'll work on the prior Y-stream
check_tickets_branch = prior_release_branch check_tickets_branch = prior_release_branch
phase = prior_release_phase
target_x, target_y, target_extra = parse_rhel_branchname(prior_release_branch) target_x, target_y, target_extra = parse_rhel_branchname(prior_release_branch)
target_version = "{}.{}{}".format( target_version = "{}.{}{}".format(
@ -650,9 +664,6 @@ def determine_rhel_state(
# phase, so it always enforces. # phase, so it always enforces.
enforcing = True enforcing = True
# Determine which phase the prior release is in:
phase = phase_lookup[prior_release_branch]
if phase == pp_phase_stabilization: if phase == pp_phase_stabilization:
# We're in the Stabilization phase, so we can't automatically determine # We're in the Stabilization phase, so we can't automatically determine
# between the "zstream" and "exception" targets. # between the "zstream" and "exception" targets.