From 24a7f5a56e73f034ebd97b73c07628fc16d9618c Mon Sep 17 00:00:00 2001 From: Luiz Carvalho Date: Mar 09 2020 13:19:00 +0000 Subject: [PATCH 1/3] 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. Signed-off-by: Luiz Carvalho --- diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py index 9a21b74..cde3d27 100644 --- a/freshmaker/lightblue.py +++ b/freshmaker/lightblue.py @@ -1269,7 +1269,7 @@ class LightBlue(object): 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"] == {}, From fe77f2165c9d550ca7990e14556155005e5ea994 Mon Sep 17 00:00:00 2001 From: Luiz Carvalho Date: Mar 09 2020 13:21:25 +0000 Subject: [PATCH 2/3] 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. Signed-off-by: Luiz Carvalho --- diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py index cde3d27..b1aef6e 100644 --- a/freshmaker/lightblue.py +++ b/freshmaker/lightblue.py @@ -1296,15 +1296,18 @@ class LightBlue(object): 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) From d88d0ead220de0e61140c483785a217f11b66606 Mon Sep 17 00:00:00 2001 From: Luiz Carvalho Date: Mar 09 2020 14:30:20 +0000 Subject: [PATCH 3/3] Use info from extra.image location Signed-off-by: Luiz Carvalho --- diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py index b1aef6e..8de7f43 100644 --- a/freshmaker/lightblue.py +++ b/freshmaker/lightblue.py @@ -219,6 +219,7 @@ class ContainerImage(dict): 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( diff --git a/tests/test_lightblue.py b/tests/test_lightblue.py index 22f094e..a95b74b 100644 --- a/tests/test_lightblue.py +++ b/tests/test_lightblue.py @@ -1275,6 +1275,7 @@ class TestQueryEntityFromLightBlue(helpers.FreshmakerTestCase): "error": None, "arches": None, "odcs_compose_ids": None, + "parent_build_id": None, "parent_image_builds": None, "published": True, "brew": { @@ -1683,12 +1684,22 @@ class TestQueryEntityFromLightBlue(helpers.FreshmakerTestCase): 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