Skip to content

Structured journal entries: MESSAGE_ID is stored as F_MESSAGE_ID, and most IDs are malformed or duplicated #2682

Backlog

Description

@fcuny

bootc's structured journal entries have three related problems:

  1. bootc never writes MESSAGE_ID. The journald layer prefixes every custom field with F_, so the documented journalctl MESSAGE_ID=... query for rollback matches nothing.
  2. 24 of the 29 *_ID constants are 33 hex characters. A valid sd-id128 is 32.
  3. Several IDs are shared by unrelated events, so a consumer filtering on one ID gets events it did not ask for.

I'd like to agree on a direction before sending a fix, because every option changes something consumers may already match on.

Reproduction

I built main at 487e949 with just build, booted it with bcvk libvirt run (ostree backend, bootc-202611230749.g487e949761-1.el10), and ran a real rollback. To get a rollback target without a second image, I redeployed the booted commit with its own origin file:

# csum=$(ostree admin status | awk '/^\* /{print $3}' | sed 's/\.[0-9]*$//')
# ostree admin deploy --os=default --origin-file=/ostree/deploy/default/deploy/$csum.0.origin $csum
# bootc rollback
# journalctl -o json MESSAGE_ID=26f3b1eb24464d12aa5e7b544a6b5468 | wc -l
0
# journalctl -o json F_MESSAGE_ID=26f3b1eb24464d12aa5e7b544a6b5468 | jq -c '{MESSAGE, F_MESSAGE_ID}'
{"MESSAGE":"Rolling back to image: sha256:6ead...","F_MESSAGE_ID":"26f3b1eb24464d12aa5e7b544a6b5468"}

A bootc switch entry shows the same pattern for every custom field: F_MESSAGE_ID, F_BOOTC_NEW_IMAGE_REFERENCE, F_BOOTC_NEW_IMAGE_TRANSPORT, F_BOOTC_OLD_IMAGE_REFERENCE. Only MESSAGE is unprefixed.

1. Custom fields carry an F_ prefix

initialize_tracing() builds the journald layer with tracing_journald::layer() and no further configuration (crates/utils/src/tracing_util.rs:10). In tracing-journald 0.3.2 (the version in Cargo.lock), Layer::new sets field_prefix: Some("F".into()). EventVisitor::put_prefix then writes F_ before every field except message. sanitize_name maps . to _ and uppercases.

So this call:

tracing::info!(message_id = ROLLBACK_JOURNAL_ID, bootc.foo = "x", "...");

produces F_MESSAGE_ID=... and F_BOOTC_FOO=x in the journal. It never produces MESSAGE_ID.

Impact:

  • The rollback docs tell users to match MESSAGE_ID=26f3b1eb24464d12aa5e7b544a6b5468 (crates/lib/src/cli.rs:1151, docs/src/man/bootc-rollback.8.md:20). That query returns no entries, even right after a rollback (see Reproduction).
  • journalctl -x and the message catalog key on MESSAGE_ID, so they ignore every bootc entry.
  • The tests disagree with the docs. test-composefs-corrupted-state-resilience.nu:52 queries F_MESSAGE_ID, which matches what bootc writes.
  • test-image-pushpull-upgrade.nu:90 queries _MESSAGE_ID=. Nothing writes that field: sanitize_name strips leading underscores, and journald drops _-prefixed fields sent by clients (confirmed with logger --journald on the same VM). The test does not inspect the output, so it cannot catch a missing entry.

2. Most IDs are not valid 128-bit IDs

grep -rnE '_ID: &str = "' crates/ finds 29 constants. 24 of them are 33 hex characters, for example DEPLOY_JOURNAL_ID = 9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b3. sd_id128_from_string() accepts 32 hex characters (or 36 with dashes), so it rejects all 24.

The values also follow a hand-typed descending pattern (...9c8d7e6f5a4b3c2d1e0f...) rather than coming from systemd-id128 new. Three of the five 32-character IDs also look hand-typed: SET_UNIFIED_CFS_JOURNAL_ID, SET_UNIFIED_JOURNAL_ID (image.rs:299, image.rs:409) and STAGE_JOURNAL_ID (deploy.rs:1260). Only ROLLBACK_JOURNAL_ID and STATUS_JOURNAL_ID look randomly generated.

Impact: journald stores the 33-character strings and exact-match queries still work. Any tool that parses MESSAGE_ID as an sd-id128, including the catalog, rejects them. Hand-picked values also lose the uniqueness guarantee, which is how problem 3 happened.

3. Unrelated events share IDs

Value Constants
6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0 PULLING_NEW_IMAGE_ID (deploy.rs:757, deploy.rs:981), INSTALL_FINALIZE_JOURNAL_ID (install.rs:3242)
7a6b5c4d3e2f1a0b9c8d7e6f5a4b3c2d1 SWITCH_JOURNAL_ID (cli.rs:1764), COMPOSEFS_SWITCH_JOURNAL_ID (bootc_composefs/switch.rs:87)
5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9 IMAGE_ALREADY_PRESENT_ID (deploy.rs:795, deploy.rs:966)

The first row is a real bug: bootc install finalize and an image pull log the same ID. The second row covers the same operation on two backends, but the two events carry different fields (bootc.old_image_reference/bootc.new_image_reference versus bootc.target_image/bootc.apply_mode). A consumer cannot rely on one field schema per ID. The third row is the same event in two code paths, which is probably intended.

BOUND_IMAGES_JOURNAL_ID (1a0b...8b7c6d5, boundimage.rs:43) also equals SET_UNIFIED_JOURNAL_ID plus one trailing 5. Truncating the 33-character values to 32 would therefore create a new collision.

Options

These are not exclusive. (c) applies whichever of (a) or (b) we pick.

(a) Drop the prefix with .with_field_prefix(None). bootc would write real MESSAGE_ID entries, and the documented query and the catalog would work.

  • Every existing field gets renamed (F_BOOTC_* becomes BOOTC_*). Anyone matching F_* today breaks silently.
  • Unprefixed fields can collide with journald's own fields. A tracing field named priority or syslog_identifier would override the real one. The prefix exists to prevent that, so we'd want a lint or review rule for field names.

(b) Keep the prefix and fix the docs and tests. Document F_MESSAGE_ID in the rollback man page and fix test-image-pushpull-upgrade.nu to query F_MESSAGE_ID and assert on the output.

  • Nothing that works today breaks.
  • bootc entries stay invisible to journalctl -x, the catalog, and any tooling that expects the standard MESSAGE_ID field.

(c) Regenerate invalid and duplicate IDs with systemd-id128 new. Give every distinct event its own valid ID, and consider one shared module for the constants so duplicates are visible in one place.

  • Consumers that already filter on an old ID stop matching. If we pick (a) as well, they break anyway, so doing both in one release limits the churn to one change.
  • ROLLBACK_JOURNAL_ID and STATUS_JOURNAL_ID are valid and unique, so they can keep their values.

My preference (opinion): (a) plus (c) in one release with a release note, since the IDs are already unusable by standard tooling. (b) is the low-risk fallback if we know of consumers matching F_*.

Related

  • bootc-dev/bootc#2681 adds bootc-log-boot.service for bootc-dev/bootc#452. It sidesteps this by calling libsystemd::logging::journal_send directly, so it writes a real MESSAGE_ID. crates/ostree-ext/src/logging.rs already uses the same approach.
  • The journald layer filters at INFO (tracing_util.rs:12). The three events logged with tracing::debug! and a message_id (IMAGE_ALREADY_PRESENT_ID twice and DEPLOY_JOURNAL_ID) never reach the journal.

Assisted-by: AI

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions