Skip to content
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

Don't stop pull for images that can be built #10054

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions pkg/compose/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
moby "github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/registry"
"github.com/hashicorp/go-multierror"
"golang.org/x/sync/errgroup"

"github.com/docker/compose/v2/pkg/api"
Expand Down Expand Up @@ -65,12 +66,14 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
eg, ctx := errgroup.WithContext(ctx)
eg.SetLimit(s.maxConcurrency)

var mustBuild []string

imagesBeingPulled := map[string]string{}
var (
mustBuild []string
pullErrors = make([]error, len(project.Services))
imagesBeingPulled = map[string]string{}
)

for _, service := range project.Services {
service := service
for i, service := range project.Services {
i, service := i, service
if service.Image == "" {
w.Event(progress.Event{
ID: service.Name,
Expand Down Expand Up @@ -113,13 +116,14 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
eg.Go(func() error {
_, err := s.pullServiceImage(ctx, service, info, s.configFile(), w, false, project.Environment["DOCKER_DEFAULT_PLATFORM"])
if err != nil {
pullErrors[i] = err
if !opts.IgnoreFailures {
if service.Build != nil {
mustBuild = append(mustBuild, service.Name)
} else {
return err // fail fast if image can't be pulled nor built
}
return err
}
w.TailMsgf("Pulling %s: %s", service.Name, err.Error())
}
return nil
})
Expand All @@ -131,7 +135,11 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
w.TailMsgf("WARNING: Some service image(s) must be built from source by running:\n docker compose build %s", strings.Join(mustBuild, " "))
}

return err
if err != nil {
return err
}

return multierror.Append(nil, pullErrors...).ErrorOrNil()
}

func imageAlreadyPresent(serviceImage string, localImages map[string]string) bool {
Expand Down