Skip to content

Commit

Permalink
Ignore images with missing brew nvr data
Browse files Browse the repository at this point in the history
Images built and released by Konflux lack Brew metadata. Freshmaker
will encounter problems, because it currently expects this data.

This commit makes Freshmaker ignore those images. This is done in
`images.PyxisAPI.find_images_with_included_rpms`, right after querying pyxis,
by checking the brew nvr field.
  • Loading branch information
FernandesMF committed Oct 29, 2024
1 parent 57d573a commit 98cb86b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions freshmaker/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@ def find_images_with_included_rpms(
if not images:
return []

# Skip images without Brew metadata. Images built and released by Konflux
# lack Brew metadata. We don't support rebuilding such images.
images = [x for x in images if x["brew"]]

# Avoid manipulating the images directly, use a copy instead
image_dicts = copy.deepcopy(images)
del images
Expand Down
50 changes: 50 additions & 0 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,56 @@ def test_images_with_included_newer_srpm_multilpe_nvrs(self, exists, mocked_clie
)
self.assertEqual([image.nvr for image in ret], ["parent-1-3", "parent-1-2"])

@patch("freshmaker.pyxis_gql.Client")
def test_images_with_missing_nvr_data(self, mock_pyxis_client):
mock_pyxis_client.return_value.execute.return_value = {
"find_images": {
"data": [
{
"architecture": "amd64",
"brew": None,
"content_sets": ["dummy-content-set-1"],
"edges": {
"rpm_manifest": {
"data": {
"rpms": [
{
"name": "openssl",
"nvra": "openssl-1.2.3-2.amd64",
"srpm_name": "openssl",
"srpm_nevra": "openssl-1.2.3-2.amd64",
}
]
}
}
},
"parent_brew_build": "ubi8-minimal-container-8.6-100.1582220001",
"parsed_data": {},
"repositories": [
{
"published": True,
"registry": "registry.example.com",
"repository": "product/repo1",
"tags": [{"name": "latest"}],
}
],
}
],
"error": None,
"page": 0,
"page_size": 250,
"total": 2,
}
}
pyxis = PyxisAPI(server_url=self.fake_server_url)
repositories = {
repo["repository"]: repo for repo in self.fake_repositories_with_content_sets
}
ret = pyxis.find_images_with_included_rpms(
["dummy-content-set-1"], ["openssl-1.2.4-2"], repositories
)
self.assertEqual([], ret)

def _filter_fnc(self, image):
return image.nvr.startswith("filtered_")

Expand Down

0 comments on commit 98cb86b

Please sign in to comment.