Skip to content

fix: avoid misleading journalctl warning in logs on first boot#190

Open
sarmahaj wants to merge 1 commit into
fedora-iot:mainfrom
sarmahaj:fix-first-boot-warning
Open

fix: avoid misleading journalctl warning in logs on first boot#190
sarmahaj wants to merge 1 commit into
fedora-iot:mainfrom
sarmahaj:fix-first-boot-warning

Conversation

@sarmahaj

@sarmahaj sarmahaj commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Use systemd-analyze condition ConditionFirstBoot=yes to detect first boot before querying the previous boot journal. This prevents a misleading warning on first boot when journalctl -b -1 fails because there is no prior boot. This also works correctly on systems with non-persistent journald storage.

@sarmahaj
sarmahaj requested a review from say-paul July 10, 2026 14:33

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a check in src/main.rs to verify if a previous boot exists using journalctl --list-boots before attempting to query the journal for the previous boot (-b -1). This prevents errors on systems during their first boot. The review feedback suggests optimizing the check for the number of boots by using .nth(1).is_none() instead of counting all lines, which avoids unnecessary iteration over the entire command output.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/main.rs Outdated
@sarmahaj
sarmahaj force-pushed the fix-first-boot-warning branch from de51ed4 to e0432e6 Compare July 10, 2026 14:41
@sarmahaj

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds a check to verify if a previous boot exists using journalctl --list-boots before querying its journal, skipping the rollback check if no previous boot is found. It also improves a log message format. The feedback suggests inverting the success check for journalctl --list-boots to return early on failure, which reduces nesting and improves readability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/main.rs Outdated
@say-paul

Copy link
Copy Markdown
Member

LGTM, I like gemini comment that prevents the use of else .

@say-paul

Copy link
Copy Markdown
Member

Can we do the implementation of checking if its a first time boot of the system only, systemd should provide such info, as i think system with non-persistent journald will skip the rollback check everytime without reporting error.

@knecasov knecasov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I added a few comments and gave a thumbs-up to the Gemini note.

Comment thread src/main.rs Outdated
Comment thread src/main.rs Outdated
Comment thread src/main.rs Outdated
@sarmahaj
sarmahaj force-pushed the fix-first-boot-warning branch from e0432e6 to 3511b80 Compare July 20, 2026 12:17
@sarmahaj

Copy link
Copy Markdown
Contributor Author

Can we do the implementation of checking if its a first time boot of the system only, systemd should provide such info, as i think system with non-persistent journald will skip the rollback check everytime without reporting error.

@say-paul Thanks for suggesting !
ptal at the recent commit ,implememts systemd based check for detecting firstboot

@sarmahaj
sarmahaj requested a review from knecasov July 20, 2026 12:28
mcattamoredhat
mcattamoredhat previously approved these changes Jul 20, 2026

@mcattamoredhat mcattamoredhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

knecasov
knecasov previously approved these changes Jul 20, 2026

@knecasov knecasov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, I would only recommend editing the PR description to reflect the final implementation.

Comment thread src/main.rs Outdated
@sarmahaj
sarmahaj dismissed stale reviews from knecasov and mcattamoredhat via abc7f15 July 21, 2026 09:13
@sarmahaj
sarmahaj force-pushed the fix-first-boot-warning branch from 3511b80 to abc7f15 Compare July 21, 2026 09:13
@sarmahaj

sarmahaj commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for review and approval @mcattamoredhat and @knecasov . Applied changes suggested by you @knecasov Thanks!

knecasov
knecasov previously approved these changes Jul 21, 2026

@knecasov knecasov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you so much for fixes! The PR description looks good now - only the formatting seems to be broken.

Anyway, it is not blocking merging, so I am approving it!

Comment thread src/main.rs
Fixes misleading warning on first boot and on systems with
non-persistent journald storage.

Signed-off-by: Sarita Mahajan <sarmahaj@redhat.com>

@knecasov knecasov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM.

@mcattamoredhat mcattamoredhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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.

4 participants