From e55270a51ad40a8a0320b7b4d38216ea48619e5a Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 14 Jul 2025 14:31:59 +0200 Subject: [PATCH] podman auto-update: include container in invalid policy message I noticed recently when I made a typo that then auto-update errored but it did not tell me which container was incorrect so I had to check all containers myself. Include the container ID in the error to make it clear which container has the issue. Signed-off-by: Paul Holzinger --- pkg/autoupdate/autoupdate.go | 2 +- test/system/255-auto-update.bats | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go index e3c54a2667..5ab4ddd8a0 100644 --- a/pkg/autoupdate/autoupdate.go +++ b/pkg/autoupdate/autoupdate.go @@ -393,7 +393,7 @@ func (u *updater) assembleTasks(ctx context.Context) []error { } policy, err := LookupPolicy(value) if err != nil { - errs = append(errs, err) + errs = append(errs, fmt.Errorf("auto-updating container %q: %w", ctr.ID(), err)) continue } if policy == PolicyDefault { diff --git a/test/system/255-auto-update.bats b/test/system/255-auto-update.bats index f4de97e5d3..e916b90cbc 100644 --- a/test/system/255-auto-update.bats +++ b/test/system/255-auto-update.bats @@ -267,7 +267,7 @@ function _confirm_update() { _wait_service_ready container-$cname.service run_podman 125 auto-update - is "$output" ".*invalid auto-update policy.*" "invalid policy setup" + assert "$output" =~ 'auto-updating container "[0-9a-f]{64}": invalid auto-update policy "'"$fakevalue"'": valid policies are \["disabled" "image" "local" "registry"\]' "invalid policy setup" run_podman inspect --format "{{.Image}}" $cname is "$output" "$ori_image" "Image ID should not change" @@ -384,8 +384,7 @@ EOF # Exit code is expected, due to invalid 'fakevalue' run_podman 125 auto-update --rollback=false update_log=$output - is "$update_log" ".*invalid auto-update policy.*" "invalid policy setup" - is "$update_log" ".*Error: invalid auto-update policy.*" "invalid policy setup" + assert "$update_log" =~ '.*Error: auto-updating container "[0-9a-f]{64}": invalid auto-update policy.*' "invalid policy setup" local n_updated=$(grep -c 'Trying to pull' <<<"$update_log") is "$n_updated" "2" "Number of images updated from registry."