Skip to content

update_agent: support rebase to OCI pullspec#1241

Merged
jbtrystram merged 6 commits intocoreos:mainfrom
jbtrystram:oci_scheme
Feb 27, 2025
Merged

update_agent: support rebase to OCI pullspec#1241
jbtrystram merged 6 commits intocoreos:mainfrom
jbtrystram:oci_scheme

Conversation

@jbtrystram
Copy link
Member

Add a configuration knob in update to optionnaly use OCI pullspec instead of ostree checksums.

This will default to false.
Requires coreos/fedora-coreos-cincinnati#99 and coreos/rpm-ostree#5120

@jbtrystram jbtrystram force-pushed the oci_scheme branch 2 times, most recently from f0713e1 to 1ca8a87 Compare December 4, 2024 14:18
@jbtrystram jbtrystram changed the title update_agent: support rebaseing to OCI pullspec update_agent: support rebase to OCI pullspec Dec 4, 2024
Copy link
Member

@travier travier left a comment

Choose a reason for hiding this comment

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

Very quick look but looks good 👍🏻

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Let's cross-link to coreos/fedora-coreos-tracker#1823 in the commit message for the larger context.

@jbtrystram jbtrystram force-pushed the oci_scheme branch 4 times, most recently from 11aa880 to 7000352 Compare December 16, 2024 13:51
Copy link
Member Author

@jbtrystram jbtrystram left a comment

Choose a reason for hiding this comment

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

I updated this to use ostree-remote-image so we validate the ostree signatures, as suggested in coreos/fedora-coreos-tracker#1823 (comment)

I think this is ready for review now. I will clean up and sqash commits once the design is agreed

@jbtrystram
Copy link
Member Author

OK, had some more discussion with Jlebon and travier today and there are some more things to flesh out

@jbtrystram jbtrystram marked this pull request as draft January 13, 2025 14:36
@jbtrystram
Copy link
Member Author

jbtrystram commented Jan 15, 2025

Allright, I think this is ready for review now. I highlighted a couple of things I am unsure of.
I will squash the commits after addressing review comments

@jbtrystram jbtrystram marked this pull request as ready for review January 15, 2025 17:20
jbtrystram added a commit to jbtrystram/fedora-coreos-config that referenced this pull request Jan 23, 2025
Switch boot images to use OCI for updates. This is a step towards
bootable containers support and bootc rebase.

See https://fedoraproject.org/wiki/Changes/CoreOSOstree2OCIUpdates
Requires coreos/zincati#1241
See coreos/fedora-coreos-tracker#1823
@jbtrystram jbtrystram force-pushed the oci_scheme branch 2 times, most recently from add9bf7 to c5e0459 Compare January 24, 2025 10:59
// get the latest commit but that would be racy, so let's finalize the latest
// commit.
if release.is_oci {
cmd.arg("--allow-missing-checksum")
Copy link
Member

Choose a reason for hiding this comment

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

I think probably the cleaner thing is to have rpm-ostree accept a digested pullspec the way it accepts commit checksums and it can verify that it matches the digested pullspec that was staged. Then we can drop this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, definitely, but that requires work in rpm-ostree, let's not block on it ?

@jbtrystram
Copy link
Member Author

Allright, I reworked this PR a bunch following the review comments, that ended up being pretty substantial changes.

Overview :

  • A local deployment is now unserialized with an enum containing either a Checksum or a Pullspec. Both are simply strings, but I use that to match my way around, rather than a is_oci boolean.
  • custom-origin fields are now purely cosmetic : Zincati will cue from the container-image-reference.
  • Now properly parses the OCI manifest output from rpm-ostree --json and get the fedora-coreos.stream key from that. This is working around rpm-ostree status --json does not properly serialize ostree.manifest for OCI deployments rpm-ostree#5196
  • imported a couple of new crates : oci-spec for the above issue and ostree-rs to properly parse ostree image references and containers pull specs. I removed the hacky split(':') and split(":sha256")` in favor of that.

Testing

Here are my notes to test this out it case someone wants to experiment:

Start a VM with Zincati disabled : cosa run --qemu-image fedora-coreos-41.20241215.2.0-qemu.x86_64.qcow2 --add-ignition noautoupdate

Rebase to an OCI image in graph (recent enough to get rpm-ostree-2024.9) :

    sudo rpm-ostree rebase ostree-remote-image:fedora:registry:quay.io/fedora/fedora-coreos@sha256:74448159fae255797012a12eaf9089ea3c1018ffb0b3e76e03483cba59b50bb2 \
     --custom-origin-url=quay.io/fedora/fedora-coreos@sha256:74448159fae255797012a12eaf9089ea3c1018ffb0b3e76e03483cba59b50bb2 \
     --custom-origin-description="Fedora CoreOS testing stream"
     sudo reboot

Now import Zincati build with this PR then:

    sudo rm /etc/zincati/config.d/90-disable-auto-updates.toml
    sudo systemctl restart zincati

Zincati should now pick up an OCI update through the OCI graph

Getting zincati custom build in the COSA VM

While we can make a custom FCOS build with an override to get our Zincati build inside, it will be erased by the content of the OCI image with a rebase, so here is how I did, after building zincati and copy the binary into $COSA_DIR/tmp

rpm-ostree usroverlay
cp /mnt/workdir-tmp/zincati /usr/libexec/zincati
cp /mnt/workdir-tmp/zincati.rules /usr/share/polkit-1/rules.d/zincati.rules

# restart polkit
systemctl restart polkit.service

# re enable updates
rm /etc/zincati/config.d/90-disable-auto-updates.toml

# restart zincati
systemctl restart zincati.service

# Show the update
journalctl --no-pager -o cat -u zincati --follow

In the meantime, I'll squash this and try to make commits that make sense :)

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

To be clear again though, this will make #498 much more visible once we switch over to this. Ideally, we fix that wart before switching production nodes over.

OK, whipped up #1259 for now.

@jbtrystram
Copy link
Member Author

Ok I just re-did the testing, OCI and regular OSTree updates works as expected.
I think we are good to merge this if there are no further comments on the code

@jbtrystram jbtrystram force-pushed the oci_scheme branch 3 times, most recently from 20f465a to 1eddd79 Compare February 27, 2025 11:28
@jbtrystram jbtrystram force-pushed the oci_scheme branch 2 times, most recently from 3519a37 to 950aa08 Compare February 27, 2025 15:05
Add support for local OCI deployements, no longer erroring out.

Use the `ostree-ext` crate to parse the ostree image reference properly.
This will allow zincati to query the OCI graph and rebase to OCI images
for updates.

Also change the base-commit-meta object to support the OCI case where
this is actually an escaped serialized OCI manifest.
Use the `oci-spec` crate to deserialize it and extract the Fedora CoreOS
stream info from the base OCI annotations.
This works around coreos/rpm-ostree#5196
Local deployements are now unserialized with a enum being either
`Checksum` or `Pullspec`.
This will cue the cincinnati client to request the OCI graph in the
pullspec case. [1]

The custom-origin-description, if set, is passed along the rebase
call, and the custom-url is updated to match the new pullspec. [2]

Finally, update the polkit policy to allow Zincati
to do a rebase operation.

[1] Requires coreos/fedora-coreos-cincinnati#99
and coreos/rpm-ostree#5120
In the previous implementation, we finalize what's staged without knowing
because rpm-ostree deploy does not returns the staged commit.
Let's query the deployments and get the checksum that matches the
pullspec we have in the update payload.
When going through the update graph, Zincati searches for a node that
matches the current deployement, as the starting point for the update.

If the graph does not contains a matching node, zincati errors silently.
While this should almost never happen, it's useful to print a warning to
explain the situation if we hit that case.
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Nice work!

in 32d76f6 we added ostree bindings to
parse image references, which in turn requires glib-devel
dependencies to build.

Let's use the fcos-buildroot container to run the CI so we have to
maintain the correct set of dependencies in one place.
@jbtrystram
Copy link
Member Author

I just pushed because of an earlier unfortunate cargo update that ran into #1176
Now there should not be any changes in the lockfile other than what was added with ostree :)

@jlebon
Copy link
Member

jlebon commented Feb 27, 2025

I just pushed because of an earlier unfortunate cargo update that ran into #1176

Opened #1260 for that one. Let's try to get the dependency bumps into this release.

@jbtrystram jbtrystram enabled auto-merge February 27, 2025 16:17
@jbtrystram jbtrystram merged commit 293df0f into coreos:main Feb 27, 2025
8 checks passed
dustymabe pushed a commit to dustymabe/fedora-coreos-config that referenced this pull request Mar 13, 2025
Switch boot images to use OCI for updates. This is a step towards
bootable containers support and bootc rebase.

See https://fedoraproject.org/wiki/Changes/CoreOSOstree2OCIUpdates
Requires coreos/zincati#1241
See coreos/fedora-coreos-tracker#1823
dustymabe pushed a commit to coreos/fedora-coreos-config that referenced this pull request Mar 14, 2025
Switch boot images to use OCI for updates. This is a step towards
bootable containers support and bootc rebase.

See https://fedoraproject.org/wiki/Changes/CoreOSOstree2OCIUpdates
Requires coreos/zincati#1241
See coreos/fedora-coreos-tracker#1823
dustymabe pushed a commit to coreosbot-releng/fedora-coreos-config that referenced this pull request Mar 17, 2025
Switch boot images to use OCI for updates. This is a step towards
bootable containers support and bootc rebase.

See https://fedoraproject.org/wiki/Changes/CoreOSOstree2OCIUpdates
Requires coreos/zincati#1241
See coreos/fedora-coreos-tracker#1823
dustymabe pushed a commit to dustymabe/fedora-coreos-config that referenced this pull request Mar 17, 2025
Switch boot images to use OCI for updates. This is a step towards
bootable containers support and bootc rebase.

See https://fedoraproject.org/wiki/Changes/CoreOSOstree2OCIUpdates
Requires coreos/zincati#1241
See coreos/fedora-coreos-tracker#1823
dustymabe pushed a commit to coreos/fedora-coreos-config that referenced this pull request Mar 18, 2025
Switch boot images to use OCI for updates. This is a step towards
bootable containers support and bootc rebase.

See https://fedoraproject.org/wiki/Changes/CoreOSOstree2OCIUpdates
Requires coreos/zincati#1241
See coreos/fedora-coreos-tracker#1823
jbtrystram added a commit to jbtrystram/fedora-coreos-config that referenced this pull request Mar 28, 2025
To simplify testing for coreos/fedora-coreos-tracker#1823
This script write a Zincati status override containing a fake rpm-ostree
status output to appear like it's on an OCI deployement.

Zincati will look under the well-known path of /run/zincati/booted-status-override.json.
The content will trigger the OCI code path in Zincati.

This will later run as ExecStartPre in the zincati.service environment

Just ship the migration script for now, without the zincati service
changes, to allow testing.

See coreos/fedora-coreos-tracker#1890
See coreos/fedora-coreos-tracker#1823 (comment)
Requires zincati 0.0.30
Ref coreos/zincati#1273
Ref coreos/zincati#1241
jbtrystram added a commit to jbtrystram/fedora-coreos-config that referenced this pull request Apr 9, 2025
To simplify testing for coreos/fedora-coreos-tracker#1823
This script write a Zincati status override containing a fake rpm-ostree
status output to appear like it's on an OCI deployement.

Zincati will look under the well-known path of /run/zincati/booted-status-override.json.
The content will trigger the OCI code path in Zincati.

This will later run as ExecStartPre in the zincati.service environment

Just ship the migration script for now, without the zincati service
changes, to allow testing.

See coreos/fedora-coreos-tracker#1890
See coreos/fedora-coreos-tracker#1823 (comment)
Requires zincati 0.0.30
Ref coreos/zincati#1273
Ref coreos/zincati#1241
dustymabe pushed a commit to coreos/fedora-coreos-config that referenced this pull request Apr 9, 2025
To simplify testing for coreos/fedora-coreos-tracker#1823
This script write a Zincati status override containing a fake rpm-ostree
status output to appear like it's on an OCI deployement.

Zincati will look under the well-known path of /run/zincati/booted-status-override.json.
The content will trigger the OCI code path in Zincati.

This will later run as ExecStartPre in the zincati.service environment

Just ship the migration script for now, without the zincati service
changes, to allow testing.

See coreos/fedora-coreos-tracker#1890
See coreos/fedora-coreos-tracker#1823 (comment)
Requires zincati 0.0.30
Ref coreos/zincati#1273
Ref coreos/zincati#1241
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