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

spec: Add cached update metadata #248

Merged
merged 1 commit into from
Jan 15, 2024
Merged

Conversation

cgwalters
Copy link
Collaborator

In ostreedev/ostree-rs-ext#537 we added a facility to cache metadata (manifest+config) for container image updates with an eye for use in rpm-ostree.

The bootc update --check code here in bootc was also updated to use it; but we didn't really expose it back in the status.

This closes the gap, just bridging the cached update metadata into status. We want to do this as opposed to having bootc update --check grow its own API for example.

Copy link

openshift-ci bot commented Jan 2, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

In ostreedev/ostree-rs-ext#537 we
added a facility to cache metadata (manifest+config) for
container image updates with an eye for use in rpm-ostree.

The `bootc update --check` code here in bootc was also
updated to use it; but we didn't really expose it back in
the status.

This closes the gap, just bridging the cached update metadata
into status.  We want to do this as opposed to having
`bootc update --check` grow its own API for example.

Closes: containers#247

Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters
Copy link
Collaborator Author

This one needs some integration testing, which actually really wants us to improve our testing story in general.

@cgwalters
Copy link
Collaborator Author

Although looking at this more, while this was easy to write and works, I think it's ergonomically odd because it's associated with a boot entry (as is how it's implemented today on the ostree side). But logically I think what we have in staged should probably become more like this:

diff --git a/lib/src/spec.rs b/lib/src/spec.rs
index 78e73c2..94c25f6 100644
--- a/lib/src/spec.rs
+++ b/lib/src/spec.rs
@@ -106,12 +106,17 @@ pub enum HostType {
     BootcHost,
 }
 
+pub enum Update {
+    Checked(ImageStatus),
+    Staged(BootEntry),
+}
+
 /// The status of the host system
 #[derive(Debug, Clone, Serialize, Default, Deserialize, PartialEq, Eq, JsonSchema)]
 #[serde(rename_all = "camelCase")]
 pub struct HostStatus {
     /// The staged image for the next boot
-    pub staged: Option<BootEntry>,
+    pub staged: Option<Update>,
     /// The booted image; this will be unset if the host is not bootc compatible.
     pub booted: Option<BootEntry>,
     /// The previously booted image

@cgwalters cgwalters marked this pull request as ready for review January 12, 2024 18:46
@cgwalters
Copy link
Collaborator Author

Thinking about this a bit more, I think this is OK as is because it does make some sense to have a flow where:

$ bootc upgrade
<update is queued for existing container>
$ bootc switch quay.io/exampleos/otheros:latest
<new update is queued for different image>

Yet, there's no reason to logically toss away the cached update for the currently booted image.

@cgwalters cgwalters added the area/updates Related to upgrading between versions label Jan 12, 2024
@cgwalters
Copy link
Collaborator Author

To test this out:

  • run bootc with this code
  • run bootc upgrade --check
  • verify we have cached update in bootc status
  • push new update to registry
  • run bootc upgrade --check
  • verify we have new cached update in bootc status

@jeckersb jeckersb self-requested a review January 15, 2024 14:41
@jeckersb
Copy link
Contributor

LGTM. By means of starting this on Friday and finishing it this morning I got the bonus of having the upstream eln image update itself to test against that:

[root@localhost ~]# ./bootc upgrade --check
Update available for: ostree-unverified-registry:quay.io/centos-bootc/fedora-bootc-cloud:eln
  Version: 39.20240110.0
  Digest: sha256:77d80dab784f9c333fa289d9ff74d967a2147ac301b43803ab18185fd4f11e6d
Total new layers: 68    Size: 684.5 MB
Removed layers:   2     Size: 75.9 MB
Added layers:     2     Size: 75.9 MB
[root@localhost ~]# ./bootc status
note: The format of this API is not yet stable
apiVersion: org.containers.bootc/v1alpha1
kind: BootcHost
metadata:
  name: host
spec:
  image:
    image: quay.io/centos-bootc/fedora-bootc-cloud:eln
    transport: registry
status:
  staged: null
  booted:
    image:
      image:
        image: quay.io/centos-bootc/fedora-bootc-cloud:eln
        transport: registry
      version: 39.20240110.0
      timestamp: null
      imageDigest: sha256:23e6e34a370894901c6361516d670198ed8fda649f62265e4f00a7b80af1962a
    cachedUpdate:
      image:
        image: quay.io/centos-bootc/fedora-bootc-cloud:eln
        transport: registry
      version: 39.20240110.0
      timestamp: null
      imageDigest: sha256:77d80dab784f9c333fa289d9ff74d967a2147ac301b43803ab18185fd4f11e6d
    incompatible: false
    pinned: false
    ostree:
      checksum: ce6c0ac10d2f7600000889f952d43de672e78bbee658f788590cef121c3c9fe3
      deploySerial: 0
  rollback:
    image:
      image:
        image: quay.io/centos-bootc/fedora-bootc-cloud:eln
        transport: registry
      version: 39.20240110.0
      timestamp: null
      imageDigest: sha256:ec3a19fafe3a78c681f9a4ecd2b57bdd6382b1e467480e1d7e4e079061d57016
    cachedUpdate:
      image:
        image: quay.io/centos-bootc/fedora-bootc-cloud:eln
        transport: registry
      version: 39.20240110.0
      timestamp: null
      imageDigest: sha256:23e6e34a370894901c6361516d670198ed8fda649f62265e4f00a7b80af1962a
    incompatible: false
    pinned: false
    ostree:
      checksum: 86edeca31d16ca78ef9eae201164413c740e803ef2ff287bb1baff975394115f
      deploySerial: 0
  type: bootcHost

(weekend goes by...)

[root@localhost ~]# ./bootc upgrade --check
Update available for: ostree-unverified-registry:quay.io/centos-bootc/fedora-bootc-cloud:eln
  Version: 39.20240110.0
  Digest: sha256:90a3870bc6be2c41415fd71997d4e294037b809c58d19d4d899c5eb792566af9
Total new layers: 68    Size: 684.5 MB
Removed layers:   2     Size: 75.9 MB
Added layers:     2     Size: 75.9 MB
[root@localhost ~]# ./bootc status
note: The format of this API is not yet stable
apiVersion: org.containers.bootc/v1alpha1
kind: BootcHost
metadata:
  name: host
spec:
  image:
    image: quay.io/centos-bootc/fedora-bootc-cloud:eln
    transport: registry
status:
  staged: null
  booted:
    image:
      image:
        image: quay.io/centos-bootc/fedora-bootc-cloud:eln
        transport: registry
      version: 39.20240110.0
      timestamp: null
      imageDigest: sha256:23e6e34a370894901c6361516d670198ed8fda649f62265e4f00a7b80af1962a
    cachedUpdate:
      image:
        image: quay.io/centos-bootc/fedora-bootc-cloud:eln
        transport: registry
      version: 39.20240110.0
      timestamp: null
      imageDigest: sha256:90a3870bc6be2c41415fd71997d4e294037b809c58d19d4d899c5eb792566af9
    incompatible: false
    pinned: false
    ostree:
      checksum: ce6c0ac10d2f7600000889f952d43de672e78bbee658f788590cef121c3c9fe3
      deploySerial: 0
  rollback:
    image:
      image:
        image: quay.io/centos-bootc/fedora-bootc-cloud:eln
        transport: registry
      version: 39.20240110.0
      timestamp: null
      imageDigest: sha256:ec3a19fafe3a78c681f9a4ecd2b57bdd6382b1e467480e1d7e4e079061d57016
    cachedUpdate:
      image:
        image: quay.io/centos-bootc/fedora-bootc-cloud:eln
        transport: registry
      version: 39.20240110.0
      timestamp: null
      imageDigest: sha256:23e6e34a370894901c6361516d670198ed8fda649f62265e4f00a7b80af1962a
    incompatible: false
    pinned: false
    ostree:
      checksum: 86edeca31d16ca78ef9eae201164413c740e803ef2ff287bb1baff975394115f
      deploySerial: 0
  type: bootcHost

@jeckersb jeckersb merged commit 736c0e8 into containers:main Jan 15, 2024
10 checks passed
@jeckersb jeckersb removed their request for review January 15, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/updates Related to upgrading between versions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants