-
Notifications
You must be signed in to change notification settings - Fork 15
fix: avoid misleading journalctl warning in logs on first boot #190
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -119,6 +119,28 @@ | |||||||||||
| set_fact: | ||||||||||||
| failed_counter: "{{ failed_counter | int + 1 }}" | ||||||||||||
|
|
||||||||||||
| # case: check rollback detection still works on non-first boot | ||||||||||||
| - name: check rollback detection works correctly on non-first boot | ||||||||||||
| block: | ||||||||||||
| - name: get greenboot-healthcheck log from current boot (post-rollback) | ||||||||||||
| command: journalctl -b -0 -u greenboot-healthcheck.service --no-pager | ||||||||||||
| become: yes | ||||||||||||
| register: result_healthcheck_post_rollback | ||||||||||||
|
|
||||||||||||
| - assert: | ||||||||||||
| that: | ||||||||||||
| - "'FALLBACK BOOT DETECTED!' in result_healthcheck_post_rollback.stdout" | ||||||||||||
| fail_msg: "Rollback detection failed on non-first boot" | ||||||||||||
| success_msg: "Rollback correctly detected on non-first boot" | ||||||||||||
|
|
||||||||||||
| always: | ||||||||||||
| - set_fact: | ||||||||||||
| total_counter: "{{ total_counter | int + 1 }}" | ||||||||||||
| rescue: | ||||||||||||
| - name: failed count + 1 | ||||||||||||
| set_fact: | ||||||||||||
| failed_counter: "{{ failed_counter | int + 1 }}" | ||||||||||||
|
|
||||||||||||
| # case: check greenboot-set-rollback-trigger log at first boot | ||||||||||||
| - name: check greenboot-set-rollback-trigger at first boot | ||||||||||||
| block: | ||||||||||||
|
|
@@ -142,6 +164,35 @@ | |||||||||||
| set_fact: | ||||||||||||
| failed_counter: "{{ failed_counter | int + 1 }}" | ||||||||||||
|
|
||||||||||||
| # case: check proper first boot handling | ||||||||||||
| - name: check greenboot-healthcheck handles first boot correctly | ||||||||||||
| block: | ||||||||||||
| - name: get earliest boot ID | ||||||||||||
| shell: journalctl --list-boots --no-pager | awk '$2 ~ /^[0-9a-f]{32}$/{print $2; exit}' | ||||||||||||
| become: yes | ||||||||||||
| register: first_boot_id | ||||||||||||
|
sarmahaj marked this conversation as resolved.
|
||||||||||||
| failed_when: first_boot_id.stdout | length == 0 | ||||||||||||
|
Comment on lines
+170
to
+174
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Not needed, see below |
||||||||||||
|
|
||||||||||||
| - name: get greenboot-healthcheck log from first boot | ||||||||||||
| command: "journalctl -b {{ first_boot_id.stdout }} -u greenboot-healthcheck.service --no-pager" | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
From |
||||||||||||
| become: yes | ||||||||||||
| register: result_healthcheck_first_boot | ||||||||||||
|
|
||||||||||||
| - assert: | ||||||||||||
| that: | ||||||||||||
| - "'No previous boot journal available' in result_healthcheck_first_boot.stdout" | ||||||||||||
| - "'FALLBACK BOOT DETECTED!' not in result_healthcheck_first_boot.stdout" | ||||||||||||
| fail_msg: "Expected first boot message not found or false rollback detection on first boot" | ||||||||||||
| success_msg: "First boot correctly detected with appropriate message and no false rollback detection" | ||||||||||||
|
Comment on lines
+181
to
+186
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would separate this into two different asserts |
||||||||||||
|
|
||||||||||||
| always: | ||||||||||||
| - set_fact: | ||||||||||||
| total_counter: "{{ total_counter | int + 1 }}" | ||||||||||||
| rescue: | ||||||||||||
| - name: failed count + 1 | ||||||||||||
| set_fact: | ||||||||||||
| failed_counter: "{{ failed_counter | int + 1 }}" | ||||||||||||
|
|
||||||||||||
| # case: check greenboot-set-rollback-trigger log at boot after upgrade | ||||||||||||
| - name: check greenboot-set-rollback-trigger at boot after upgrade | ||||||||||||
| block: | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,6 +71,35 @@ | |||||
| set_fact: | ||||||
| failed_counter: "{{ failed_counter | int + 1 }}" | ||||||
|
|
||||||
| # case: check proper first boot handling | ||||||
| - name: check greenboot-healthcheck handles first boot correctly | ||||||
| block: | ||||||
| - name: get earliest boot ID | ||||||
| shell: journalctl --list-boots --no-pager | awk '$2 ~ /^[0-9a-f]{32}$/{print $2; exit}' | ||||||
| become: yes | ||||||
| register: first_boot_id | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding |
||||||
| failed_when: first_boot_id.stdout | length == 0 | ||||||
|
Comment on lines
+77
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, see above |
||||||
|
|
||||||
| - name: get greenboot-healthcheck log from first boot | ||||||
| command: "journalctl -b {{ first_boot_id.stdout }} -u greenboot-healthcheck.service --no-pager" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| become: yes | ||||||
| register: result_healthcheck_first_boot | ||||||
|
|
||||||
| - assert: | ||||||
| that: | ||||||
| - "'No previous boot journal available' in result_healthcheck_first_boot.stdout" | ||||||
| - "'FALLBACK BOOT DETECTED!' not in result_healthcheck_first_boot.stdout" | ||||||
| fail_msg: "Expected first boot message not found or false rollback detection on first boot" | ||||||
| success_msg: "First boot correctly detected with appropriate message and no false rollback detection" | ||||||
|
Comment on lines
+88
to
+93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||||||
|
|
||||||
| always: | ||||||
| - set_fact: | ||||||
| total_counter: "{{ total_counter | int + 1 }}" | ||||||
| rescue: | ||||||
| - name: failed count + 1 | ||||||
| set_fact: | ||||||
| failed_counter: "{{ failed_counter | int + 1 }}" | ||||||
|
|
||||||
| - name: check /boot mount status | ||||||
| shell: findmnt -r -o OPTIONS -n /boot | awk -F "," '{print $1}' | ||||||
| register: result_boot_mount_before | ||||||
|
|
@@ -212,6 +241,29 @@ | |||||
| failed_counter: "{{ failed_counter | int + 1 }}" | ||||||
| when: result_rollback is defined and result_rollback is succeeded | ||||||
|
|
||||||
| # case: check rollback detection still works on non-first boot | ||||||
| - name: check rollback detection works correctly on non-first boot | ||||||
| block: | ||||||
| - name: get greenboot-healthcheck log from current boot (post-rollback) | ||||||
| command: journalctl -b -0 -u greenboot-healthcheck.service --no-pager | ||||||
| become: yes | ||||||
| register: result_healthcheck_post_rollback | ||||||
|
|
||||||
| - assert: | ||||||
| that: | ||||||
| - "'FALLBACK BOOT DETECTED!' in result_healthcheck_post_rollback.stdout" | ||||||
| fail_msg: "Rollback detection failed on non-first boot" | ||||||
| success_msg: "Rollback correctly detected on non-first boot" | ||||||
|
|
||||||
| always: | ||||||
| - set_fact: | ||||||
| total_counter: "{{ total_counter | int + 1 }}" | ||||||
| rescue: | ||||||
| - name: failed count + 1 | ||||||
| set_fact: | ||||||
| failed_counter: "{{ failed_counter | int + 1 }}" | ||||||
| when: result_rollback is defined and result_rollback is succeeded | ||||||
|
|
||||||
| # case: check boot-complete.target status | ||||||
| - name: boot-complete.target should be active | ||||||
| block: | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change assumes that journalctl fails because there is no previous journal, without verifying that the command's stderr starts with "No journal boot entry found for the specified boot". It should instead return Ok(false) for that specific case, and Err(...) for any other failure.