Skip to content
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

auto update: return restart error #17796

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/autoupdate/autoupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ func (u *updater) updateUnit(ctx context.Context, unit string, tasks []*task) []

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

Expand Down
25 changes: 23 additions & 2 deletions test/system/255-auto-update.bats
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ function _confirm_update() {
is "$output" ".* system auto-update"

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

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

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

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