Skip to content

Commit 9788fbf

Browse files
committed
fix: fix docker pull fallback when podman fails or is not being used
1 parent 6403819 commit 9788fbf

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pkg/container/container.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,14 +558,14 @@ func (c *ContainerClient) ImagePullWithRetries(ctx context.Context, imageRef str
558558

559559
// Note: ImagePull does not seem to return an error if the private registries authentication fails
560560
// so after pulling the image, check if it is loaded to confirm everything worked as expected
561-
useDockerPull := false
561+
useDockerPull := true
562562

563563
// try podman api first and but fallback to docker pull API fails
564564
// Note: Podman 4.4 was observed to have an issue pulling images via the docker API where the only reported error is:
565565
// "write /dev/stderr: input/output error"
566566
podmanLib := NewDefaultLibPodHTTPClient()
567567
if podmanLib.Test(ctx) == nil {
568-
slog.Info("Using podman API to pull image")
568+
slog.Info("Trying to pull image using podman API")
569569
libpodErr := podmanLib.PullImages(ctx, imageRef, alwaysPull, PodmanPullOptions{
570570
PullOptions: pullOptions,
571571
Quiet: false,
@@ -575,7 +575,9 @@ func (c *ContainerClient) ImagePullWithRetries(ctx context.Context, imageRef str
575575
// and a check for the image is done afterwards anyway
576576
if libpodErr != nil {
577577
slog.Warn("podman (libpod) pull images failed but error will be ignored.", "err", libpodErr)
578-
useDockerPull = true
578+
579+
} else {
580+
useDockerPull = false
579581
}
580582
}
581583

pkg/container/socket_client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,9 @@ func (c *SocketClient) PullImages(ctx context.Context, imageRef string, alwaysPu
154154
}
155155

156156
slog.Info("Podman API response was successful.", "status", r.Status)
157+
statusOK := r.StatusCode >= 200 && r.StatusCode < 400
158+
if !statusOK {
159+
return fmt.Errorf("podman api failed. code=%s", r.Status)
160+
}
157161
return nil
158162
}

0 commit comments

Comments
 (0)