summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorValentin Rothberg <vrothberg@redhat.com>2022-08-03 16:12:48 +0200
committerValentin Rothberg <vrothberg@redhat.com>2022-08-04 13:07:58 +0200
commit43cca5d97a2c971f3386099d6b66250a1ebad96f (patch)
treeed54482e6f3ddb5917bb817bd53f3c43f89f39db /pkg
parent0df51bb6bccc4e3598db59ea1bf389a97d7019e4 (diff)
downloadpodman-43cca5d97a2c971f3386099d6b66250a1ebad96f.tar.gz
podman-43cca5d97a2c971f3386099d6b66250a1ebad96f.tar.bz2
podman-43cca5d97a2c971f3386099d6b66250a1ebad96f.zip
pkg/autoupdate: decompose the update logic
Decompose the update logic into smaller steps (update check, update, rollback, etc.) and move the implementation into the `task` API. This allows to transition a task from state to state, independent of its underlying auto-update policy. Supporting more than one container per unit is now really close. [NO NEW TESTS NEEDED] - should not change behavior. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/autoupdate/autoupdate.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go
index f450a4233..b3f0c53eb 100644
--- a/pkg/autoupdate/autoupdate.go
+++ b/pkg/autoupdate/autoupdate.go
@@ -182,6 +182,10 @@ func AutoUpdate(ctx context.Context, runtime *libpod.Runtime, options entities.A
for _, task := range tasks {
err := func() error {
+ // Transition from state to state. Will be
+ // split into multiple loops in the future to
+ // support more than one container/task per
+ // unit.
updateAvailable, err := task.updateAvailable(ctx)
if err != nil {
task.status = statusFailed
@@ -298,8 +302,11 @@ func (t *task) registryUpdate(ctx context.Context) error {
return nil
}
- if err := pullImage(ctx, t.auto.runtime, t.rawImageName, t.authfile); err != nil {
- return fmt.Errorf("registry auto-updating container %q: image update for %q failed: %w", t.container.ID(), t.rawImageName, err)
+ pullOptions := &libimage.PullOptions{}
+ pullOptions.AuthFilePath = t.authfile
+ pullOptions.Writer = os.Stderr
+ if _, err := t.auto.runtime.LibimageRuntime().Pull(ctx, t.rawImageName, config.PullPolicyAlways, pullOptions); err != nil {
+ return err
}
t.auto.updatedRawImages[t.rawImageName] = true
@@ -448,13 +455,3 @@ func (u *updater) assembleImageMap(ctx context.Context) (map[string]*libimage.Im
return imageMap, nil
}
-
-// pullImage pulls the specified image.
-func pullImage(ctx context.Context, runtime *libpod.Runtime, name, authfile string) error {
- pullOptions := &libimage.PullOptions{}
- pullOptions.AuthFilePath = authfile
- pullOptions.Writer = os.Stderr
-
- _, err := runtime.LibimageRuntime().Pull(ctx, name, config.PullPolicyAlways, pullOptions)
- return err
-}