Skip to content

Add journaling for image finalization and firstboot #452

Open

Description

@cgwalters

It'd be useful for auditing purposes for us to emit journal messages on at least the first time a particular deployment is booted, including substantial metadata (basically at least all the image stuff: pull spec, digest, version, etc.).

We might as well also do this as part of ostree-finalize-staged.service. Today these services run C code from libostree which is unaware of the container bits, so to fix this we could either patch that code to be aware of the container refs (or call into ostree container commands if available, i.e. we put the logic in ostree-ext?). But this conflicts a bit with us doing the podman pull backend, so instead we could add units here (triggered by our new generator?) that "hook" ostree-boot-complete.service and ostree-finalize-staged.service via drop-ins say.

Activity

  1. added
    enhancement
    area/updates
    on Apr 1, 2024
  2. fcuny commented on Nov 19, 2026

    @fcuny
    Contributor

    We'd like to implement this and want to agree on the shape first.

    Use case. We run composefs-backend nodes that never update or switch; we reinstall them instead. Nothing is ever staged on those nodes, so a hook in bootc-finalize-staged.service would never fire. bootc install also logs to the installer environment's journal, not the target's. Today the installed system has no journal record of the image it booted.

    Proposal. Record the image at boot, once per deployment:

    • A new unit (name TBD, e.g. bootc-record-boot.service), enabled by the generator next to the status units. It runs a new bootc internals record-boot after local-fs.target.
    • The command reads the booted deployment through the existing status code, so it works on both backends.
    • If /var/lib/bootc/booted/<deployment-id> doesn't exist, it emits one journal entry and creates that marker. /var is shared across deployments, so the entry fires after an install and again after each update. The same run removes markers for deployments that no longer exist.
    • The entry gets a new MESSAGE_ID and structured fields that follow the existing bootc.* convention: image reference with transport, image digest, version, build timestamp, architecture, backend, and deployment ID.

    We'd leave the finalize-time entry from the original description for a follow-up.

    Questions.

    1. Does a marker in /var/lib/bootc work for you? The deployment state directory sits under /sysroot, which is mounted read-only at that point.
    2. Should the first PR cover both backends, or composefs first?
  3. fcuny commented on Nov 23, 2026

    @fcuny
    Contributor

    To move this forward, we'll start with the composefs backend and open a draft PR. One change from my proposal above: drop the marker and log on every boot.

    Why every boot. A once-per-deployment entry is the least durable record. On our nodes it would fire once after install and then rotate out of the journal. An entry per boot keeps a recent record whatever the retention, and it removes the marker and its cleanup. It still answers "first boot" for anyone with enough history: take the earliest entry for a deployment ID.

    First PR.

    • bootc internals log-boot (name TBD) reads the booted deployment through get_composefs_status and emits one entry with a new MESSAGE_ID. Fields: image reference with transport, manifest digest, version, build timestamp, architecture, backend, and deployment ID (the composefs verity digest).
    • A oneshot unit, enabled by the generator on native composefs boots only, runs it after local-fs.target. It stays off the critical path, and a failure doesn't fail the boot.
    • ostree follows in a second PR. The command doesn't depend on the backend, so that PR widens the generator gate and adds tests.

    The finalize-time entry from the original description stays out of scope.

  4. fcuny commented on Nov 25, 2026

    @fcuny
    Contributor

    The composefs part landed in #2681. Every composefs boot now writes one entry with MESSAGE_ID=66797517e29842bfa048064146ec92c2; man bootc-log-boot.service lists the fields.

    What's left:

    • ostree. I'll send this as a follow-up PR. One correction to my plan above: log-boot reads composefs state directly, so ostree needs its own read path, not only a wider generator gate. BootedStorage::new on ostree also remounts /sysroot read-write and takes the sysroot lock, which a boot-time unit should avoid.
    • Finalize-time entry. The entry in bootc-finalize-staged.service from the original description is still out of scope for us. Should it stay on this issue, or move to its own?

    Separately, #2682 tracks the existing entries (rollback, switch, and so on): they write F_MESSAGE_ID instead of MESSAGE_ID. The new entry doesn't have that problem because it bypasses tracing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/updatesenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions