File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,15 +177,25 @@ fn check_previous_rollback() -> Result<bool> {
177177 . context ( "Failed to execute journalctl command to check rollback status" ) ?;
178178
179179 if !output. status . success ( ) {
180- log:: info!(
181- "No previous boot journal available (expected on first boot or systems with non-persistent journal). Skipping rollback check."
180+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
181+ // Check if failure is due to missing previous boot (expected on first boot)
182+ if stderr. contains ( "No journal boot entry found for the specified boot" ) {
183+ log:: info!(
184+ "No previous boot journal available (expected on first boot or systems with non-persistent journal). Skipping rollback check."
185+ ) ;
186+ return Ok ( false ) ;
187+ }
188+ // For other failures, return an error
189+ bail ! (
190+ "journalctl command failed with status: {}. stderr: {}" ,
191+ output. status,
192+ stderr. trim( )
182193 ) ;
183- return Ok ( false ) ;
184194 }
185195
186196 let journal_output = String :: from_utf8_lossy ( & output. stdout ) ;
187197
188- if journal_output. trim ( ) . is_empty ( ) {
198+ if journal_output. trim ( ) . is_empty ( ) || journal_output . contains ( "-- No entries --" ) {
189199 log:: debug!( "No rollback service logs found in previous boot" ) ;
190200 return Ok ( false ) ;
191201 }
Original file line number Diff line number Diff line change @@ -229,7 +229,7 @@ tee -a Containerfile >> /dev/null << EOF
229229RUN (dnf install -y 'dnf5-command(copr)' || dnf install -y 'dnf-command(copr)') && \
230230 dnf copr enable -y packit/fedora-iot-greenboot-rs-${PR_NUMBER} ${COPR_CHROOT} && \
231231 dnf clean metadata && \
232- dnf install -y greenboot greenboot-default-health-checks && \
232+ ( dnf reinstall -y greenboot greenboot-default-health-checks || dnf install -y greenboot greenboot-default-health-checks) && \
233233 systemctl enable greenboot-healthcheck.service
234234RUN sed -i "s/GREENBOOT_MAX_BOOT_ATTEMPTS=3/GREENBOOT_MAX_BOOT_ATTEMPTS=5/g" /etc/greenboot/greenboot.conf
235235RUN sed -i 's#DISABLED_HEALTHCHECKS=()#DISABLED_HEALTHCHECKS=("01_repository_dns_check.sh" "not_exit.sh")#g' /etc/greenboot/greenboot.conf
Original file line number Diff line number Diff line change @@ -229,7 +229,7 @@ tee -a Containerfile >> /dev/null << EOF
229229RUN (dnf install -y 'dnf5-command(copr)' || dnf install -y 'dnf-command(copr)') && \
230230 dnf copr enable -y packit/fedora-iot-greenboot-rs-${PR_NUMBER} ${COPR_CHROOT} && \
231231 dnf clean metadata && \
232- dnf install -y greenboot greenboot-default-health-checks && \
232+ ( dnf reinstall -y greenboot greenboot-default-health-checks || dnf install -y greenboot greenboot-default-health-checks) && \
233233 systemctl enable greenboot-healthcheck.service
234234RUN sed -i "s/GREENBOOT_MAX_BOOT_ATTEMPTS=3/GREENBOOT_MAX_BOOT_ATTEMPTS=5/g" /etc/greenboot/greenboot.conf
235235RUN sed -i 's#DISABLED_HEALTHCHECKS=()#DISABLED_HEALTHCHECKS=("01_repository_dns_check.sh" "not_exit.sh")#g' /etc/greenboot/greenboot.conf
Original file line number Diff line number Diff line change 167167 # case: check proper first boot handling
168168 - name : check greenboot-healthcheck handles first boot correctly
169169 block :
170- - name : get earliest boot ID
171- shell : journalctl --list-boots --no-pager | awk '$2 ~ /^[0-9a-f]{32}$/{print $2; exit}'
172- become : yes
173- register : first_boot_id
174- failed_when : first_boot_id.stdout | length == 0
175-
176170 - name : get greenboot-healthcheck log from first boot
177- command : " journalctl -b {{ first_boot_id.stdout }} -u greenboot-healthcheck.service --no-pager"
171+ command : " journalctl -b 1 -u greenboot-healthcheck.service --no-pager"
178172 become : yes
179173 register : result_healthcheck_first_boot
180174
181175 - assert :
182176 that :
183177 - " 'No previous boot journal available' in result_healthcheck_first_boot.stdout"
178+ fail_msg : " Expected first boot message not found"
179+ success_msg : " First boot correctly detected with appropriate message"
180+
181+ - assert :
182+ that :
184183 - " 'FALLBACK BOOT DETECTED!' not in result_healthcheck_first_boot.stdout"
185- fail_msg : " Expected first boot message not found or false rollback detection on first boot"
186- success_msg : " First boot correctly detected with appropriate message and no false rollback detection"
184+ fail_msg : " False rollback detection on first boot"
185+ success_msg : " No false rollback detection on first boot "
187186
188187 always :
189188 - set_fact :
Original file line number Diff line number Diff line change 7474 # case: check proper first boot handling
7575 - name : check greenboot-healthcheck handles first boot correctly
7676 block :
77- - name : get earliest boot ID
78- shell : journalctl --list-boots --no-pager | awk '$2 ~ /^[0-9a-f]{32}$/{print $2; exit}'
79- become : yes
80- register : first_boot_id
81- failed_when : first_boot_id.stdout | length == 0
82-
8377 - name : get greenboot-healthcheck log from first boot
84- command : " journalctl -b {{ first_boot_id.stdout }} -u greenboot-healthcheck.service --no-pager"
78+ command : " journalctl -b 1 -u greenboot-healthcheck.service --no-pager"
8579 become : yes
8680 register : result_healthcheck_first_boot
8781
8882 - assert :
8983 that :
9084 - " 'No previous boot journal available' in result_healthcheck_first_boot.stdout"
85+ fail_msg : " Expected first boot message not found"
86+ success_msg : " First boot correctly detected with appropriate message"
87+
88+ - assert :
89+ that :
9190 - " 'FALLBACK BOOT DETECTED!' not in result_healthcheck_first_boot.stdout"
92- fail_msg : " Expected first boot message not found or false rollback detection on first boot"
93- success_msg : " First boot correctly detected with appropriate message and no false rollback detection"
91+ fail_msg : " False rollback detection on first boot"
92+ success_msg : " No false rollback detection on first boot "
9493
9594 always :
9695 - set_fact :
You can’t perform that action at this time.
0 commit comments