diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-04-09 14:38:34 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-04-14 11:47:04 +0200 |
commit | 1a02c9b40c75808791502a050cffb8d9b28b705b (patch) | |
tree | dde156e24528cbcfb3a566a242ca9752066b07a9 /pkg/autoupdate/autoupdate.go | |
parent | 5cf64aee11063bc8e7ff22f1365b0bf6b3ab0900 (diff) | |
download | podman-1a02c9b40c75808791502a050cffb8d9b28b705b.tar.gz podman-1a02c9b40c75808791502a050cffb8d9b28b705b.tar.bz2 podman-1a02c9b40c75808791502a050cffb8d9b28b705b.zip |
auto update: skip non-image policies
Fix a bug in the auto-update logic causing all images to be checked and
not only the ones of containers with the specific auto-update policy.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/autoupdate/autoupdate.go')
-rw-r--r-- | pkg/autoupdate/autoupdate.go | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go index 7c243eb00..78d5ac474 100644 --- a/pkg/autoupdate/autoupdate.go +++ b/pkg/autoupdate/autoupdate.go @@ -201,18 +201,25 @@ func imageContainersMap(runtime *libpod.Runtime) (map[string][]*libpod.Container if state != define.ContainerStateRunning { continue } + // Only update containers with the specific label/policy set. labels := ctr.Labels() - if value, exists := labels[Label]; exists { - policy, err := LookupPolicy(value) - if err != nil { - errors = append(errors, err) - continue - } - if policy != PolicyNewImage { - continue - } + value, exists := labels[Label] + if !exists { + continue } + + policy, err := LookupPolicy(value) + if err != nil { + errors = append(errors, err) + continue + } + + // Skip non-image labels (could be explicitly disabled). + if policy != PolicyNewImage { + continue + } + // Now we know that `ctr` is configured for auto updates. id, _ := ctr.Image() imageMap[id] = append(imageMap[id], allContainers[i]) |