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

CI test caching only stores most recently tested BIB hash causing repeat builds #594

Closed
achilleas-k opened this issue Apr 15, 2024 · 0 comments · Fixed by #599
Closed

CI test caching only stores most recently tested BIB hash causing repeat builds #594

achilleas-k opened this issue Apr 15, 2024 · 0 comments · Fixed by #599

Comments

@achilleas-k
Copy link
Member

The CI cache is used to decide if an image should be rebuilt in testing based on whether the image definition or one of the test dependencies has changed. The following items are considered:

  1. Manifest ID (hash of image definition + content).
  2. osbuild version.
  3. bootc-image-builder container ID.
  4. Boot test success (this will rebuild an image if we add it to the image types that can boot test and no information about a previous boot test exists).

The decision is made in the check_for_build() function:

def check_for_build(manifest_fname, build_info_path, errors):

The manifest ID and osbuild version are part of the path of the cached results, so any change in one of those elements creates a new entry in the cache directory tree, keeping the old result intact.
However, the bootc-image-builder container ID is only part of the metadata in the info.json file for each entry. This means that the following sequence of events can occur and cause unnecessary rebuilds:

  1. Cache entry exists at path <distro>/<arch>/<osbuild-version>/<manifest-id> and the info.json contains "bib-id": "sha256:aaaa".
  2. PR#A to update bib ID is created (automatically, daily). The CI run finds the cache entry, sees that the new bib ID, sha256:bbbb doesn't match the one in info.json and rebuilds the image and boot tests it.
  3. <distro>/<arch>/<osbuild-version>/<manifest-id>/info.json is updated and now contains "bib-id": "sha256:bbbb".
  4. PR#B is created (before the previous one is merged) with the bib ID defined in the main branch. The CI run finds the cache entry, sees that the bib ID, sha256:aaaa doesn't match the one in info.json and rebuilds the image and boot tests it.
  5. <distro>/<arch>/<osbuild-version>/<manifest-id>/info.json is updated and now contains "bib-id": "sha256:aaaa" again.
  6. PR#A is added to the merge queue and rebuilds the image again like in step 2, changing the bib ID in the cache back to sha256:bbbb.

Slightly different sequences of events and more PRs can cause more rebuilds, but this demonstrates a simple version of the issue.
A quick solution would be to include the bib ID in the path like we do with the osbuild version, but only a single image type depends on this in testing, so it wouldn't make sense in other cases.
Another solution would be to separate the bib metadata so we could have:

  • <distro>/<arch>/<osbuild-version>/<manifest-id>/info.json
  • <distro>/<arch>/<osbuild-version>/<manifest-id>/bib-aaaa.json: with content {"boot-success": true}
  • <distro>/<arch>/<osbuild-version>/<manifest-id>/bib-bbbb.json: with content {"boot-success": true}

Also, we could be a bit smarter with what we test. If the manifest ID and osbuild version haven't changed, and all we need to do is boot test the image, we could download the image itself from the cache instead of rebuilding it and only run the boot test.

achilleas-k added a commit to achilleas-k/images that referenced this issue Apr 15, 2024
On successful boot, save the bootc-image-builder image ID as a separate
(empty) file so we can save the boot success of multiple images and
avoid unnecessary rebuilds.

See osbuild#594
achilleas-k added a commit to achilleas-k/images that referenced this issue Apr 15, 2024
On successful boot, save the bootc-image-builder image ID as a separate
(empty) file so we can save the boot success of multiple images and
avoid unnecessary rebuilds.

See osbuild#594
achilleas-k added a commit to achilleas-k/images that referenced this issue Apr 15, 2024
On successful boot, save the bootc-image-builder image ID as a separate
(empty) file so we can save the boot success of multiple images and
avoid unnecessary rebuilds.

See osbuild#594
achilleas-k added a commit to achilleas-k/images that referenced this issue Apr 16, 2024
On successful boot, save the bootc-image-builder image ID as a separate
(empty) file so we can save the boot success of multiple images and
avoid unnecessary rebuilds.

See osbuild#594
github-merge-queue bot pushed a commit that referenced this issue Apr 16, 2024
On successful boot, save the bootc-image-builder image ID as a separate
(empty) file so we can save the boot success of multiple images and
avoid unnecessary rebuilds.

See #594
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 a pull request may close this issue.

1 participant