Skip to content

Commit 78f1ebb

Browse files
Merge pull request #17796 from vrothberg/au-errors
auto update: return restart error
2 parents 8bd9109 + ba141ad commit 78f1ebb

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

pkg/autoupdate/autoupdate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ func (u *updater) updateUnit(ctx context.Context, unit string, tasks []*task) []
203203

204204
// Jump to the next unit on successful update or if rollbacks are disabled.
205205
if updateError == nil || !u.options.Rollback {
206+
if updateError != nil {
207+
errors = append(errors, fmt.Errorf("restarting unit %s during update: %w", unit, updateError))
208+
}
206209
return errors
207210
}
208211

test/system/255-auto-update.bats

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,15 @@ function _confirm_update() {
171171
is "$output" ".* system auto-update"
172172

173173
since=$(date --iso-8601=seconds)
174-
run_podman auto-update --rollback=false --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
174+
run_podman '?' auto-update --rollback=false --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
175+
if [[ $status -ne 0 ]]; then
176+
echo "------------------------------------ SYSTEMCTL STATUS"
177+
systemctl status container-$cname.service
178+
echo "------------------------------------ JOURNALCAL LOGS"
179+
journalctl --unit container-$cname.service
180+
echo "------------------------------------"
181+
die "auto update failed with exit code $status: $output"
182+
fi
175183
is "$output" "Trying to pull.*" "Image is updated."
176184
is "$output" ".*container-$cname.service,quay.io/libpod/alpine:latest,true,registry.*" "Image is updated."
177185
run_podman events --filter type=system --since $since --stream=false
@@ -248,7 +256,15 @@ function _confirm_update() {
248256
run_podman auto-update --dry-run --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
249257
is "$output" ".*container-$cname.service,quay.io/libpod/localtest:latest,pending,local.*" "Image update is pending."
250258

251-
run_podman auto-update --rollback=false --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
259+
run_podman '?' auto-update --rollback=false --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
260+
if [[ $status -ne 0 ]]; then
261+
echo "------------------------------------ SYSTEMCTL STATUS"
262+
systemctl status container-$cname.service
263+
echo "------------------------------------ JOURNALCAL LOGS"
264+
journalctl --unit container-$cname.service
265+
echo "------------------------------------"
266+
die "auto update failed with exit code $status: $output"
267+
fi
252268
is "$output" ".*container-$cname.service,quay.io/libpod/localtest:latest,true,local.*" "Image is updated."
253269

254270
_confirm_update $cname $ori_image
@@ -353,6 +369,11 @@ EOF
353369
is "$n_updated" "2" "Number of images updated from registry."
354370

355371
for cname in "${!expect_update[@]}"; do
372+
echo "------------------------------------ SYSTEMCTL STATUS"
373+
systemctl status container-$cname.service
374+
echo "------------------------------------ JOURNALCAL LOGS"
375+
journalctl --unit container-$cname.service
376+
echo "------------------------------------"
356377
is "$update_log" ".*$cname.*" "container with auto-update policy image updated"
357378
# Just because podman says it fetched, doesn't mean it actually updated
358379
_confirm_update $cname $img_id

0 commit comments

Comments
 (0)