containers / bootc

Boot and upgrade via container images
https://containers.github.io/bootc/
Apache License 2.0
587 stars 74 forks source link

Add a human readable output for bootc status #408

Open mrguitar opened 6 months ago

mrguitar commented 6 months ago

Coming from rpm-ostree, I can quickly see & more importantly grok the output fromrpm-ostree status. bootc status has all the good stuff, but it takes much longer to wade through the output, and scroll up in the terminal, etc. Adding an option to boil it down like --pretty or --human, as Colin suggested, would really help speed me up and add better clarity for users. I can definitely see a kube admin preferring the existing output, so let's not lose that.

cgwalters commented 6 months ago

Yes totally! To give more color to this the current bootc design is very much influenced by the "imperative + DBus API" of rpm-ostree being tough to deal with for systems like the https://github.com/openshift/machine-config-operator/ that want to actually manage the system declaratively in a Kube-like style. IOW we want to support agents scripting, in the general case.

However we should totally have nice ergonomics for standalone agentless systems, and this is very much part of that. Labeling as good-first-issue.

lukewarmtemp commented 3 months ago

This is the current output for bootc status:

sudo ./bootc status
apiVersion: org.containers.bootc/v1alpha1
kind: BootcHost
metadata:
  name: host
spec:
  image:
    image: localhost:5000/fcos:latest
    transport: registry
  bootOrder: default
status:
  staged: null
  booted:
    image:
      image:
        image: localhost:5000/fcos:latest
        transport: registry
      version: 40.20240504.3.0
      timestamp: null
      imageDigest: sha256:2f7207cddc3b01ee0980a4c8152d1277e0a0b5fe0ebff27bcc5e9b101e08d7ce
    cachedUpdate: null
    incompatible: false
    pinned: false
    ostree:
      checksum: 05b704430628019881d929c204ad4293230dc34d7df962428268faf145be8ac7
      deploySerial: 0
  rollback:
    image:
      image:
        image: quay.io/luyang/fcos-karg-test2
        transport: registry
      version: 40.20240504.3.0
      timestamp: null
      imageDigest: sha256:d5d43c888d3017c19ee912714ce206716dd56564eea5818e5b2f32f6e74feae5
    cachedUpdate: null
    incompatible: false
    pinned: false
    ostree:
      checksum: 6f3d22c95edbd7257e5de1a6dcd88e31c4536031776230e4daa1629f679cc098
      deploySerial: 0
  rollbackQueued: false
  type: bootcHost

What information is most important to keep when making the human readable option?

miabbott commented 3 months ago

IMO, I would start with a similar output to what we have in rpm-ostree status

$ rpm-ostree status
State: idle
AutomaticUpdates: stage; rpm-ostreed-automatic.timer: last run 6h ago
Deployments:
  ostree-image-signed:docker://ghcr.io/miabbott/rh-meatwad:latest
                   Digest: sha256:1f1b95df8599e5a61ffbc6d8c118d0a16ee83a0adeae8e5303972df3abc5ee1b
                  Version: 40.20240605.0 (2024-06-05T17:08:06Z)
                     Diff: 232 upgraded, 1 removed, 2 added

● ostree-image-signed:docker://ghcr.io/miabbott/rh-meatwad:latest
                   Digest: sha256:5d709d78ae0054a10fb3eb8a6332d93c1598b6fc1effb5be2b32886a09a7dd22
                  Version: 40.20240521.0 (2024-05-21T15:48:42Z)

  ostree-image-signed:docker://ghcr.io/miabbott/rh-meatwad:latest
                   Digest: sha256:18d3d274ca7442613c7dd3f78ba80476dcc37f64a6851b37288730ee96f3e780
                  Version: 39.20240509.0 (2024-05-09T17:07:45Z)

From bootc status, I would capture the image name, the version, and the imageDigest and represent them for the booted and rollback deployments.

lukewarmtemp commented 3 months ago

We've been working through this issue in our weekly mobbing sessions and came across @cgwalters recent comment: https://github.com/containers/bootc/pull/602#issuecomment-2167838878. Originally, we were thinking of creating and printing a smaller yaml with the image name, the version, and the imageDigest. However, if we've interpreted the comment correctly, it might be better to just extract the fields and format them into a print statement?

A rough example:

if (opt.pretty) {
  println!("image name: {:?}", host.status.booted.image)
  println!("version: {:?}", host.status.booted.version)
}
image name: quay.io/luyang/fcos-karg-test2
   version: 40.20240504.3.0
cgwalters commented 3 months ago

Yes, though I think we should consider how to render important things like "you have a new image staged", etc.