pkg/autoupdate: repull image if other containers failed

If two containers use the same image and one rolled back (i.e., tagged
the old image again), make sure to repull the image for the other
container.

Once an image has caused a rollback, it may be worth marking this image
as broken and not update any other container using it but that is
outside of the scope.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg 2022-08-02 17:32:38 +02:00
parent 2c999f1ecb
commit 13a8ebd09f
1 changed files with 3 additions and 1 deletions

View File

@ -54,8 +54,8 @@ var supportedPolicies = map[string]Policy{
type updater struct {
conn *dbus.Conn
idToImage map[string]*libimage.Image
unitToTasks map[string][]*task
options *entities.AutoUpdateOptions
unitToTasks map[string][]*task
updatedRawImages map[string]bool
runtime *libpod.Runtime
}
@ -278,6 +278,8 @@ func (u *updater) updateRegistry(ctx context.Context, task *task) (*entities.Aut
if err := task.image.Tag(rawImageName); err != nil {
return report, fmt.Errorf("falling back to previous image: %w", err)
}
u.updatedRawImages[rawImageName] = false
if err := u.restartSystemdUnit(ctx, task.container, task.unit); err != nil {
return report, fmt.Errorf("restarting unit with old image during fallback: %w", err)
}