#499 Fix issues while handling base images and published content
Merged 4 years ago by gnaponie. Opened 4 years ago by lucarval.
lucarval/freshmaker fix-various-issues  into  master

file modified
+7 -3
@@ -219,6 +219,7 @@ 

              if extra_image.get("odcs", {}).get("compose_ids"):

                  data["odcs_compose_ids"] = extra_image["odcs"]["compose_ids"]

  

+             data["parent_build_id"] = extra_image.get("parent_build_id")

              data["parent_image_builds"] = extra_image.get("parent_image_builds")

  

              brew_task = session.get_task_request(
@@ -1269,7 +1270,7 @@ 

              return parent_brew_build

          # We need to resolve the image in here because "parent_image_builds" needs to be there

          # and it gets populated when the image gets resolved.

-         child_image.resolve_commit()

+         child_image.resolve(self)

          # If the parent is not in `parent_brew_build` we can try to look for the parent in Brew,

          # using the field `parent_image_builds` (searching for the nvr), which should always be there.

          # In case parent_brew_build is None and child_image["parent_image_builds"] == {},
@@ -1296,15 +1297,18 @@ 

              images = []

          parent_image = None

  

-         children = images if images else [child_image]

          # We first try to find the parent from the `parent_brew_build` field in Lightblue.

          parent_brew_build = self.find_parent_brew_build_nvr_from_child(child_image)

          # We've reached the base image, stop recursion

          if not parent_brew_build:

-             return children

+             return images

          parent_image = self.get_images_by_nvrs([parent_brew_build], srpm_names=[srpm_name], published=None)

  

          if parent_image:

+             # In some cases, an image may not have its content sets defined. To

+             # circumvent this gap, we use the list of child images when calling

+             # resolve so their content sets can be used.

+             children = images if images else [child_image]

              parent_image = parent_image[0]

              parent_image.resolve(self, children)

  

file modified
+17 -6
@@ -1275,6 +1275,7 @@ 

                                   "error": None,

                                   "arches": None,

                                   "odcs_compose_ids": None,

+                                  "parent_build_id": None,

                                   "parent_image_builds": None,

                                   "published": True,

                                   "brew": {
@@ -1683,12 +1684,22 @@ 

              resolve_published):

          get_build.return_value = {

              "task_id": 123456,

-             "parent_build_id": 1074147,

-             "parent_image_builds": {

-                 "rh-osbs/openshift-golang-builder:1.11": {

-                     "id": 969696, "nvr": "openshift-golang-builder-container-v1.11.13-3.1"},

-                 "rh-osbs/openshift-ose-base:v4.1.34.20200131.033116": {

-                     "id": 1074147, "nvr": "openshift-enterprise-base-container-v4.1.34-202001310309"}}}

+             "extra": {

+                 "image": {

+                     "parent_build_id": 1074147,

+                     "parent_image_builds": {

+                         "rh-osbs/openshift-golang-builder:1.11": {

+                             "id": 969696,

+                             "nvr": "openshift-golang-builder-container-v1.11.13-3.1"

+                         },

+                         "rh-osbs/openshift-ose-base:v4.1.34.20200131.033116": {

+                             "id": 1074147,

+                             "nvr": "openshift-enterprise-base-container-v4.1.34-202001310309"

+                         },

+                     }

+                 }

+             }

+         }

          get_task_request.return_value = [

              "git://example.com/rpms/repo-1#commit_hash1", "target1", {}]

          exists.return_value = True

Fix base image parent assignment

If an image does not have a parent, ensure that
`LightBlue.find_parent_images_with_package` does not return the image
itself as a parent.
Do not "unresolve" lightblue info

The method `ContainerImage.resolve_commit` will update the image data
with some defaults, including `published`. If called, it will reset the
data populated from Lightblue.

I need to add unit tests and fix some existing ones.

It seems correct. Let's wait for the tests.

1 new commit added

  • Use info from extra.image location
4 years ago

3 new commits added

  • Use info from extra.image location
  • Fix base image parent assignment
  • Do not "unresolve" lightblue info
4 years ago

Pull-Request has been merged by gnaponie

4 years ago