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

sysext_prod_builder: fix build id mismatch #2056

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Conversation

t-lo
Copy link
Member

@t-lo t-lo commented Jun 24, 2024

This change fixes a version mismatch of FLATCAR_BUILD_ID when performing a dev build of an existing release tag. The build ID is part of the version string of dev builds, separated by a + from the main version. If common.sh detects a dev build (COREOS_OFFICIAL != 1) and FLATCAR_BUILD_ID is empty, common.sh will generate a new ID based on a timestamp. This is usually desired behaviour to prevent accidentally marking a dev build non-dev (which would cause breakage much later when signature checks fail).

For official releases, FLATCAR_BUILD_ID is not set in version.txt. A dev build of a release tag would make common.sh generate a new ID each time it is sourced by different processes. build_image sources common.sh first, and writes the resulting version string the OS image's os-release file. build_sysext runs later and also sources common.sh, leading its version check to fail as its own VERSION now differs from the version of the OS image it's supposed to generate sysexts for. This is usually desired behaviour since build_sysext regularly operates on pre-built OS images; only when run from sysext_prod_builder during an OS image build it doesn't.

This change reads BUILD_ID from the OS image rootfs in sysext_prod_builder and exports FLATCAR_BUILD_ID accordingly before calling build_sysext. Hence FLATCAR_BUILD_ID is not empty, so common.sh in build_sysext will not re-generate it.

How to use

Try to build a dev version of a release tag, e.g.

 git checkout alpha-3975.0.0
 ./build_packages
 ./build_image

./build_image will fail with build_sysext complaining about version mismatches. Base squashfs version and SDK board packages versions will have version ID timestamps that differ by a few minutes, e.g.

...
Base squashfs version: 3975.0.0+2024-06-24-1729
SDK board packages version: 3975.0.0+2024-06-24-1736
...
file build_sysext, line 197, called: die 'Version mismatch between board flatcar release and SDK container flatcar release.
...

Apply the patch from this branch, try again. Build now works.

Backports and cherry-picks

Should be cherry-picked to all maintenance branches that use build_sysext, i.e. at least alpha, beta, and stable, and possibly LTS.

@t-lo t-lo force-pushed the t-lo/fix-build-id-mismatch branch from 4da0276 to 50f21e5 Compare June 24, 2024 18:17
@t-lo t-lo temporarily deployed to development June 24, 2024 18:17 — with GitHub Actions Inactive
@t-lo t-lo force-pushed the t-lo/fix-build-id-mismatch branch from 50f21e5 to 1b66d7b Compare June 24, 2024 18:19
@t-lo t-lo temporarily deployed to development June 24, 2024 18:19 — with GitHub Actions Inactive
@t-lo
Copy link
Member Author

t-lo commented Jun 24, 2024

This was tested on alpha-3975, I hope it doesn't break main 😅

Copy link

github-actions bot commented Jun 24, 2024

@t-lo t-lo requested a review from a team June 24, 2024 18:25
Copy link
Member

@krnowak krnowak left a comment

Choose a reason for hiding this comment

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

Good grief, what a mess. Let's get this in.

This change fixes a version mismatch of FLATCAR_BUILD_ID when performing
a dev build of an existing release tag. The build ID is part of the
version string of dev builds, separated by a "+" from the main version.
If common.sh detects a dev build (COREOS_OFFICIAL != 1) and
FLATCAR_BUILD_ID is empty, common.sh will generate a new ID based on a
timestamp.

For official releases, FLATCAR_BUILD_ID is not set in version.txt. A dev
build of a release tag would make common.sh generate a new ID each time
it is sourced by different processes. build_image sources common.sh
first, and writes the resulting version string the OS image's
os-release file. build_sysext runs later and also sources common.sh,
leading its version check to fail as its own VERSION now differs from
the version of the OS image it's supposed to generate sysexts for.

This change reads BUILD_ID from the OS image rootfs in
sysext_prod_builder and exports FLATCAR_BUILD_ID accordingly before
calling build_sysext. Hence FLATCAR_BUILD_ID is not empty, so common.sh
in build_sysext will not re-generate it.

Signed-off-by: Thilo Fromm <[email protected]>
@t-lo t-lo force-pushed the t-lo/fix-build-id-mismatch branch from 1b66d7b to 361eda2 Compare June 25, 2024 09:44
@t-lo
Copy link
Member Author

t-lo commented Jun 25, 2024

Rebased to latest main (which re-set branch protection but I'm not going to re-run the whole build now)

@t-lo t-lo merged commit 83456ca into main Jun 25, 2024
1 check failed
t-lo added a commit that referenced this pull request Jun 25, 2024
sysext_prod_builder: fix build id mismatch
t-lo added a commit that referenced this pull request Jun 25, 2024
sysext_prod_builder: fix build id mismatch
@t-lo
Copy link
Member Author

t-lo commented Jun 25, 2024

Merged and backported to 4012 (Alpha), 3975 (Beta), and 3815 (Stable). LTS is still on torcx.

@t-lo t-lo deleted the t-lo/fix-build-id-mismatch branch June 25, 2024 10:17
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.

2 participants