Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include osbuild NEVRA in build info path for test cache #432

Merged
merged 5 commits into from
Feb 9, 2024

Conversation

achilleas-k
Copy link
Member

@achilleas-k achilleas-k commented Feb 8, 2024

Until now, the following scenario would produce unnecessary rebuilds:

  • A PR is opened that updates osbuild in Schutzfile to vNew.
  • A manifest is generated with id abc123.
  • The build info lookup for abc123 shows that it was built with vOld so it's added to the test matrix.
  • The new build info is uploaded showing abc123 was built with vNew.
  • A different PR runs CI with vOld (before the update PR is merged or before this PR is rebased).
  • A manifest is generated with id abc123 again.
  • The build info lookup for abc123 shows that it was built with vNew (in the osbuild update PR) but the currently installed version is vOld (!= vNew) so it's added to the test matrix.
  • The new build info is uploaded showing abc123 was built with vOld.

This doesn't just create an unnecessary rebuild, but can create a situation where every image is rebuilt multiple times a day if the two PRs keep getting amended, essentially fighting each other by changing the commit ID back and forth.

This commit changes the build info paths to include the osbuild package version (NEVRA) as a path component:

s3://images-ci-cache/images/builds/fedora-40/aarch64/osbuild-104-1.fc39.noarch/abc123

The build filter now no longer needs to read the osbuild commit ID from the info.json and compare with the current one. It can simply check the path with the package version component and if it is not found, the new configuration will be tested.

Note that this PR will of course create a mass rebuild of all the images. All PRs should be rebased on this when it's merged to avoid pushing images and build info to the old paths.
The old paths should be cleaned up by the bucket retention policy in a few days.

@mvo5 mvo5 self-requested a review February 8, 2024 20:04
ochosi
ochosi previously approved these changes Feb 9, 2024
Copy link
Contributor

@ochosi ochosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoiding unnecessary builds - yay! 💖
The logic is sound and the path construction in the code looks plausible!

@thozza
Copy link
Member

thozza commented Feb 9, 2024

Please correct me if I'm wrong, but we may end up not rebuilding images if the osbuild commit SHA is updated to a newer version, but that version still has the same NEVRA as the current commit SHA (e.g. both are from main and part of an unreleased version of osbuild), right? Which is not ideal, no?

@achilleas-k
Copy link
Member Author

Please correct me if I'm wrong, but we may end up not rebuilding images if the osbuild commit SHA is updated to a newer version, but that version still has the same NEVRA as the current commit SHA (e.g. both are from main and part of an unreleased version of osbuild), right? Which is not ideal, no?

The RPMs we build for unreleased versions of osbuild contain the short-SHA in their NEVRA, so this shouldn't be an issue. I believe this comes automatically from the %{?dist} tag in the spec file.
Here's a build log that shows the path that's created for the results:
https://gitlab.com/redhat/services/products/image-builder/ci/images/-/jobs/6128641712

Uploading build/fedora_39-x86_64-ami-empty to s3://images-ci-cache/images/builds/fedora-39/x86_64/osbuild-107-1.20190819git6e12f08.fc39.noarch/4f1a882beb4de10b802ea5f424603696fb987cf769779d6ff1d7cf56a5994ec8/

Returns the installed rpm version for osbuild.
Helper functions for generating paths will help us avoid inconsistencies
when changing the way we create or look up paths for build metadata.
Until now, the following scenario would produce unnecessary rebuilds:
- A PR is opened that updates osbuild in `Schutzfile` to `vNew`.
- A manifest is generated with id `abc123`.
- The build info lookup for `abc123` shows that it was built with `vOld`
  so it's added to the test matrix.
- The new build info is uploaded showing `abc123` was built with `vNew`.
- A different PR runs CI with `vOld` (before the update PR is merged or
  before this PR is rebased).
- A manifest is generated with id `abc123` again.
- The build info lookup for `abc123` shows that it was built with `vNew`
  (in the osbuild update PR) but the currently installed version is
  `vOld` (`!= vNew`) so it's added to the test matrix.
- The new build info is uploaded showing `abc123` was built with `vOld`.

This commit changes the build info paths to include the osbuild package
version (NEVRA) as a path component:

    s3://images-ci-cache/images/builds/fedora-40/aarch64/osbuild-104-1.fc39.noarch/abc123

The build filter now no longer needs to read the osbuild commit ID from
the info.json and compare with the current one.  It can simply check the
path with the package version component and if it is not found, the new
configuration will be tested.
Test the path generators with a mocked get_osbuild_nevra() function so
that they can be run without osbuild installed and on non-rpm based
systems.
@achilleas-k
Copy link
Member Author

achilleas-k commented Feb 9, 2024

Please correct me if I'm wrong, but we may end up not rebuilding images if the osbuild commit SHA is updated to a newer version, but that version still has the same NEVRA as the current commit SHA (e.g. both are from main and part of an unreleased version of osbuild), right? Which is not ideal, no?

The RPMs we build for unreleased versions of osbuild contain the short-SHA in their NEVRA, so this shouldn't be an issue. I believe this comes automatically from the %{?dist} tag in the spec file. Here's a build log that shows the path that's created for the results: https://gitlab.com/redhat/services/products/image-builder/ci/images/-/jobs/6128641712

Uploading build/fedora_39-x86_64-ami-empty to s3://images-ci-cache/images/builds/fedora-39/x86_64/osbuild-107-1.20190819git6e12f08.fc39.noarch/4f1a882beb4de10b802ea5f424603696fb987cf769779d6ff1d7cf56a5994ec8/

Funny. The 20190819 seems to be a date stamp but why is it in 2019? Building an rpm locally I get

osbuild-108-1.20240209gita85b51b.fc39.noarch

Probably a mock thing, right?

@thozza
Copy link
Member

thozza commented Feb 9, 2024

Funny. The 20190819 seems to be a date stamp but why is it in 2019? Building an rpm locally I get

osbuild-108-1.20240209gita85b51b.fc39.noarch

Probably a mock thing, right?

I don't think so... Are you sure that the date is correct on the host which builds the RPM? 🤔

Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@achilleas-k
Copy link
Member Author

Funny. The 20190819 seems to be a date stamp but why is it in 2019? Building an rpm locally I get

osbuild-108-1.20240209gita85b51b.fc39.noarch

Probably a mock thing, right?

I don't think so... Are you sure that the date is correct on the host which builds the RPM? 🤔

This gets even weirder. Here's an example build log: https://gitlab.com/redhat/services/products/image-builder/ci/osbuild/-/jobs/6131776245

Mock start with

🎁 Building RPMs with mock
INFO: mock.py version 5.3 starting (python version = 3.11.2, NVR = mock-5.3-1.fc38), args: /usr/libexec/mock/mock -r fedora-38-x86_64 --no-bootstrap-chroot --resultdir repo/osbuild/fedora-38/x86_64/77855c9e63c8d74ca74bd3a8cd9f0afe01f8f294 rpmbuild/SRPMS/osbuild-108-1.20240208git77855c9.fc38.src.rpm

Date is correct!

Then ends with

Start: build phase for osbuild-108-1.20240208git77855c9.fc38.src.rpm
Start: build setup for osbuild-108-1.20240208git77855c9.fc38.src.rpm
Finish: build setup for osbuild-108-1.20240208git77855c9.fc38.src.rpm
Start: Outputting list of installed packages
Finish: Outputting list of installed packages
Start: rpmbuild osbuild-108-1.20240208git77855c9.fc38.src.rpm
Finish: rpmbuild osbuild-108-1.20240208git77855c9.fc38.src.rpm
Finish: build phase for osbuild-108-1.20240208git77855c9.fc38.src.rpm
INFO: Done(rpmbuild/SRPMS/osbuild-108-1.20240208git77855c9.fc38.src.rpm) Config(fedora-38-x86_64) 1 minutes 37 seconds
INFO: Results and/or logs in: repo/osbuild/fedora-38/x86_64/77855c9e63c8d74ca74bd3a8cd9f0afe01f8f294
INFO: Cleaning up build root ('cleanup_on_success=True')
Start: clean chroot
Finish: clean chroot
Finish: run

Date still correct. But:

⛓️ Creating dnf repository
Directory walk started
Directory walk done - 9 packages
Temporary output repo path: repo/osbuild/fedora-38/x86_64/77855c9e63c8d74ca74bd3a8cd9f0afe01f8f294/.repodata/
Preparing sqlite DBs
Pool started (with 5 workers)
Pool finished
☁ Uploading RPMs to S3
~/~/builds/redhat/services/products/image-builder/ci/osbuild/repo ~/~/builds/redhat/services/products/image-builder/ci/osbuild
upload: './osbuild/fedora-38/x86_64/77855c9e63c8d74ca74bd3a8cd9f0afe01f8f294/osbuild-108-1.20190819git77855c9.fc38.noarch.rpm' -> 's3://osbuild-composer-repos/osbuild/fedora-38/x86_64/77855c9e63c8d74ca74bd3a8cd9f0afe01f8f294/osbuild-108-1.20190819git77855c9.fc38.noarch.rpm' (135573 bytes in 0.2 seconds, 738.56 KB/s) [1 of 16]
Public URL of the object is: http://osbuild-composer-repos.s3.amazonaws.com/osbuild/fedora-38/x86_64/77855c9e63c8d74ca74bd3a8cd9f0afe01f8f294/osbuild-108-1.20190819git77855c9.fc38.noarch.rpm

Date changes during createrepo_c??

@achilleas-k
Copy link
Member Author

AH WAIT. I see it now. It's the last date in the %changelog in the spec file 🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants