8000 fix: container builder image priority by robot9706 · Pull Request #779 · dyrector-io/dyrectorio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: container builder image priority #779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions golang/internal/helper/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,16 @@ func shouldUseLocalImage(ctx context.Context, cli client.APIClient,
EncodedAuth: encodedAuth,
})
if err != nil {
if preferLocal && errors.Is(err, errDigestMismatch) && !errors.Is(err, ErrLocalImageNotFound) {
log.Debug().Msgf("using local image")
return true, nil
// Local image is present, but does not match the remote image
if errors.Is(err, errDigestMismatch) && !errors.Is(err, ErrLocalImageNotFound) {
return preferLocal, nil
}

if errors.Is(err, errDigestsMatching) {
log.Debug().Msgf("using local image")
return true, nil
}
// swallowing specific errors

// Swallowing specific errors
if !(errors.Is(err, errDigestMismatch) || errors.Is(err, ErrImageNotFound)) {
return false, err
}
Expand Down Expand Up @@ -277,6 +278,7 @@ func CustomImagePull(ctx context.Context, cli client.APIClient,
}

if useLocalImage {
log.Debug().Msgf("using local image")
return nil
}
}
Expand Down
3 changes: 2 additions & 1 deletion golang/internal/helper/image/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ type PullPriority int32
const (
LocalOnly PullPriority = 0
PreferLocal PullPriority = 1
ForcePull PullPriority = 2
PullIfNewer PullPriority = 2
ForcePull PullPriority = 3
)

// RegistryAuth defines an image registry and the authentication information
Expand Down
2 changes: 1 addition & 1 deletion golang/pkg/builder/container/container_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func NewDockerBuilder(ctx context.Context) Builder {
b := DockerContainerBuilder{
ctx: ctx,
logger: logger,
imagePriority: imageHelper.PreferLocal,
imagePriority: imageHelper.PullIfNewer,
}

cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
Expand Down
0