From 7bcd74651695299fc8fb4e862401178203720788 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Sep 20 2024 17:40:40 +0000 Subject: [PATCH 1/3] determine_rhel_state: Fix missing phase check The string wasn't updated properly to include the MAINTENANCE phase lookup, so it broke detection of RHEL 8.10. Signed-off-by: Stephen Gallagher --- diff --git a/src/centpkg/utils.py b/src/centpkg/utils.py index 64cf59f..317b202 100644 --- a/src/centpkg/utils.py +++ b/src/centpkg/utils.py @@ -525,7 +525,7 @@ def determine_rhel_state( # Query the "package pages" API for the current active Y-stream release request_params = { - "phase__in": "{},{}".format( + "phase__in": "{},{},{}".format( pp_phase_devtestdoc, pp_phase_stabilization, pp_phase_maintenance ), "product__shortname": "rhel", From 84955b3feae17cfd50792dc743ca539f9e6db5d2 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Sep 20 2024 18:38:02 +0000 Subject: [PATCH 2/3] Fix detection of releases in Maintenance Phase Signed-off-by: Stephen Gallagher --- diff --git a/src/centpkg/utils.py b/src/centpkg/utils.py index 317b202..45649d3 100644 --- a/src/centpkg/utils.py +++ b/src/centpkg/utils.py @@ -612,6 +612,7 @@ def determine_rhel_state( prior_release_branch = format_branch( x_version, active_y_version - 1, is_beta=False ) + current_release_branch = format_branch(x_version, active_y_version, is_beta=False) logger.debug("Prior release branch: {}".format(prior_release_branch)) @@ -624,12 +625,16 @@ def determine_rhel_state( if branch_exists: # The branch is there, so work on the active Y-stream, which is always - # in DevTestDoc Phase - phase = pp_phase_devtestdoc + # in either DevTestDoc Phase or Maintenance Phase (in the case of an + # end-of-life CentOS Stream) + phase = phase_lookup[current_release_branch] check_tickets_branch = cs_branch rhel_target_default = "latest" - enforcing = False target_version = latest_version + if phase == pp_phase_maintenance: + enforcing = True + else: + enforcing = False else: # The branch is not present, so we'll work on the prior Y-stream check_tickets_branch = prior_release_branch From 672800359d77bf6b013fefe19334335da7cf73fe Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Sep 20 2024 19:30:15 +0000 Subject: [PATCH 3/3] 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 --- diff --git a/src/centpkg/utils.py b/src/centpkg/utils.py index 45649d3..b65aefe 100644 --- a/src/centpkg/utils.py +++ b/src/centpkg/utils.py @@ -44,6 +44,10 @@ pp_phase_name_lookup[pp_phase_stabilization] = "Stabilization" pp_phase_maintenance = 600 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_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 request_params = { - "phase__in": "{},{},{}".format( - pp_phase_devtestdoc, pp_phase_stabilization, pp_phase_maintenance - ), + "phase__in": f"{pp_phase_devtestdoc},{pp_phase_stabilization},{pp_phase_maintenance},{pp_phase_unsupported}", "product__shortname": "rhel", "relgroup__shortname": rhel_version, "format": "json", @@ -616,28 +618,40 @@ def determine_rhel_state( logger.debug("Prior release branch: {}".format(prior_release_branch)) - 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?") + # Determine which phase the prior release is in: + prior_release_phase = phase_lookup[prior_release_branch] - if branch_exists: - # The branch is there, 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) + # If the prior release is in the Unsupported Phase, it probably means + # that we're dealing with an EOL CentOS Stream (like 8.10). We need + # to use the stream rules in this case. + 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] check_tickets_branch = cs_branch rhel_target_default = "latest" target_version = latest_version - if phase == pp_phase_maintenance: + if phase >= pp_phase_maintenance: enforcing = True else: enforcing = False else: # The branch is not present, so we'll work on the prior Y-stream check_tickets_branch = prior_release_branch + phase = prior_release_phase target_x, target_y, target_extra = parse_rhel_branchname(prior_release_branch) target_version = "{}.{}{}".format( @@ -650,9 +664,6 @@ def determine_rhel_state( # phase, so it always enforces. enforcing = True - # Determine which phase the prior release is in: - phase = phase_lookup[prior_release_branch] - if phase == pp_phase_stabilization: # We're in the Stabilization phase, so we can't automatically determine # between the "zstream" and "exception" targets.