#109 determine_rhel_state: Fix missing phase check
Merged 2 months ago by tdawson. Opened 2 months ago by sgallagh.
centos/ sgallagh/centpkg determine_rhel_state  into  develop

file modified
+33 -17
@@ -44,6 +44,10 @@ 

  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 @@ 

  

      # 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",
@@ -612,27 +614,44 @@ 

          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))

  

-     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 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 branch_exists:

-         # The branch is there, so work on the active Y-stream, which is always

-         # in DevTestDoc Phase

-         phase = pp_phase_devtestdoc

+     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"

-         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

+         phase = prior_release_phase

  

          target_x, target_y, target_extra = parse_rhel_branchname(prior_release_branch)

          target_version = "{}.{}{}".format(
@@ -645,9 +664,6 @@ 

          # 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.

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 sgallagh@redhat.com

1 new commit added

  • Fix detection of releases in Maintenance Phase
2 months ago

OK, I just spotted another issue. We weren't properly handling c8s which is connected to RHEL 8.10, which is in Maintenance Phase. It was treating it the same as being in DevTestDoc Phase, meaning it would not block and enforce the ticket checks.

See patch 2 for the fix.

2 new commits added

  • Fix detection of releases in Maintenance Phase
  • determine_rhel_state: Fix missing phase check
2 months ago

2 new commits added

  • Fix detection of releases in Maintenance Phase
  • determine_rhel_state: Fix missing phase check
2 months ago

1 new commit added

  • Handle maintenance releases better
2 months ago

@tdawson noticed during review that it was buggy when dealing with packages that didn't have a rhel-8.9.0 branch. That led down a bit of a rabbit hole, but I've now added a third patch to this set that should handle that case properly.

LGTM and passes all my tests.
Did you want to do a rebase for less commits, or are you good as it is?

They're logically distinct, so I think it's fine to keep them separate. Thanks!

Pull-Request has been merged by tdawson

2 months ago
Metadata