Skip to content

Commit

Permalink
Don't error when image pull fails and image exists:
Browse files Browse the repository at this point in the history
HookOS recently got the capability to embed container
images. With this capability, pulling an image is not
desired. This is expecially true if the image name is
not resolvable or there is no network connection to
the registry. An image name 127.0.0.1/embedded/myimage,
for example.

Currently, tink worker will always try to pull an image
and will fail if the image pull fails. To allow for
embedded images to function properly, when an image
pull fails we check if the image already exists in the
local Docker cache. If it does we don't fail the method
call.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Aug 29, 2024
1 parent ca50515 commit a54bcce
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/tink-worker/worker/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ImagePullStatus struct {
}

// PullImage outputs to stdout the contents of the requested image (relative to the registry).
// If a pull fails but the image already exists then we will return a nil error.
func (m *containerManager) PullImage(ctx context.Context, img string) error {
l := m.getLogger(ctx)
authConfig := registry.AuthConfig{
Expand All @@ -46,6 +47,9 @@ func (m *containerManager) PullImage(ctx context.Context, img string) error {

out, err := m.cli.ImagePull(ctx, path.Join(m.registryDetails.Registry, img), image.PullOptions{RegistryAuth: authStr})
if err != nil {
if _, _, err := m.cli.ImageInspectWithRaw(ctx, path.Join(m.registryDetails.Registry, img)); err == nil {
return nil
}
return errors.Wrap(err, "DOCKER PULL")
}
defer func() {
Expand Down

0 comments on commit a54bcce

Please sign in to comment.