mirror of
https://github.com/docker/compose.git
synced 2025-07-28 16:14:06 +02:00
remove import aliases for containerd/errdefs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c50d16cd78
commit
d4f6000712
@ -26,7 +26,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/v2/types"
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
cerrdefs "github.com/containerd/errdefs"
|
"github.com/containerd/errdefs"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
cli "github.com/docker/cli/cli/command/container"
|
cli "github.com/docker/cli/cli/command/container"
|
||||||
"github.com/docker/compose/v2/pkg/api"
|
"github.com/docker/compose/v2/pkg/api"
|
||||||
@ -198,7 +198,7 @@ func loadFileObject(conf types.FileObjectConfig) (types.FileObjectConfig, error)
|
|||||||
|
|
||||||
func inspectWithPull(ctx context.Context, dockerCli command.Cli, imageName string) (image.InspectResponse, error) {
|
func inspectWithPull(ctx context.Context, dockerCli command.Cli, imageName string) (image.InspectResponse, error) {
|
||||||
inspect, err := dockerCli.Client().ImageInspect(ctx, imageName)
|
inspect, err := dockerCli.Client().ImageInspect(ctx, imageName)
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
var stream io.ReadCloser
|
var stream io.ReadCloser
|
||||||
stream, err = dockerCli.Client().ImagePull(ctx, imageName, image.PullOptions{})
|
stream, err = dockerCli.Client().ImagePull(ctx, imageName, image.PullOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
|
|
||||||
"github.com/compose-spec/compose-go/v2/paths"
|
"github.com/compose-spec/compose-go/v2/paths"
|
||||||
"github.com/compose-spec/compose-go/v2/types"
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
cerrdefs "github.com/containerd/errdefs"
|
"github.com/containerd/errdefs"
|
||||||
"github.com/docker/docker/api/types/blkiodev"
|
"github.com/docker/docker/api/types/blkiodev"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
@ -1262,7 +1262,7 @@ func (s *composeService) ensureNetwork(ctx context.Context, project *types.Proje
|
|||||||
}
|
}
|
||||||
|
|
||||||
id, err := s.resolveOrCreateNetwork(ctx, project, name, n)
|
id, err := s.resolveOrCreateNetwork(ctx, project, name, n)
|
||||||
if cerrdefs.IsConflict(err) {
|
if errdefs.IsConflict(err) {
|
||||||
// Maybe another execution of `docker compose up|run` created same network
|
// Maybe another execution of `docker compose up|run` created same network
|
||||||
// let's retry once
|
// let's retry once
|
||||||
return s.resolveOrCreateNetwork(ctx, project, name, n)
|
return s.resolveOrCreateNetwork(ctx, project, name, n)
|
||||||
@ -1497,7 +1497,7 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne
|
|||||||
sn, err := s.apiClient().NetworkInspect(ctx, n.Name, network.InspectOptions{})
|
sn, err := s.apiClient().NetworkInspect(ctx, n.Name, network.InspectOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
networks = append(networks, sn)
|
networks = append(networks, sn)
|
||||||
} else if !cerrdefs.IsNotFound(err) {
|
} else if !errdefs.IsNotFound(err) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1534,7 +1534,7 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne
|
|||||||
func (s *composeService) ensureVolume(ctx context.Context, name string, volume types.VolumeConfig, project *types.Project, assumeYes bool) (string, error) {
|
func (s *composeService) ensureVolume(ctx context.Context, name string, volume types.VolumeConfig, project *types.Project, assumeYes bool) (string, error) {
|
||||||
inspected, err := s.apiClient().VolumeInspect(ctx, volume.Name)
|
inspected, err := s.apiClient().VolumeInspect(ctx, volume.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !cerrdefs.IsNotFound(err) {
|
if !errdefs.IsNotFound(err) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if volume.External {
|
if volume.External {
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/v2/types"
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
cerrdefs "github.com/containerd/errdefs"
|
"github.com/containerd/errdefs"
|
||||||
"github.com/docker/compose/v2/pkg/api"
|
"github.com/docker/compose/v2/pkg/api"
|
||||||
"github.com/docker/compose/v2/pkg/progress"
|
"github.com/docker/compose/v2/pkg/progress"
|
||||||
"github.com/docker/compose/v2/pkg/utils"
|
"github.com/docker/compose/v2/pkg/utils"
|
||||||
@ -219,7 +219,7 @@ func (s *composeService) removeNetwork(ctx context.Context, composeNetworkName s
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
nw, err := s.apiClient().NetworkInspect(ctx, net.ID, network.InspectOptions{})
|
nw, err := s.apiClient().NetworkInspect(ctx, net.ID, network.InspectOptions{})
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
w.Event(progress.NewEvent(eventName, progress.Warning, "No resource found to remove"))
|
w.Event(progress.NewEvent(eventName, progress.Warning, "No resource found to remove"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ func (s *composeService) removeNetwork(ctx context.Context, composeNetworkName s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := s.apiClient().NetworkRemove(ctx, net.ID); err != nil {
|
if err := s.apiClient().NetworkRemove(ctx, net.ID); err != nil {
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
w.Event(progress.ErrorEvent(eventName))
|
w.Event(progress.ErrorEvent(eventName))
|
||||||
@ -261,11 +261,11 @@ func (s *composeService) removeImage(ctx context.Context, image string, w progre
|
|||||||
w.Event(progress.NewEvent(id, progress.Done, "Removed"))
|
w.Event(progress.NewEvent(id, progress.Done, "Removed"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if cerrdefs.IsConflict(err) {
|
if errdefs.IsConflict(err) {
|
||||||
w.Event(progress.NewEvent(id, progress.Warning, "Resource is still in use"))
|
w.Event(progress.NewEvent(id, progress.Warning, "Resource is still in use"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
w.Event(progress.NewEvent(id, progress.Done, "Warning: No resource found to remove"))
|
w.Event(progress.NewEvent(id, progress.Done, "Warning: No resource found to remove"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ func (s *composeService) removeVolume(ctx context.Context, id string, w progress
|
|||||||
resource := fmt.Sprintf("Volume %s", id)
|
resource := fmt.Sprintf("Volume %s", id)
|
||||||
|
|
||||||
_, err := s.apiClient().VolumeInspect(ctx, id)
|
_, err := s.apiClient().VolumeInspect(ctx, id)
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
// Already gone
|
// Already gone
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -287,11 +287,11 @@ func (s *composeService) removeVolume(ctx context.Context, id string, w progress
|
|||||||
w.Event(progress.NewEvent(resource, progress.Done, "Removed"))
|
w.Event(progress.NewEvent(resource, progress.Done, "Removed"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if cerrdefs.IsConflict(err) {
|
if errdefs.IsConflict(err) {
|
||||||
w.Event(progress.NewEvent(resource, progress.Warning, "Resource is still in use"))
|
w.Event(progress.NewEvent(resource, progress.Warning, "Resource is still in use"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
w.Event(progress.NewEvent(resource, progress.Done, "Warning: No resource found to remove"))
|
w.Event(progress.NewEvent(resource, progress.Done, "Warning: No resource found to remove"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ func (s *composeService) stopContainer(
|
|||||||
err := s.runHook(ctx, ctr, *service, hook, listener)
|
err := s.runHook(ctx, ctr, *service, hook, listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Ignore errors indicating that some containers were already stopped or removed.
|
// Ignore errors indicating that some containers were already stopped or removed.
|
||||||
if cerrdefs.IsNotFound(err) || cerrdefs.IsConflict(err) {
|
if errdefs.IsNotFound(err) || errdefs.IsConflict(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@ -357,7 +357,7 @@ func (s *composeService) stopAndRemoveContainer(ctx context.Context, ctr contain
|
|||||||
w := progress.ContextWriter(ctx)
|
w := progress.ContextWriter(ctx)
|
||||||
eventName := getContainerProgressName(ctr)
|
eventName := getContainerProgressName(ctr)
|
||||||
err := s.stopContainer(ctx, w, service, ctr, timeout, nil)
|
err := s.stopContainer(ctx, w, service, ctr, timeout, nil)
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
w.Event(progress.RemovedEvent(eventName))
|
w.Event(progress.RemovedEvent(eventName))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ func (s *composeService) stopAndRemoveContainer(ctx context.Context, ctr contain
|
|||||||
Force: true,
|
Force: true,
|
||||||
RemoveVolumes: volumes,
|
RemoveVolumes: volumes,
|
||||||
})
|
})
|
||||||
if err != nil && !cerrdefs.IsNotFound(err) && !cerrdefs.IsConflict(err) {
|
if err != nil && !errdefs.IsNotFound(err) && !errdefs.IsConflict(err) {
|
||||||
w.Event(progress.ErrorMessageEvent(eventName, "Error while Removing"))
|
w.Event(progress.ErrorMessageEvent(eventName, "Error while Removing"))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/v2/types"
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
cerrdefs "github.com/containerd/errdefs"
|
"github.com/containerd/errdefs"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
@ -204,7 +204,7 @@ func (p *ImagePruner) filterImagesByExistence(ctx context.Context, imageNames []
|
|||||||
for _, img := range imageNames {
|
for _, img := range imageNames {
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
_, err := p.client.ImageInspect(ctx, img)
|
_, err := p.client.ImageInspect(ctx, img)
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
// err on the side of caution: only skip if we successfully
|
// err on the side of caution: only skip if we successfully
|
||||||
// queried the API and got back a definitive "not exists"
|
// queried the API and got back a definitive "not exists"
|
||||||
return nil
|
return nil
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
cerrdefs "github.com/containerd/errdefs"
|
"github.com/containerd/errdefs"
|
||||||
"github.com/containerd/platforms"
|
"github.com/containerd/platforms"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
@ -121,7 +121,7 @@ func (s *composeService) getImageSummaries(ctx context.Context, repoTags []strin
|
|||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
inspect, err := s.apiClient().ImageInspect(ctx, repoTag)
|
inspect, err := s.apiClient().ImageInspect(ctx, repoTag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if cerrdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unable to get image '%s': %w", repoTag, err)
|
return fmt.Errorf("unable to get image '%s': %w", repoTag, err)
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/v2/types"
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
cerrdefs "github.com/containerd/errdefs"
|
"github.com/containerd/errdefs"
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/compose/v2/cmd/formatter"
|
"github.com/docker/compose/v2/cmd/formatter"
|
||||||
"github.com/docker/compose/v2/internal/tracing"
|
"github.com/docker/compose/v2/internal/tracing"
|
||||||
@ -142,7 +142,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
|
|||||||
All: true,
|
All: true,
|
||||||
})
|
})
|
||||||
// Ignore errors indicating that some of the containers were already stopped or removed.
|
// Ignore errors indicating that some of the containers were already stopped or removed.
|
||||||
if cerrdefs.IsNotFound(err) || cerrdefs.IsConflict(err) {
|
if errdefs.IsNotFound(err) || errdefs.IsConflict(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
|
|||||||
Follow: true,
|
Follow: true,
|
||||||
Since: ctr.State.StartedAt,
|
Since: ctr.State.StartedAt,
|
||||||
})
|
})
|
||||||
if cerrdefs.IsNotImplemented(err) {
|
if errdefs.IsNotImplemented(err) {
|
||||||
// container may be configured with logging_driver: none
|
// container may be configured with logging_driver: none
|
||||||
// as container already started, we might miss the very first logs. But still better than none
|
// as container already started, we might miss the very first logs. But still better than none
|
||||||
return s.doAttachContainer(ctx, event.Service, event.ID, event.Source, printer.HandleEvent)
|
return s.doAttachContainer(ctx, event.Service, event.ID, event.Source, printer.HandleEvent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user