#84 Update Stabilization Phase Detection
Merged 9 months ago by tdawson. Opened 9 months ago by tdawson.
centos/ tdawson/centpkg update-phase-detection  into  develop

file modified
+1
@@ -205,6 +205,7 @@ 

                      divergent_branch = centpkg.utils.does_divergent_branch_exist(

                                              self.cmd.repo_name,

                                              rhel_version,

+                                             active_y,

                                              rhel_dist_git,

                                              pp_api_url,

                                              "rpms")

file modified
+7 -72
@@ -286,17 +286,12 @@ 

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

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

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

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

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

  

There is now a separate phase for Stabilization, rather than just a section of time within the DevTestDoc phase.

Signed-off-by: Troy Dawson tdawson@redhat.com

1 new commit added

  • Change in both places
9 months ago

To summarize a discussion we had elsewhere:

I think we need to deduplicate these functions. There's no need for two implementations of the Product Pages lookup. My recommendation is to drop determine_divergent_branch() which is only ever called by does_divergent_branch_exist(), which in turn is only ever called in cli.py after it has already called determine_active_y_version(). So we could just pass the active Y version to does_divergent_branch_exist() and eliminate all the redundancy.

1 new commit added

  • determine_divergent_branch is redundant. Make the change and remove it.
9 months ago

Totally agree. Redundancy removed. Makes it quicker too.

LGTM. :thumbsup:
Up to you if you want to squash them into a single patch or submit all three commits.

rebased onto 6b939c4

9 months ago

Squashed into one. Thanks for reviewing this.

Pull-Request has been merged by tdawson

9 months ago