From 1b57ca099a9db13da6a1733904b0af5f5c73e356 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 8 Jun 2026 14:38:42 +0200 Subject: [PATCH 1/2] swarmd: migrate to moby module Signed-off-by: Sebastiaan van Stijn --- swarmd/cmd/swarmd/main.go | 4 +- swarmd/dockerexec/adapter.go | 56 +++--- swarmd/dockerexec/container.go | 97 +++++----- swarmd/dockerexec/container_test.go | 9 +- swarmd/dockerexec/controller.go | 35 ++-- .../dockerexec/controller_integration_test.go | 7 +- swarmd/dockerexec/controller_test.go | 180 ++++++++---------- swarmd/dockerexec/docker_client_stub.go | 65 ++++--- swarmd/dockerexec/executor.go | 10 +- swarmd/go.mod | 17 +- swarmd/go.sum | 44 ++--- swarmd/go.work.sum | 29 +++ 12 files changed, 285 insertions(+), 268 deletions(-) diff --git a/swarmd/cmd/swarmd/main.go b/swarmd/cmd/swarmd/main.go index 2b0c17f921..a4a21e7454 100644 --- a/swarmd/cmd/swarmd/main.go +++ b/swarmd/cmd/swarmd/main.go @@ -10,8 +10,8 @@ import ( "os" "os/signal" - engineapi "github.com/docker/docker/client" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + engineapi "github.com/moby/moby/client" "github.com/moby/swarmkit/swarmd/dockerexec" "github.com/moby/swarmkit/swarmd/internal/defaults" "github.com/moby/swarmkit/swarmd/version" @@ -171,7 +171,7 @@ var ( return err } - client, err := engineapi.NewClientWithOpts( + client, err := engineapi.New( engineapi.WithHost(engineAddr), ) if err != nil { diff --git a/swarmd/dockerexec/adapter.go b/swarmd/dockerexec/adapter.go index c641f3d06a..ef8dd90b38 100644 --- a/swarmd/dockerexec/adapter.go +++ b/swarmd/dockerexec/adapter.go @@ -8,11 +8,10 @@ import ( "strings" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/events" - engineapi "github.com/docker/docker/client" gogotypes "github.com/gogo/protobuf/types" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/events" + engineapi "github.com/moby/moby/client" "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/log" @@ -42,16 +41,16 @@ func newContainerAdapter(client engineapi.APIClient, nodeDescription *api.NodeDe }, nil } -func noopPrivilegeFn() (string, error) { return "", nil } +func noopPrivilegeFn(context.Context) (string, error) { return "", nil } -func (c *containerConfig) imagePullOptions() types.ImagePullOptions { +func (c *containerConfig) imagePullOptions() engineapi.ImagePullOptions { var registryAuth string if c.spec().PullOptions != nil { registryAuth = c.spec().PullOptions.RegistryAuth } - return types.ImagePullOptions{ + return engineapi.ImagePullOptions{ // if the image needs to be pulled, the auth config will be retrieved and updated RegistryAuth: registryAuth, PrivilegeFunc: noopPrivilegeFn, @@ -130,7 +129,7 @@ func (c *containerAdapter) createNetworks(ctx context.Context) error { func (c *containerAdapter) removeNetworks(ctx context.Context) error { for _, nid := range c.container.networks() { - if err := c.client.NetworkRemove(ctx, nid); err != nil { + if _, err := c.client.NetworkRemove(ctx, nid, engineapi.NetworkRemoveOptions{}); err != nil { if isActiveEndpointError(err) { continue } @@ -144,24 +143,28 @@ func (c *containerAdapter) removeNetworks(ctx context.Context) error { } func (c *containerAdapter) create(ctx context.Context) error { - _, err := c.client.ContainerCreate(ctx, - c.container.config(), - c.container.hostConfig(), - c.container.networkingConfig(), - nil, - c.container.name(), - ) + _, err := c.client.ContainerCreate(ctx, engineapi.ContainerCreateOptions{ + Config: c.container.config(), + HostConfig: c.container.hostConfig(), + NetworkingConfig: c.container.networkingConfig(), + Name: c.container.name(), + }) return err } func (c *containerAdapter) start(ctx context.Context) error { // TODO(nishanttotla): Consider adding checkpoint handling later - return c.client.ContainerStart(ctx, c.container.name(), types.ContainerStartOptions{}) + _, err := c.client.ContainerStart(ctx, c.container.name(), engineapi.ContainerStartOptions{}) + return err } -func (c *containerAdapter) inspect(ctx context.Context) (types.ContainerJSON, error) { - return c.client.ContainerInspect(ctx, c.container.name()) +func (c *containerAdapter) inspect(ctx context.Context) (container.InspectResponse, error) { + res, err := c.client.ContainerInspect(ctx, c.container.name(), engineapi.ContainerInspectOptions{}) + if err != nil { + return container.InspectResponse{}, err + } + return res.Container, nil } // events issues a call to the events API and returns a channel with all @@ -180,7 +183,7 @@ func (c *containerAdapter) events(ctx context.Context) (<-chan events.Message, < log.G(ctx).Debugf("waiting on events") // TODO(stevvooe): For long running tasks, it is likely that we will have // to restart this under failure. - eventCh, errCh := c.client.Events(ctx, types.EventsOptions{ + res := c.client.Events(ctx, engineapi.EventsListOptions{ Since: "0", Filters: c.container.eventFilter(), }) @@ -190,13 +193,13 @@ func (c *containerAdapter) events(ctx context.Context) (<-chan events.Message, < for { select { - case msg := <-eventCh: + case msg := <-res.Messages: select { case eventsq <- msg: case <-ctx.Done(): return } - case err := <-errCh: + case err := <-res.Err: log.G(ctx).WithError(err).Error("error from events stream") return case <-ctx.Done(): @@ -220,18 +223,21 @@ func (c *containerAdapter) shutdown(ctx context.Context) error { stopgraceFromProto, _ := gogotypes.DurationFromProto(spec.StopGracePeriod) stopgraceSeconds = int(stopgraceFromProto.Seconds()) } - return c.client.ContainerStop(ctx, c.container.name(), container.StopOptions{Timeout: &stopgraceSeconds}) + _, err := c.client.ContainerStop(ctx, c.container.name(), engineapi.ContainerStopOptions{Timeout: &stopgraceSeconds}) + return err } func (c *containerAdapter) terminate(ctx context.Context) error { - return c.client.ContainerKill(ctx, c.container.name(), "") + _, err := c.client.ContainerKill(ctx, c.container.name(), engineapi.ContainerKillOptions{}) + return err } func (c *containerAdapter) remove(ctx context.Context) error { - return c.client.ContainerRemove(ctx, c.container.name(), types.ContainerRemoveOptions{ + _, err := c.client.ContainerRemove(ctx, c.container.name(), engineapi.ContainerRemoveOptions{ RemoveVolumes: true, Force: true, }) + return err } func (c *containerAdapter) createVolumes(ctx context.Context) error { @@ -268,7 +274,7 @@ func (c *containerAdapter) logs(ctx context.Context, options api.LogSubscription return nil, errors.New("logs not supported on services with TTY") } - apiOptions := types.ContainerLogsOptions{ + apiOptions := engineapi.ContainerLogsOptions{ Follow: options.Follow, Timestamps: true, Details: false, diff --git a/swarmd/dockerexec/container.go b/swarmd/dockerexec/container.go index f29207cba7..764c9f5ecb 100644 --- a/swarmd/dockerexec/container.go +++ b/swarmd/dockerexec/container.go @@ -5,20 +5,18 @@ import ( "fmt" "maps" "net" + "net/netip" "strconv" "strings" "time" - "github.com/docker/docker/api/types" - enginecontainer "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/filters" - enginemount "github.com/docker/docker/api/types/mount" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/api/types/volume" - "github.com/docker/go-connections/nat" "github.com/docker/go-units" gogotypes "github.com/gogo/protobuf/types" + enginecontainer "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/events" + enginemount "github.com/moby/moby/api/types/mount" + "github.com/moby/moby/api/types/network" + engineapi "github.com/moby/moby/client" "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/api/genericresource" @@ -94,12 +92,13 @@ func (c *containerConfig) image() string { return c.spec().Image } -func portSpec(port uint32, protocol api.PortConfig_Protocol) nat.Port { - return nat.Port(fmt.Sprintf("%d/%s", port, strings.ToLower(protocol.String()))) +func portSpec(port uint32, protocol api.PortConfig_Protocol) network.Port { + p, _ := network.ParsePort(fmt.Sprintf("%d/%s", port, strings.ToLower(protocol.String()))) + return p } -func (c *containerConfig) portBindings() nat.PortMap { - portBindings := nat.PortMap{} +func (c *containerConfig) portBindings() network.PortMap { + portBindings := network.PortMap{} if c.task.Endpoint == nil { return portBindings } @@ -110,7 +109,7 @@ func (c *containerConfig) portBindings() nat.PortMap { } port := portSpec(portConfig.TargetPort, portConfig.Protocol) - binding := []nat.PortBinding{ + binding := []network.PortBinding{ {}, } @@ -126,17 +125,18 @@ func (c *containerConfig) portBindings() nat.PortMap { func (c *containerConfig) isolation() enginecontainer.Isolation { switch c.spec().Isolation { case api.ContainerIsolationDefault: - return enginecontainer.Isolation("default") + return "default" case api.ContainerIsolationHyperV: - return enginecontainer.Isolation("hyperv") + return "hyperv" case api.ContainerIsolationProcess: - return enginecontainer.Isolation("process") + return "process" + default: + return "" } - return enginecontainer.Isolation("") } -func (c *containerConfig) exposedPorts() map[nat.Port]struct{} { - exposedPorts := make(map[nat.Port]struct{}) +func (c *containerConfig) exposedPorts() network.PortSet { + exposedPorts := make(network.PortSet) if c.task.Endpoint == nil { return exposedPorts } @@ -412,7 +412,7 @@ func getMountMask(m *api.Mount) string { } // This handles the case of volumes that are defined inside a service Mount -func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.CreateOptions { +func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *engineapi.VolumeCreateOptions { var ( driverName string driverOpts map[string]string @@ -426,7 +426,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.CreateOp } // FIXME: do we need the ClusterVolumeSpec here? - return &volume.CreateOptions{ + return &engineapi.VolumeCreateOptions{ Name: mount.Source, Driver: driverName, DriverOpts: driverOpts, @@ -498,20 +498,20 @@ func (c *containerConfig) virtualIP(networkID string) string { func (c *containerConfig) networkingConfig() *network.NetworkingConfig { epConfig := make(map[string]*network.EndpointSettings) for _, na := range c.task.Networks { - var ipv4, ipv6 string + var ipv4, ipv6 netip.Addr for _, addr := range na.Addresses { - ip, _, err := net.ParseCIDR(addr) + prefix, err := netip.ParsePrefix(addr) if err != nil { continue } - if ip.To4() != nil { - ipv4 = ip.String() + ip := prefix.Addr() + if ip.Is4() { + ipv4 = ip continue } - - if ip.To16() != nil { - ipv6 = ip.String() + if ip.Is6() { + ipv6 = ip } } @@ -541,39 +541,48 @@ func (c *containerConfig) networks() []string { return networks } -func (c *containerConfig) networkCreateOptions(name string) (types.NetworkCreate, error) { +func (c *containerConfig) networkCreateOptions(name string) (engineapi.NetworkCreateOptions, error) { na, ok := c.networksAttachments[name] if !ok { - return types.NetworkCreate{}, errors.New("container: unknown network referenced") + return engineapi.NetworkCreateOptions{}, errors.New("container: unknown network referenced") } - options := types.NetworkCreate{ + options := engineapi.NetworkCreateOptions{ Driver: na.Network.DriverState.Name, IPAM: &network.IPAM{ Driver: na.Network.IPAM.Driver.Name, }, - Options: na.Network.DriverState.Options, - CheckDuplicate: true, + Options: na.Network.DriverState.Options, } for _, ic := range na.Network.IPAM.Configs { - c := network.IPAMConfig{ - Subnet: ic.Subnet, - IPRange: ic.Range, - Gateway: ic.Gateway, + sn, err := netip.ParsePrefix(ic.Subnet) + if err != nil { + continue + } + r, err := netip.ParsePrefix(ic.Range) + if err != nil { + continue + } + gw, err := netip.ParseAddr(ic.Gateway) + if err != nil { + continue } - options.IPAM.Config = append(options.IPAM.Config, c) + options.IPAM.Config = append(options.IPAM.Config, network.IPAMConfig{ + Subnet: sn, + IPRange: r, + Gateway: gw, + }) } return options, nil } -func (c containerConfig) eventFilter() filters.Args { - filter := filters.NewArgs() - filter.Add("type", string(events.ContainerEventType)) - filter.Add("name", c.name()) - filter.Add("label", fmt.Sprintf("%v.task.id=%v", systemLabelPrefix, c.task.ID)) - return filter +func (c containerConfig) eventFilter() engineapi.Filters { + return make(engineapi.Filters). + Add("type", string(events.ContainerEventType)). + Add("name", c.name()). + Add("label", fmt.Sprintf("%v.task.id=%v", systemLabelPrefix, c.task.ID)) } func (c *containerConfig) init() *bool { diff --git a/swarmd/dockerexec/container_test.go b/swarmd/dockerexec/container_test.go index 0b9add675e..883852f78a 100644 --- a/swarmd/dockerexec/container_test.go +++ b/swarmd/dockerexec/container_test.go @@ -5,11 +5,10 @@ import ( "testing" "time" - enginecontainer "github.com/docker/docker/api/types/container" - enginemount "github.com/docker/docker/api/types/mount" - "github.com/docker/docker/api/types/strslice" "github.com/docker/go-units" gogotypes "github.com/gogo/protobuf/types" + enginecontainer "github.com/moby/moby/api/types/container" + enginemount "github.com/moby/moby/api/types/mount" "github.com/moby/swarmkit/v2/api" ) @@ -274,7 +273,7 @@ func TestCapabilityAdd(t *testing.T) { }, } - expected := strslice.StrSlice{"CAP_NET_RAW", "CAP_SYS_CHROOT"} + expected := []string{"CAP_NET_RAW", "CAP_SYS_CHROOT"} actual := c.hostConfig().CapAdd if !reflect.DeepEqual(actual, expected) { t.Fatalf("expected %s, got %s", expected, actual) @@ -294,7 +293,7 @@ func TestCapabilityDrop(t *testing.T) { }, } - expected := strslice.StrSlice{"CAP_KILL"} + expected := []string{"CAP_KILL"} actual := c.hostConfig().CapDrop if !reflect.DeepEqual(actual, expected) { t.Fatalf("expected %s, got %s", expected, actual) diff --git a/swarmd/dockerexec/controller.go b/swarmd/dockerexec/controller.go index abc0508fa2..c7be6a91cb 100644 --- a/swarmd/dockerexec/controller.go +++ b/swarmd/dockerexec/controller.go @@ -8,14 +8,13 @@ import ( "fmt" "io" "strconv" - "strings" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/events" - engineapi "github.com/docker/docker/client" - "github.com/docker/go-connections/nat" gogotypes "github.com/gogo/protobuf/types" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/events" + "github.com/moby/moby/api/types/network" + engineapi "github.com/moby/moby/client" "github.com/pkg/errors" "golang.org/x/time/rate" @@ -602,7 +601,7 @@ func (e *exitError) Unwrap() error { return e.cause } -func makeExitError(ctnr types.ContainerJSON) error { +func makeExitError(ctnr container.InspectResponse) error { if ctnr.State.ExitCode != 0 { var cause error if ctnr.State.Error != "" { @@ -621,7 +620,7 @@ func makeExitError(ctnr types.ContainerJSON) error { } -func parseContainerStatus(ctnr types.ContainerJSON) (*api.ContainerStatus, error) { +func parseContainerStatus(ctnr container.InspectResponse) (*api.ContainerStatus, error) { status := &api.ContainerStatus{ ContainerID: ctnr.ID, PID: int32(ctnr.State.Pid), @@ -631,7 +630,7 @@ func parseContainerStatus(ctnr types.ContainerJSON) (*api.ContainerStatus, error return status, nil } -func parsePortStatus(ctnr types.ContainerJSON) (*api.PortStatus, error) { +func parsePortStatus(ctnr container.InspectResponse) (*api.PortStatus, error) { status := &api.PortStatus{} if ctnr.NetworkSettings != nil && len(ctnr.NetworkSettings.Ports) > 0 { @@ -645,30 +644,26 @@ func parsePortStatus(ctnr types.ContainerJSON) (*api.PortStatus, error) { return status, nil } -func parsePortMap(portMap nat.PortMap) ([]*api.PortConfig, error) { +func parsePortMap(portMap network.PortMap) ([]*api.PortConfig, error) { exposedPorts := make([]*api.PortConfig, 0, len(portMap)) for portProtocol, mapping := range portMap { - parts := strings.SplitN(string(portProtocol), "/", 2) - if len(parts) != 2 { + if !portProtocol.IsValid() { return nil, fmt.Errorf("invalid port mapping: %s", portProtocol) } - port, err := strconv.ParseUint(parts[0], 10, 16) - if err != nil { - return nil, err - } + port := portProtocol.Num() var protocol api.PortConfig_Protocol - switch strings.ToLower(parts[1]) { - case "tcp": + switch portProtocol.Proto() { + case network.TCP: protocol = api.ProtocolTCP - case "udp": + case network.UDP: protocol = api.ProtocolUDP - case "sctp": + case network.SCTP: protocol = api.ProtocolSCTP default: - return nil, fmt.Errorf("invalid protocol: %s", parts[1]) + return nil, fmt.Errorf("invalid protocol: %s", portProtocol.Proto()) } for _, binding := range mapping { diff --git a/swarmd/dockerexec/controller_integration_test.go b/swarmd/dockerexec/controller_integration_test.go index 68e92883a7..f010677006 100644 --- a/swarmd/dockerexec/controller_integration_test.go +++ b/swarmd/dockerexec/controller_integration_test.go @@ -5,7 +5,7 @@ import ( "flag" "testing" - engineapi "github.com/docker/docker/client" + engineapi "github.com/moby/moby/client" "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/api/genericresource" @@ -36,10 +36,7 @@ func TestControllerFlowIntegration(t *testing.T) { } ctx := context.Background() - client, err := engineapi.NewClientWithOpts( - engineapi.WithHost(dockerTestAddr), - engineapi.WithAPIVersionNegotiation(), - ) + client, err := engineapi.New(engineapi.WithHost(dockerTestAddr)) assert.NoError(t, err) assert.NotNil(t, client) diff --git a/swarmd/dockerexec/controller_test.go b/swarmd/dockerexec/controller_test.go index 9a7ff1e32f..29dcc66798 100644 --- a/swarmd/dockerexec/controller_test.go +++ b/swarmd/dockerexec/controller_test.go @@ -10,14 +10,11 @@ import ( "testing" "time" - v1 "github.com/opencontainers/image-spec/specs-go/v1" + engineapi "github.com/moby/moby/client" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - containertypes "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/network" gogotypes "github.com/gogo/protobuf/types" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/events" "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/identity" @@ -36,19 +33,19 @@ func TestControllerPrepare(t *testing.T) { assert.Equal(t, 1, client.calls["ContainerCreate"]) }() - client.ImagePullFn = func(_ context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) { + client.ImagePullFn = func(_ context.Context, refStr string, options engineapi.ImagePullOptions) (io.ReadCloser, error) { if refStr == config.image() { return io.NopCloser(bytes.NewBuffer([]byte{})), nil } panic("unexpected call of ImagePull") } - client.ContainerCreateFn = func(_ context.Context, cConfig *containertypes.Config, hConfig *containertypes.HostConfig, nConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (containertypes.CreateResponse, error) { - if reflect.DeepEqual(*cConfig, *config.config()) && - reflect.DeepEqual(*hConfig, *config.hostConfig()) && - reflect.DeepEqual(*nConfig, *config.networkingConfig()) && - containerName == config.name() { - return containertypes.CreateResponse{ID: "container-id-" + task.ID}, nil + client.ContainerCreateFn = func(_ context.Context, options engineapi.ContainerCreateOptions) (engineapi.ContainerCreateResult, error) { + if reflect.DeepEqual(*options.Config, *config.config()) && + reflect.DeepEqual(*options.HostConfig, *config.hostConfig()) && + reflect.DeepEqual(*options.NetworkingConfig, *config.networkingConfig()) && + options.Name == config.name() { + return engineapi.ContainerCreateResult{ID: "container-id-" + task.ID}, nil } panic("unexpected call to ContainerCreate") } @@ -66,25 +63,25 @@ func TestControllerPrepareAlreadyPrepared(t *testing.T) { assert.Equal(t, 1, client.calls["ContainerInspect"]) }() - client.ImagePullFn = func(_ context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) { + client.ImagePullFn = func(_ context.Context, refStr string, options engineapi.ImagePullOptions) (io.ReadCloser, error) { if refStr == config.image() { return io.NopCloser(bytes.NewBuffer([]byte{})), nil } panic("unexpected call of ImagePull") } - client.ContainerCreateFn = func(_ context.Context, cConfig *containertypes.Config, hostConfig *containertypes.HostConfig, networking *network.NetworkingConfig, platform *v1.Platform, containerName string) (containertypes.CreateResponse, error) { - if reflect.DeepEqual(*cConfig, *config.config()) && - reflect.DeepEqual(*networking, *config.networkingConfig()) && - containerName == config.name() { - return containertypes.CreateResponse{}, fmt.Errorf("Conflict. The name") + client.ContainerCreateFn = func(_ context.Context, options engineapi.ContainerCreateOptions) (engineapi.ContainerCreateResult, error) { + if reflect.DeepEqual(*options.Config, *config.config()) && + reflect.DeepEqual(*options.NetworkingConfig, *config.networkingConfig()) && + options.Name == config.name() { + return engineapi.ContainerCreateResult{}, fmt.Errorf("Conflict. The name") } panic("unexpected call of ContainerCreate") } - client.ContainerInspectFn = func(_ context.Context, containerName string) (types.ContainerJSON, error) { + client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { - return types.ContainerJSON{}, nil + return container.InspectResponse{}, nil } panic("unexpected call of ContainerInspect") } @@ -104,21 +101,19 @@ func TestControllerStart(t *testing.T) { assert.Equal(t, 1, client.calls["ContainerStart"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (types.ContainerJSON, error) { + client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ - Status: "created", - }, + return container.InspectResponse{ + State: &container.State{ + Status: "created", }, }, nil } panic("unexpected call of ContainerInspect") } - client.ContainerStartFn = func(_ context.Context, containerName string, options types.ContainerStartOptions) error { - if containerName == config.name() && reflect.DeepEqual(options, types.ContainerStartOptions{}) { + client.ContainerStartFn = func(_ context.Context, containerName string, options engineapi.ContainerStartOptions) error { + if containerName == config.name() && reflect.DeepEqual(options, engineapi.ContainerStartOptions{}) { return nil } panic("unexpected call of ContainerStart") @@ -135,13 +130,11 @@ func TestControllerStartAlreadyStarted(t *testing.T) { assert.Equal(t, 1, client.calls["ContainerInspect"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (types.ContainerJSON, error) { + client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ - Status: "notcreated", // can be anything but created - }, + return container.InspectResponse{ + State: &container.State{ + Status: "notcreated", // can be anything but created }, }, nil } @@ -163,29 +156,25 @@ func TestControllerWait(t *testing.T) { assert.Equal(t, 1, client.calls["Events"]) }() - client.ContainerInspectFn = func(_ context.Context, container string) (types.ContainerJSON, error) { - if client.calls["ContainerInspect"] == 1 && container == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ - Status: "running", - }, + client.ContainerInspectFn = func(_ context.Context, ctrID string) (container.InspectResponse, error) { + if client.calls["ContainerInspect"] == 1 && ctrID == config.name() { + return container.InspectResponse{ + State: &container.State{ + Status: "running", }, }, nil - } else if client.calls["ContainerInspect"] == 2 && container == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ - Status: "stopped", // can be anything but created - }, + } else if client.calls["ContainerInspect"] == 2 && ctrID == config.name() { + return container.InspectResponse{ + State: &container.State{ + Status: "stopped", // can be anything but created }, }, nil } panic("unexpected call of ContainerInspect") } - client.EventsFn = func(_ context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) { - if reflect.DeepEqual(options, types.EventsOptions{ + client.EventsFn = func(_ context.Context, options engineapi.EventsListOptions) engineapi.EventsResult { + if reflect.DeepEqual(options, engineapi.EventsListOptions{ Since: "0", Filters: config.eventFilter(), }) { @@ -206,29 +195,27 @@ func TestControllerWaitUnhealthy(t *testing.T) { assert.Equal(t, 1, client.calls["Events"]) assert.Equal(t, 1, client.calls["ContainerStop"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (types.ContainerJSON, error) { + client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ - Status: "running", - }, + return container.InspectResponse{ + State: &container.State{ + Status: "running", }, }, nil } panic("unexpected call ContainerInspect") } - evs, errs := makeEvents(t, config, events.ActionCreate, events.ActionHealthStatusUnhealthy) - client.EventsFn = func(_ context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) { - if reflect.DeepEqual(options, types.EventsOptions{ + res := makeEvents(t, config, events.ActionCreate, events.ActionHealthStatusUnhealthy) + client.EventsFn = func(_ context.Context, options engineapi.EventsListOptions) engineapi.EventsResult { + if reflect.DeepEqual(options, engineapi.EventsListOptions{ Since: "0", Filters: config.eventFilter(), }) { - return evs, errs + return res } panic("unexpected call of Events") } - client.ContainerStopFn = func(_ context.Context, containerName string, options container.StopOptions) error { + client.ContainerStopFn = func(_ context.Context, containerName string, options engineapi.ContainerStopOptions) error { if containerName == config.name() && *options.Timeout == tenSecond { return nil } @@ -247,32 +234,28 @@ func TestControllerWaitExitError(t *testing.T) { assert.Equal(t, 1, client.calls["Events"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (types.ContainerJSON, error) { + client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if client.calls["ContainerInspect"] == 1 && containerName == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ - Status: "running", - }, + return container.InspectResponse{ + State: &container.State{ + Status: "running", }, }, nil } else if client.calls["ContainerInspect"] == 2 && containerName == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - ID: "cid", - State: &types.ContainerState{ - Status: "exited", // can be anything but created - ExitCode: 1, - Pid: 1, - }, + return container.InspectResponse{ + ID: "cid", + State: &container.State{ + Status: "exited", // can be anything but created + ExitCode: 1, + Pid: 1, }, }, nil } panic("unexpected call of ContainerInspect") } - client.EventsFn = func(_ context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) { - if reflect.DeepEqual(options, types.EventsOptions{ + client.EventsFn = func(_ context.Context, options engineapi.EventsListOptions) engineapi.EventsResult { + if reflect.DeepEqual(options, engineapi.EventsListOptions{ Since: "0", Filters: config.eventFilter(), }) { @@ -302,13 +285,11 @@ func TestControllerWaitExitedClean(t *testing.T) { assert.Equal(t, 1, client.calls["ContainerInspect"]) }() - client.ContainerInspectFn = func(_ context.Context, container string) (types.ContainerJSON, error) { - if container == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{ - Status: "exited", - }, + client.ContainerInspectFn = func(_ context.Context, ctrID string) (container.InspectResponse, error) { + if ctrID == config.name() { + return container.InspectResponse{ + State: &container.State{ + Status: "exited", }, }, nil } @@ -327,16 +308,14 @@ func TestControllerWaitExitedError(t *testing.T) { assert.Equal(t, 1, client.calls["ContainerInspect"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (types.ContainerJSON, error) { + client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { - return types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - ID: "cid", - State: &types.ContainerState{ - Status: "exited", - ExitCode: 1, - Pid: 1, - }, + return container.InspectResponse{ + ID: "cid", + State: &container.State{ + Status: "exited", + ExitCode: 1, + Pid: 1, }, }, nil } @@ -355,7 +334,7 @@ func TestControllerShutdown(t *testing.T) { assert.Equal(t, 1, client.calls["ContainerStop"]) }() - client.ContainerStopFn = func(_ context.Context, containerName string, option container.StopOptions) error { + client.ContainerStopFn = func(_ context.Context, containerName string, option engineapi.ContainerStopOptions) error { if containerName == config.name() && *option.Timeout == tenSecond { return nil } @@ -392,15 +371,15 @@ func TestControllerRemove(t *testing.T) { assert.Equal(t, 1, client.calls["ContainerRemove"]) }() - client.ContainerStopFn = func(_ context.Context, container string, option container.StopOptions) error { + client.ContainerStopFn = func(_ context.Context, container string, option engineapi.ContainerStopOptions) error { if container == config.name() && *option.Timeout == tenSecond { return nil } panic("unexpected call of ContainerStop") } - client.ContainerRemoveFn = func(_ context.Context, container string, options types.ContainerRemoveOptions) error { - if container == config.name() && reflect.DeepEqual(options, types.ContainerRemoveOptions{ + client.ContainerRemoveFn = func(_ context.Context, container string, options engineapi.ContainerRemoveOptions) error { + if container == config.name() && reflect.DeepEqual(options, engineapi.ContainerRemoveOptions{ RemoveVolumes: true, Force: true, }) { @@ -464,7 +443,7 @@ func genTask(t *testing.T) *api.Task { } } -func makeEvents(t *testing.T, container *containerConfig, actions ...events.Action) (<-chan events.Message, <-chan error) { +func makeEvents(t *testing.T, container *containerConfig, actions ...events.Action) engineapi.EventsResult { t.Helper() evs := make(chan events.Message, len(actions)) for _, action := range actions { @@ -481,5 +460,8 @@ func makeEvents(t *testing.T, container *containerConfig, actions ...events.Acti } close(evs) - return evs, nil + return engineapi.EventsResult{ + Messages: evs, + Err: nil, + } } diff --git a/swarmd/dockerexec/docker_client_stub.go b/swarmd/dockerexec/docker_client_stub.go index cbcfb1b2de..6a7c589061 100644 --- a/swarmd/dockerexec/docker_client_stub.go +++ b/swarmd/dockerexec/docker_client_stub.go @@ -6,12 +6,8 @@ import ( "runtime" "strings" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/events" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/client" - v1 "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/client" ) // StubAPIClient implements the client.APIClient interface, but allows @@ -19,14 +15,14 @@ import ( type StubAPIClient struct { client.APIClient calls map[string]int - ContainerCreateFn func(_ context.Context, config *container.Config, hostConfig *container.HostConfig, networking *network.NetworkingConfig, platform *v1.Platform, containerName string) (container.CreateResponse, error) - ContainerInspectFn func(_ context.Context, containerID string) (types.ContainerJSON, error) + ContainerCreateFn func(_ context.Context, options client.ContainerCreateOptions) (client.ContainerCreateResult, error) + ContainerInspectFn func(_ context.Context, containerID string) (container.InspectResponse, error) ContainerKillFn func(_ context.Context, containerID, signal string) error - ContainerRemoveFn func(_ context.Context, containerID string, options types.ContainerRemoveOptions) error - ContainerStartFn func(_ context.Context, containerID string, options types.ContainerStartOptions) error - ContainerStopFn func(_ context.Context, containerID string, options container.StopOptions) error - ImagePullFn func(_ context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) - EventsFn func(_ context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) + ContainerRemoveFn func(_ context.Context, containerID string, options client.ContainerRemoveOptions) error + ContainerStartFn func(_ context.Context, containerID string, options client.ContainerStartOptions) error + ContainerStopFn func(_ context.Context, containerID string, options client.ContainerStopOptions) error + ImagePullFn func(_ context.Context, refStr string, options client.ImagePullOptions) (io.ReadCloser, error) + EventsFn func(_ context.Context, options client.EventsListOptions) client.EventsResult } // NewStubAPIClient returns an initialized StubAPIClient @@ -51,49 +47,62 @@ func (sa *StubAPIClient) called() { } // ContainerCreate is part of the APIClient interface -func (sa *StubAPIClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networking *network.NetworkingConfig, platform *v1.Platform, containerName string) (container.CreateResponse, error) { +func (sa *StubAPIClient) ContainerCreate(ctx context.Context, options client.ContainerCreateOptions) (client.ContainerCreateResult, error) { sa.called() - return sa.ContainerCreateFn(ctx, config, hostConfig, networking, platform, containerName) + return sa.ContainerCreateFn(ctx, options) } // ContainerInspect is part of the APIClient interface -func (sa *StubAPIClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { +func (sa *StubAPIClient) ContainerInspect(ctx context.Context, containerID string, _ client.ContainerInspectOptions) (client.ContainerInspectResult, error) { sa.called() - return sa.ContainerInspectFn(ctx, containerID) + c, err := sa.ContainerInspectFn(ctx, containerID) + if err != nil { + return client.ContainerInspectResult{}, err + } + return client.ContainerInspectResult{Container: c}, nil } // ContainerKill is part of the APIClient interface -func (sa *StubAPIClient) ContainerKill(ctx context.Context, containerID, signal string) error { +func (sa *StubAPIClient) ContainerKill(ctx context.Context, containerID string, options client.ContainerKillOptions) (client.ContainerKillResult, error) { sa.called() - return sa.ContainerKillFn(ctx, containerID, signal) + return client.ContainerKillResult{}, sa.ContainerKillFn(ctx, containerID, options.Signal) } // ContainerRemove is part of the APIClient interface -func (sa *StubAPIClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error { +func (sa *StubAPIClient) ContainerRemove(ctx context.Context, containerID string, options client.ContainerRemoveOptions) (client.ContainerRemoveResult, error) { sa.called() - return sa.ContainerRemoveFn(ctx, containerID, options) + return client.ContainerRemoveResult{}, sa.ContainerRemoveFn(ctx, containerID, options) } // ContainerStart is part of the APIClient interface -func (sa *StubAPIClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error { +func (sa *StubAPIClient) ContainerStart(ctx context.Context, containerID string, options client.ContainerStartOptions) (client.ContainerStartResult, error) { sa.called() - return sa.ContainerStartFn(ctx, containerID, options) + return client.ContainerStartResult{}, sa.ContainerStartFn(ctx, containerID, options) } // ContainerStop is part of the APIClient interface -func (sa *StubAPIClient) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error { +func (sa *StubAPIClient) ContainerStop(ctx context.Context, containerID string, options client.ContainerStopOptions) (client.ContainerStopResult, error) { sa.called() - return sa.ContainerStopFn(ctx, containerID, options) + return client.ContainerStopResult{}, sa.ContainerStopFn(ctx, containerID, options) +} + +type fakeStreamResult struct { + io.ReadCloser + client.ImagePullResponse } +func (e fakeStreamResult) Read(p []byte) (int, error) { return e.ReadCloser.Read(p) } +func (e fakeStreamResult) Close() error { return e.ReadCloser.Close() } + // ImagePull is part of the APIClient interface -func (sa *StubAPIClient) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) { +func (sa *StubAPIClient) ImagePull(ctx context.Context, refStr string, options client.ImagePullOptions) (client.ImagePullResponse, error) { sa.called() - return sa.ImagePullFn(ctx, refStr, options) + res, err := sa.ImagePullFn(ctx, refStr, options) + return fakeStreamResult{ReadCloser: res}, err } // Events is part of the APIClient interface -func (sa *StubAPIClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) { +func (sa *StubAPIClient) Events(ctx context.Context, options client.EventsListOptions) client.EventsResult { sa.called() return sa.EventsFn(ctx, options) } diff --git a/swarmd/dockerexec/executor.go b/swarmd/dockerexec/executor.go index 1aa0e99132..996136ca3a 100644 --- a/swarmd/dockerexec/executor.go +++ b/swarmd/dockerexec/executor.go @@ -6,8 +6,7 @@ import ( "strings" "sync" - "github.com/docker/docker/api/types/filters" - engineapi "github.com/docker/docker/client" + engineapi "github.com/moby/moby/client" "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/agent/secrets" "github.com/moby/swarmkit/v2/api" @@ -34,10 +33,11 @@ func NewExecutor(client engineapi.APIClient, genericResources []*api.GenericReso // Describe returns the underlying node description from the docker client. func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) { - info, err := e.client.Info(ctx) + res, err := e.client.Info(ctx, engineapi.InfoOptions{}) if err != nil { return nil, err } + info := res.Info plugins := map[api.PluginDescription]struct{}{} addPlugins := func(typ string, names []string) { @@ -57,12 +57,12 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) { addPlugins("Authorization", info.Plugins.Authorization) // retrieve v2 plugins - v2plugins, err := e.client.PluginList(ctx, filters.NewArgs()) + v2plugins, err := e.client.PluginList(ctx, engineapi.PluginListOptions{}) if err != nil { log.L.WithError(err).Warning("PluginList operation failed") } else { // add v2 plugins to 'plugins' - for _, plgn := range v2plugins { + for _, plgn := range v2plugins.Items { for _, typ := range plgn.Config.Interface.Types { if typ.Prefix == "docker" && plgn.Enabled { plgnTyp := typ.Capability diff --git a/swarmd/go.mod b/swarmd/go.mod index ea7f6b26bd..da4ac2ad24 100644 --- a/swarmd/go.mod +++ b/swarmd/go.mod @@ -4,14 +4,13 @@ go 1.25.0 require ( github.com/cloudflare/cfssl v1.6.4 - github.com/docker/docker v24.0.0-rc.2.0.20230908212318-6ce5aa1cd5a4+incompatible // master (v25.0.0-dev) - github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea github.com/docker/go-units v0.5.0 github.com/dustin/go-humanize v1.0.1 github.com/gogo/protobuf v1.3.2 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 + github.com/moby/moby/api v1.55.0 + github.com/moby/moby/client v0.5.1 github.com/moby/swarmkit/v2 v2.1.2 - github.com/opencontainers/image-spec v1.1.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.20.5 github.com/sirupsen/logrus v1.10.2 @@ -45,10 +44,12 @@ require ( github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/container-storage-interface/spec v1.2.0 // indirect - github.com/containerd/containerd v1.7.29 // indirect + github.com/containerd/errdefs v1.0.0 // indirect + github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/coreos/go-semver v0.3.1 // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect + github.com/docker/go-connections v0.7.0 // indirect + github.com/docker/go-events v0.0.0-20260713150650-1ee7122bc07b // indirect github.com/docker/go-metrics v0.1.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fernet/fernet-go v0.0.0-20211208181803-9f70042a33ee // indirect @@ -63,10 +64,10 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmoiron/sqlx v1.3.3 // indirect github.com/klauspost/compress v1.17.9 // indirect - github.com/moby/term v0.5.2 // indirect - github.com/morikuni/aec v1.0.0 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.1 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.62.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect @@ -79,7 +80,6 @@ require ( go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect go.opentelemetry.io/otel v1.39.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.39.0 // indirect go.opentelemetry.io/otel/trace v1.39.0 // indirect go.uber.org/multierr v1.11.0 // indirect @@ -92,7 +92,6 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect google.golang.org/protobuf v1.36.10 // indirect - gotest.tools/v3 v3.5.2 // indirect k8s.io/klog/v2 v2.100.1 // indirect ) diff --git a/swarmd/go.sum b/swarmd/go.sum index b8bab79390..14afc78bea 100644 --- a/swarmd/go.sum +++ b/swarmd/go.sum @@ -1,15 +1,11 @@ code.cloudfoundry.org/clock v1.1.0 h1:XLzC6W3Ah/Y7ht1rmZ6+QfPdt1iGWEAAtIZXgiaj57c= code.cloudfoundry.org/clock v1.1.0/go.mod h1:yA3fxddT9RINQL2XHS7PS+OXxKCGhfrZmlNUCIM6AKo= -github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= -github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= -github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM= -github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cloudflare/cfssl v1.6.4 h1:NMOvfrEjFfC63K3SGXgAnFdsgkmiq4kATme5BfcqrO8= @@ -18,10 +14,10 @@ github.com/cockroachdb/datadriven v1.0.2 h1:H9MtNqVoVhvd9nCBwOyDjUEdZCREqbIdCJD9 github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/container-storage-interface/spec v1.2.0 h1:bD9KIVgaVKKkQ/UbVUY9kCaH/CJbhNxe0eeB4JeJV2s= github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= -github.com/containerd/containerd v1.7.29 h1:90fWABQsaN9mJhGkoVnuzEY+o1XDPbg9BTC9QTAHnuE= -github.com/containerd/containerd v1.7.29/go.mod h1:azUkWcOvHrWvaiUjSQH0fjzuHIwSPg1WL5PshGP4Szs= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= +github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= +github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= +github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= @@ -29,12 +25,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v24.0.0-rc.2.0.20230908212318-6ce5aa1cd5a4+incompatible h1:sqXunZ6IkpGcR9Kgj8R4MaCXNBZYhlcXxe4BGC8tJAI= -github.com/docker/docker v24.0.0-rc.2.0.20230908212318-6ce5aa1cd5a4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea h1:+4n+kUVbPdu6qMI9SUnSKMC+D50gNW4L7Lhk9tI2lVo= -github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= -github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= -github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= +github.com/docker/go-connections v0.7.0 h1:6SsRfJddP22WMrCkj19x9WKjEDTB+ahsdiGYf0mN39c= +github.com/docker/go-connections v0.7.0/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q= +github.com/docker/go-events v0.0.0-20260713150650-1ee7122bc07b h1:hNHejR92DFL4bzroHmZC1MQqt7WbgSFRt/Y0XqpJxIE= +github.com/docker/go-events v0.0.0-20260713150650-1ee7122bc07b/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/docker/go-metrics v0.1.0 h1:r76KPNpstz+IvQKSWpYegSkkyzex0V3A1ZGVx6bhGlY= github.com/docker/go-metrics v0.1.0/go.mod h1:PciI3sONtB051kXALN1JoIlpcu54E1FuPh+4DuqEzyw= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -98,10 +92,12 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= -github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= -github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/moby/api v1.55.0 h1:2/sexvQyqIWS8pRSCFddBfpW2qE7vR7FCL+vN8pxwMc= +github.com/moby/moby/api v1.55.0/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs= +github.com/moby/moby/client v0.5.1 h1:tYNaJno4c0HXz12y5BiqEDy0rVTYkWzI26lGvnTMiJw= +github.com/moby/moby/client v0.5.1/go.mod h1:odLstlZ6uSnfvAgVxMpvgmb8SUdd+siH2T0GBuxVAlM= github.com/mreiferson/go-httpclient v0.0.0-20160630210159-31f0106b4474/go.mod h1:OQA4XLvDbMgS8P0CevmM4m9Q3Jq4phKUzcocxuGJ5m8= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= @@ -114,8 +110,8 @@ github.com/onsi/gomega v1.38.3/go.mod h1:ZCU1pkQcXDO5Sl9/VVEGlDyp+zm0m1cmeG5TOzL github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= -github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -175,10 +171,6 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg= go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 h1:aTL7F04bJHUlztTsNGJ2l+6he8c+y/b//eR0jjjemT4= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0/go.mod h1:kldtb7jDTeol0l3ewcmd8SDvx3EmIE7lyvqbasU3QC4= go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0= go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs= go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18= @@ -187,8 +179,6 @@ go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2W go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= -go.opentelemetry.io/proto/otlp v1.7.1 h1:gTOMpGDb0WTBOP8JaO72iL3auEZhVmAQg4ipjOVAtj4= -go.opentelemetry.io/proto/otlp v1.7.1/go.mod h1:b2rVh6rfI/s2pHWNlB7ILJcRALpcNDzKhACevjI+ZnE= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -267,3 +257,5 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= +pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= diff --git a/swarmd/go.work.sum b/swarmd/go.work.sum index 3169e3fd34..50298f3839 100644 --- a/swarmd/go.work.sum +++ b/swarmd/go.work.sum @@ -639,6 +639,10 @@ github.com/containerd/continuity v0.4.4 h1:/fNVfTJ7wIl/YPMHjf+5H32uFhl63JucB34Pl github.com/containerd/continuity v0.4.4/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4= github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= +github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= +github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= +github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= +github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU= github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY= @@ -667,6 +671,8 @@ github.com/containerd/typeurl v1.0.2 h1:Chlt8zIieDbzQFzXzAeBEF92KhExuE4p9p92/QmY github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s= github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4= github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= +github.com/containerd/typeurl/v2 v2.2.0 h1:6NBDbQzr7I5LHgp34xAXYF5DOTQDn05X58lsPEmzLso= +github.com/containerd/typeurl/v2 v2.2.0/go.mod h1:8XOOxnyatxSWuG8OfsZXVnAF4iZfedjS/8UHSPJnX4g= github.com/containerd/zfs v1.1.0 h1:n7OZ7jZumLIqNJqXrEc/paBM840mORnmGdJDmAmJZHM= github.com/containerd/zfs v1.1.0/go.mod h1:oZF9wBnrnQjpWLaPKEinrx3TQ9a+W/RJO7Zb41d8YLE= github.com/containernetworking/cni v1.1.1 h1:ky20T7c0MvKvbMOwS/FrlbNwjEoqJEUUYfsL4b0mc4k= @@ -696,10 +702,16 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= +github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954 h1:RMLoZVzv4GliuWafOuPuQDKSm1SJph7uCRnnS61JAn4= +github.com/docker/go-connections v0.7.0 h1:6SsRfJddP22WMrCkj19x9WKjEDTB+ahsdiGYf0mN39c= +github.com/docker/go-connections v0.7.0/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q= +github.com/docker/go-events v0.0.0-20260713150650-1ee7122bc07b h1:hNHejR92DFL4bzroHmZC1MQqt7WbgSFRt/Y0XqpJxIE= +github.com/docker/go-events v0.0.0-20260713150650-1ee7122bc07b/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= @@ -792,6 +804,7 @@ github.com/google/flatbuffers v2.0.8+incompatible h1:ivUb1cGomAB101ZM1T0nOiWz9pS github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= @@ -914,6 +927,8 @@ github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOj github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/matttproud/golang_protobuf_extensions v1.0.2 h1:hAHbPm5IJGijwng3PWk09JkG9WeqChjprR5s9bBZ+OM= +github.com/matttproud/golang_protobuf_extensions v1.0.2/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= @@ -935,8 +950,14 @@ github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdI github.com/mitchellh/gox v0.4.0 h1:lfGJxY7ToLJQjHHwi0EX6uYBdK78egf954SQl13PQJc= github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= +github.com/moby/moby/api v1.55.0 h1:2/sexvQyqIWS8pRSCFddBfpW2qE7vR7FCL+vN8pxwMc= +github.com/moby/moby/api v1.55.0/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs= +github.com/moby/moby/client v0.5.1 h1:tYNaJno4c0HXz12y5BiqEDy0rVTYkWzI26lGvnTMiJw= +github.com/moby/moby/client v0.5.1/go.mod h1:odLstlZ6uSnfvAgVxMpvgmb8SUdd+siH2T0GBuxVAlM= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= @@ -967,6 +988,8 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 h1:3snG66yBm59tKhhSPQrQ/0bCrv1LQbKt40LnUPiUxdc= @@ -1019,6 +1042,8 @@ github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3V github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f h1:UFr9zpz4xgTnIE5yIMtWAMngCdZ9p/+q6lTbgelo80M= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= @@ -1281,6 +1306,8 @@ google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6 google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA= +google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:CgAqfJo+Xmu0GwA0411Ht3OU3OntXwsGmrmjI8ioGXI= google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 h1:1hfbdAfFbkmpg41000wDVqr7jUpK/Yo+LPnIxxGzmkg= google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3/go.mod h1:5RBcpGRxr25RbDzY5w+dmaqpSEvl8Gwl1x2CICf60ic= google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f/go.mod h1:Uy9bTZJqmfrw2rIBxgGLnamc78euZULUBrLZ9XTITKI= @@ -1360,6 +1387,8 @@ k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b h1:wxEMGetGMur3J1xuGLQY7GEQYg9bZ k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= +pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= From c817171eb25d3265cd823bbbf066ad6e44f32156 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 1 Aug 2026 21:57:50 +0200 Subject: [PATCH 2/2] swarmd: remove redundant import aliases Signed-off-by: Sebastiaan van Stijn --- swarmd/cmd/swarmd/main.go | 21 ++- swarmd/dockerexec/adapter.go | 33 ++-- swarmd/dockerexec/container.go | 85 +++++----- swarmd/dockerexec/container_test.go | 27 ++-- swarmd/dockerexec/controller.go | 4 +- .../dockerexec/controller_integration_test.go | 11 +- swarmd/dockerexec/controller_test.go | 148 +++++++++--------- swarmd/dockerexec/executor.go | 11 +- swarmd/go.work.sum | 24 +-- 9 files changed, 178 insertions(+), 186 deletions(-) diff --git a/swarmd/cmd/swarmd/main.go b/swarmd/cmd/swarmd/main.go index a4a21e7454..9054778c54 100644 --- a/swarmd/cmd/swarmd/main.go +++ b/swarmd/cmd/swarmd/main.go @@ -10,11 +10,8 @@ import ( "os" "os/signal" - grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - engineapi "github.com/moby/moby/client" - "github.com/moby/swarmkit/swarmd/dockerexec" - "github.com/moby/swarmkit/swarmd/internal/defaults" - "github.com/moby/swarmkit/swarmd/version" + prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "github.com/moby/moby/client" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/api/genericresource" "github.com/moby/swarmkit/v2/cli" @@ -24,6 +21,10 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/moby/swarmkit/swarmd/dockerexec" + "github.com/moby/swarmkit/swarmd/internal/defaults" + "github.com/moby/swarmkit/swarmd/version" ) var externalCAOpt cli.ExternalCAOpt @@ -171,14 +172,12 @@ var ( return err } - client, err := engineapi.New( - engineapi.WithHost(engineAddr), - ) + apiClient, err := client.New(client.WithHost(engineAddr)) if err != nil { return err } - executor := dockerexec.NewExecutor(client, resources) + executor := dockerexec.NewExecutor(apiClient, resources) if debugAddr != "" { go func() { @@ -191,7 +190,7 @@ var ( if metricsAddr != "" { // This allows to measure latency distribution. - grpc_prometheus.EnableHandlingTimeHistogram() + prometheus.EnableHandlingTimeHistogram() l, err := net.Listen("tcp", metricsAddr) if err != nil { @@ -235,7 +234,7 @@ var ( signal.Notify(c, os.Interrupt) go func() { <-c - n.Stop(ctx) + _ = n.Stop(ctx) }() go func() { diff --git a/swarmd/dockerexec/adapter.go b/swarmd/dockerexec/adapter.go index ef8dd90b38..2c62872cf1 100644 --- a/swarmd/dockerexec/adapter.go +++ b/swarmd/dockerexec/adapter.go @@ -11,24 +11,25 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/moby/moby/api/types/container" "github.com/moby/moby/api/types/events" - engineapi "github.com/moby/moby/client" + "github.com/moby/moby/client" + "github.com/pkg/errors" + "golang.org/x/time/rate" + "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/log" - "github.com/pkg/errors" - "golang.org/x/time/rate" ) // containerAdapter conducts remote operations for a container. All calls // are mostly naked calls to the client API, seeded with information from // containerConfig. type containerAdapter struct { - client engineapi.APIClient + client client.APIClient container *containerConfig secrets exec.SecretGetter } -func newContainerAdapter(client engineapi.APIClient, nodeDescription *api.NodeDescription, task *api.Task, secrets exec.SecretGetter) (*containerAdapter, error) { +func newContainerAdapter(client client.APIClient, nodeDescription *api.NodeDescription, task *api.Task, secrets exec.SecretGetter) (*containerAdapter, error) { ctnr, err := newContainerConfig(nodeDescription, task) if err != nil { return nil, err @@ -43,14 +44,14 @@ func newContainerAdapter(client engineapi.APIClient, nodeDescription *api.NodeDe func noopPrivilegeFn(context.Context) (string, error) { return "", nil } -func (c *containerConfig) imagePullOptions() engineapi.ImagePullOptions { +func (c *containerConfig) imagePullOptions() client.ImagePullOptions { var registryAuth string if c.spec().PullOptions != nil { registryAuth = c.spec().PullOptions.RegistryAuth } - return engineapi.ImagePullOptions{ + return client.ImagePullOptions{ // if the image needs to be pulled, the auth config will be retrieved and updated RegistryAuth: registryAuth, PrivilegeFunc: noopPrivilegeFn, @@ -129,7 +130,7 @@ func (c *containerAdapter) createNetworks(ctx context.Context) error { func (c *containerAdapter) removeNetworks(ctx context.Context) error { for _, nid := range c.container.networks() { - if _, err := c.client.NetworkRemove(ctx, nid, engineapi.NetworkRemoveOptions{}); err != nil { + if _, err := c.client.NetworkRemove(ctx, nid, client.NetworkRemoveOptions{}); err != nil { if isActiveEndpointError(err) { continue } @@ -143,7 +144,7 @@ func (c *containerAdapter) removeNetworks(ctx context.Context) error { } func (c *containerAdapter) create(ctx context.Context) error { - _, err := c.client.ContainerCreate(ctx, engineapi.ContainerCreateOptions{ + _, err := c.client.ContainerCreate(ctx, client.ContainerCreateOptions{ Config: c.container.config(), HostConfig: c.container.hostConfig(), NetworkingConfig: c.container.networkingConfig(), @@ -155,12 +156,12 @@ func (c *containerAdapter) create(ctx context.Context) error { func (c *containerAdapter) start(ctx context.Context) error { // TODO(nishanttotla): Consider adding checkpoint handling later - _, err := c.client.ContainerStart(ctx, c.container.name(), engineapi.ContainerStartOptions{}) + _, err := c.client.ContainerStart(ctx, c.container.name(), client.ContainerStartOptions{}) return err } func (c *containerAdapter) inspect(ctx context.Context) (container.InspectResponse, error) { - res, err := c.client.ContainerInspect(ctx, c.container.name(), engineapi.ContainerInspectOptions{}) + res, err := c.client.ContainerInspect(ctx, c.container.name(), client.ContainerInspectOptions{}) if err != nil { return container.InspectResponse{}, err } @@ -183,7 +184,7 @@ func (c *containerAdapter) events(ctx context.Context) (<-chan events.Message, < log.G(ctx).Debugf("waiting on events") // TODO(stevvooe): For long running tasks, it is likely that we will have // to restart this under failure. - res := c.client.Events(ctx, engineapi.EventsListOptions{ + res := c.client.Events(ctx, client.EventsListOptions{ Since: "0", Filters: c.container.eventFilter(), }) @@ -223,17 +224,17 @@ func (c *containerAdapter) shutdown(ctx context.Context) error { stopgraceFromProto, _ := gogotypes.DurationFromProto(spec.StopGracePeriod) stopgraceSeconds = int(stopgraceFromProto.Seconds()) } - _, err := c.client.ContainerStop(ctx, c.container.name(), engineapi.ContainerStopOptions{Timeout: &stopgraceSeconds}) + _, err := c.client.ContainerStop(ctx, c.container.name(), client.ContainerStopOptions{Timeout: &stopgraceSeconds}) return err } func (c *containerAdapter) terminate(ctx context.Context) error { - _, err := c.client.ContainerKill(ctx, c.container.name(), engineapi.ContainerKillOptions{}) + _, err := c.client.ContainerKill(ctx, c.container.name(), client.ContainerKillOptions{}) return err } func (c *containerAdapter) remove(ctx context.Context) error { - _, err := c.client.ContainerRemove(ctx, c.container.name(), engineapi.ContainerRemoveOptions{ + _, err := c.client.ContainerRemove(ctx, c.container.name(), client.ContainerRemoveOptions{ RemoveVolumes: true, Force: true, }) @@ -274,7 +275,7 @@ func (c *containerAdapter) logs(ctx context.Context, options api.LogSubscription return nil, errors.New("logs not supported on services with TTY") } - apiOptions := engineapi.ContainerLogsOptions{ + apiOptions := client.ContainerLogsOptions{ Follow: options.Follow, Timestamps: true, Details: false, diff --git a/swarmd/dockerexec/container.go b/swarmd/dockerexec/container.go index 764c9f5ecb..bb2f3702c3 100644 --- a/swarmd/dockerexec/container.go +++ b/swarmd/dockerexec/container.go @@ -12,11 +12,12 @@ import ( "github.com/docker/go-units" gogotypes "github.com/gogo/protobuf/types" - enginecontainer "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/container" "github.com/moby/moby/api/types/events" - enginemount "github.com/moby/moby/api/types/mount" + "github.com/moby/moby/api/types/mount" "github.com/moby/moby/api/types/network" - engineapi "github.com/moby/moby/client" + "github.com/moby/moby/client" + "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/api/genericresource" @@ -48,12 +49,12 @@ func newContainerConfig(n *api.NodeDescription, t *api.Task) (*containerConfig, } func (c *containerConfig) setTask(n *api.NodeDescription, t *api.Task) error { - container := t.Spec.GetContainer() - if container == nil { + ctr := t.Spec.GetContainer() + if ctr == nil { return exec.ErrRuntimeUnsupported } - if container.Image == "" { + if ctr.Image == "" { return ErrImageRequired } @@ -122,7 +123,7 @@ func (c *containerConfig) portBindings() network.PortMap { return portBindings } -func (c *containerConfig) isolation() enginecontainer.Isolation { +func (c *containerConfig) isolation() container.Isolation { switch c.spec().Isolation { case api.ContainerIsolationDefault: return "default" @@ -153,11 +154,11 @@ func (c *containerConfig) exposedPorts() network.PortSet { return exposedPorts } -func (c *containerConfig) config() *enginecontainer.Config { +func (c *containerConfig) config() *container.Config { genericEnvs := genericresource.EnvFormat(c.task.AssignedGenericResources, "DOCKER_RESOURCE") env := append(c.spec().Env, genericEnvs...) - config := &enginecontainer.Config{ + config := &container.Config{ Labels: c.labels(), StopSignal: c.spec().StopSignal, User: c.spec().User, @@ -186,7 +187,7 @@ func (c *containerConfig) config() *enginecontainer.Config { return config } -func (c *containerConfig) healthcheck() *enginecontainer.HealthConfig { +func (c *containerConfig) healthcheck() *container.HealthConfig { hcSpec := c.spec().Healthcheck if hcSpec == nil { return nil @@ -195,7 +196,7 @@ func (c *containerConfig) healthcheck() *enginecontainer.HealthConfig { timeout, _ := gogotypes.DurationFromProto(hcSpec.Timeout) startPeriod, _ := gogotypes.DurationFromProto(hcSpec.StartPeriod) startInterval, _ := gogotypes.DurationFromProto(hcSpec.StartInterval) - return &enginecontainer.HealthConfig{ + return &container.HealthConfig{ Test: hcSpec.Test, Interval: interval, Timeout: timeout, @@ -205,8 +206,8 @@ func (c *containerConfig) healthcheck() *enginecontainer.HealthConfig { } } -func (c *containerConfig) hostConfig() *enginecontainer.HostConfig { - hc := &enginecontainer.HostConfig{ +func (c *containerConfig) hostConfig() *container.HostConfig { + hc := &container.HostConfig{ Resources: c.resources(), Mounts: c.mounts(), Tmpfs: c.tmpfs(), @@ -234,7 +235,7 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig { } if c.task.LogDriver != nil { - hc.LogConfig = enginecontainer.LogConfig{ + hc.LogConfig = container.LogConfig{ Type: c.task.LogDriver.Name, Config: c.task.LogDriver.Options, } @@ -283,16 +284,16 @@ func (c *containerConfig) tmpfs() map[string]string { return r } -func (c *containerConfig) mounts() []enginemount.Mount { - var r []enginemount.Mount - for _, mount := range c.spec().Mounts { - r = append(r, convertMount(mount)) +func (c *containerConfig) mounts() []mount.Mount { + var r []mount.Mount + for _, mnt := range c.spec().Mounts { + r = append(r, convertMount(mnt)) } return r } -func convertMount(m api.Mount) enginemount.Mount { - mount := enginemount.Mount{ +func convertMount(m api.Mount) mount.Mount { + mnt := mount.Mount{ Source: m.Source, Target: m.Target, ReadOnly: m.ReadOnly, @@ -300,15 +301,15 @@ func convertMount(m api.Mount) enginemount.Mount { switch m.Type { case api.MountTypeBind: - mount.Type = enginemount.TypeBind + mnt.Type = mount.TypeBind case api.MountTypeVolume: - mount.Type = enginemount.TypeVolume + mnt.Type = mount.TypeVolume case api.MountTypeNamedPipe: - mount.Type = enginemount.TypeNamedPipe + mnt.Type = mount.TypeNamedPipe } if m.BindOptions != nil { - mount.BindOptions = &enginemount.BindOptions{ + mnt.BindOptions = &mount.BindOptions{ NonRecursive: m.BindOptions.NonRecursive, CreateMountpoint: m.BindOptions.CreateMountpoint, ReadOnlyNonRecursive: m.BindOptions.ReadOnlyNonRecursive, @@ -316,35 +317,35 @@ func convertMount(m api.Mount) enginemount.Mount { } switch m.BindOptions.Propagation { case api.MountPropagationRPrivate: - mount.BindOptions.Propagation = enginemount.PropagationRPrivate + mnt.BindOptions.Propagation = mount.PropagationRPrivate case api.MountPropagationPrivate: - mount.BindOptions.Propagation = enginemount.PropagationPrivate + mnt.BindOptions.Propagation = mount.PropagationPrivate case api.MountPropagationRSlave: - mount.BindOptions.Propagation = enginemount.PropagationRSlave + mnt.BindOptions.Propagation = mount.PropagationRSlave case api.MountPropagationSlave: - mount.BindOptions.Propagation = enginemount.PropagationSlave + mnt.BindOptions.Propagation = mount.PropagationSlave case api.MountPropagationRShared: - mount.BindOptions.Propagation = enginemount.PropagationRShared + mnt.BindOptions.Propagation = mount.PropagationRShared case api.MountPropagationShared: - mount.BindOptions.Propagation = enginemount.PropagationShared + mnt.BindOptions.Propagation = mount.PropagationShared } } if m.VolumeOptions != nil { - mount.VolumeOptions = &enginemount.VolumeOptions{ + mnt.VolumeOptions = &mount.VolumeOptions{ NoCopy: m.VolumeOptions.NoCopy, // TODO: uncomment after 26.0 vendor // Subpath: m.VolumeOptions.Subpath, Labels: maps.Clone(m.VolumeOptions.Labels), } if m.VolumeOptions.DriverConfig != nil { - mount.VolumeOptions.DriverConfig = &enginemount.Driver{ + mnt.VolumeOptions.DriverConfig = &mount.Driver{ Name: m.VolumeOptions.DriverConfig.Name, Options: maps.Clone(m.VolumeOptions.DriverConfig.Options), } } } - return mount + return mnt } func getMountMask(m *api.Mount) string { @@ -412,7 +413,7 @@ func getMountMask(m *api.Mount) string { } // This handles the case of volumes that are defined inside a service Mount -func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *engineapi.VolumeCreateOptions { +func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *client.VolumeCreateOptions { var ( driverName string driverOpts map[string]string @@ -426,7 +427,7 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *engineapi.Volum } // FIXME: do we need the ClusterVolumeSpec here? - return &engineapi.VolumeCreateOptions{ + return &client.VolumeCreateOptions{ Name: mount.Source, Driver: driverName, DriverOpts: driverOpts, @@ -434,8 +435,8 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *engineapi.Volum } } -func (c *containerConfig) resources() enginecontainer.Resources { - resources := enginecontainer.Resources{} +func (c *containerConfig) resources() container.Resources { + resources := container.Resources{} // set pids limit pidsLimit := c.spec().PidsLimit @@ -541,13 +542,13 @@ func (c *containerConfig) networks() []string { return networks } -func (c *containerConfig) networkCreateOptions(name string) (engineapi.NetworkCreateOptions, error) { +func (c *containerConfig) networkCreateOptions(name string) (client.NetworkCreateOptions, error) { na, ok := c.networksAttachments[name] if !ok { - return engineapi.NetworkCreateOptions{}, errors.New("container: unknown network referenced") + return client.NetworkCreateOptions{}, errors.New("container: unknown network referenced") } - options := engineapi.NetworkCreateOptions{ + options := client.NetworkCreateOptions{ Driver: na.Network.DriverState.Name, IPAM: &network.IPAM{ Driver: na.Network.IPAM.Driver.Name, @@ -578,8 +579,8 @@ func (c *containerConfig) networkCreateOptions(name string) (engineapi.NetworkCr return options, nil } -func (c containerConfig) eventFilter() engineapi.Filters { - return make(engineapi.Filters). +func (c containerConfig) eventFilter() client.Filters { + return make(client.Filters). Add("type", string(events.ContainerEventType)). Add("name", c.name()). Add("label", fmt.Sprintf("%v.task.id=%v", systemLabelPrefix, c.task.ID)) diff --git a/swarmd/dockerexec/container_test.go b/swarmd/dockerexec/container_test.go index 883852f78a..271360f48c 100644 --- a/swarmd/dockerexec/container_test.go +++ b/swarmd/dockerexec/container_test.go @@ -7,8 +7,9 @@ import ( "github.com/docker/go-units" gogotypes "github.com/gogo/protobuf/types" - enginecontainer "github.com/moby/moby/api/types/container" - enginemount "github.com/moby/moby/api/types/mount" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/api/types/mount" + "github.com/moby/swarmkit/v2/api" ) @@ -16,24 +17,24 @@ func TestVolumesAndBinds(t *testing.T) { type testCase struct { explain string config api.Mount - x enginemount.Mount + x mount.Mount } cases := []testCase{ {"Simple bind mount", api.Mount{Type: api.MountTypeBind, Source: "/banana", Target: "/kerfluffle"}, - enginemount.Mount{Type: enginemount.TypeBind, Source: "/banana", Target: "/kerfluffle"}}, + mount.Mount{Type: mount.TypeBind, Source: "/banana", Target: "/kerfluffle"}}, {"Bind mound with propagation", api.Mount{Type: api.MountTypeBind, Source: "/banana", Target: "/kerfluffle", BindOptions: &api.Mount_BindOptions{Propagation: api.MountPropagationRPrivate}}, - enginemount.Mount{Type: enginemount.TypeBind, Source: "/banana", Target: "/kerfluffle", BindOptions: &enginemount.BindOptions{Propagation: enginemount.PropagationRPrivate}}}, + mount.Mount{Type: mount.TypeBind, Source: "/banana", Target: "/kerfluffle", BindOptions: &mount.BindOptions{Propagation: mount.PropagationRPrivate}}}, {"Simple volume with source", api.Mount{Type: api.MountTypeVolume, Source: "banana", Target: "/kerfluffle"}, - enginemount.Mount{Type: enginemount.TypeVolume, Source: "banana", Target: "/kerfluffle"}}, + mount.Mount{Type: mount.TypeVolume, Source: "banana", Target: "/kerfluffle"}}, {"Volume with options", api.Mount{Type: api.MountTypeVolume, Source: "banana", Target: "/kerfluffle", VolumeOptions: &api.Mount_VolumeOptions{NoCopy: true}}, - enginemount.Mount{Type: enginemount.TypeVolume, Source: "banana", Target: "/kerfluffle", VolumeOptions: &enginemount.VolumeOptions{NoCopy: true}}}, + mount.Mount{Type: mount.TypeVolume, Source: "banana", Target: "/kerfluffle", VolumeOptions: &mount.VolumeOptions{NoCopy: true}}}, {"Volume with no source", api.Mount{Type: api.MountTypeVolume, Target: "/kerfluffle"}, - enginemount.Mount{Type: enginemount.TypeVolume, Target: "/kerfluffle"}}, + mount.Mount{Type: mount.TypeVolume, Target: "/kerfluffle"}}, {"Named pipe using Windows format", api.Mount{Type: api.MountTypeNamedPipe, Source: `\\.\pipe\foo`, Target: `\\.\pipe\foo`}, - enginemount.Mount{Type: enginemount.TypeNamedPipe, Source: `\\.\pipe\foo`, Target: `\\.\pipe\foo`}}, + mount.Mount{Type: mount.TypeNamedPipe, Source: `\\.\pipe\foo`, Target: `\\.\pipe\foo`}}, {"Named pipe using Unix format", api.Mount{Type: api.MountTypeNamedPipe, Source: "//./pipe/foo", Target: "//./pipe/foo"}, - enginemount.Mount{Type: enginemount.TypeNamedPipe, Source: "//./pipe/foo", Target: "//./pipe/foo"}}, + mount.Mount{Type: mount.TypeNamedPipe, Source: "//./pipe/foo", Target: "//./pipe/foo"}}, } for _, c := range cases { @@ -59,12 +60,12 @@ func TestVolumesAndBinds(t *testing.T) { t.Log(c.explain) t.Logf("expected: %+v, got: %+v", c.x, mounts[0]) switch c.x.Type { - case enginemount.TypeVolume: + case mount.TypeVolume: t.Logf("expected volume opts: %+v, got: %+v", c.x.VolumeOptions, mounts[0].VolumeOptions) if c.x.VolumeOptions.DriverConfig != nil { t.Logf("expected volume driver config: %+v, got: %+v", c.x.VolumeOptions.DriverConfig, mounts[0].VolumeOptions.DriverConfig) } - case enginemount.TypeBind: + case mount.TypeBind: t.Logf("expected bind opts: %+v, got: %+v", c.x.BindOptions, mounts[0].BindOptions) } t.Fail() @@ -126,7 +127,7 @@ func TestHealthcheck(t *testing.T) { }, } config := c.config() - expected := &enginecontainer.HealthConfig{ + expected := &container.HealthConfig{ Test: []string{"a", "b", "c"}, Interval: time.Second, Timeout: time.Minute, diff --git a/swarmd/dockerexec/controller.go b/swarmd/dockerexec/controller.go index c7be6a91cb..a967e4c1a6 100644 --- a/swarmd/dockerexec/controller.go +++ b/swarmd/dockerexec/controller.go @@ -14,7 +14,7 @@ import ( "github.com/moby/moby/api/types/container" "github.com/moby/moby/api/types/events" "github.com/moby/moby/api/types/network" - engineapi "github.com/moby/moby/client" + "github.com/moby/moby/client" "github.com/pkg/errors" "golang.org/x/time/rate" @@ -41,7 +41,7 @@ type controller struct { var _ exec.Controller = &controller{} // newController returns a docker exec controller for the provided task. -func newController(client engineapi.APIClient, nodeDescription *api.NodeDescription, task *api.Task, secrets exec.SecretGetter) (exec.Controller, error) { +func newController(client client.APIClient, nodeDescription *api.NodeDescription, task *api.Task, secrets exec.SecretGetter) (exec.Controller, error) { adapter, err := newContainerAdapter(client, nodeDescription, task, secrets) if err != nil { return nil, err diff --git a/swarmd/dockerexec/controller_integration_test.go b/swarmd/dockerexec/controller_integration_test.go index f010677006..dd9f1d019a 100644 --- a/swarmd/dockerexec/controller_integration_test.go +++ b/swarmd/dockerexec/controller_integration_test.go @@ -5,11 +5,12 @@ import ( "flag" "testing" - engineapi "github.com/moby/moby/client" + "github.com/moby/moby/client" + "github.com/stretchr/testify/assert" + "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/api/genericresource" - "github.com/stretchr/testify/assert" ) var ( @@ -36,9 +37,9 @@ func TestControllerFlowIntegration(t *testing.T) { } ctx := context.Background() - client, err := engineapi.New(engineapi.WithHost(dockerTestAddr)) + apiClient, err := client.New(client.WithHost(dockerTestAddr)) assert.NoError(t, err) - assert.NotNil(t, client) + assert.NotNil(t, apiClient) available := genericresource.NewSet("apple", "blue", "red") available = append(available, genericresource.NewDiscrete("orange", 3)) @@ -79,7 +80,7 @@ func TestControllerFlowIntegration(t *testing.T) { return nil }) - ctlr, err := newController(client, nil, task, nil) + ctlr, err := newController(apiClient, nil, task, nil) assert.NoError(t, err) assert.NotNil(t, ctlr) assert.NoError(t, ctlr.Prepare(ctx)) diff --git a/swarmd/dockerexec/controller_test.go b/swarmd/dockerexec/controller_test.go index 29dcc66798..649ce0d4e4 100644 --- a/swarmd/dockerexec/controller_test.go +++ b/swarmd/dockerexec/controller_test.go @@ -10,42 +10,42 @@ import ( "testing" "time" - engineapi "github.com/moby/moby/client" - gogotypes "github.com/gogo/protobuf/types" "github.com/moby/moby/api/types/container" "github.com/moby/moby/api/types/events" + "github.com/moby/moby/client" + "github.com/stretchr/testify/assert" + "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/api" "github.com/moby/swarmkit/v2/identity" "github.com/moby/swarmkit/v2/log" - "github.com/stretchr/testify/assert" ) const tenSecond = 10 func TestControllerPrepare(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ImagePull"]) - assert.Equal(t, 1, client.calls["ContainerCreate"]) + assert.Equal(t, 1, apiClient.calls["ImagePull"]) + assert.Equal(t, 1, apiClient.calls["ContainerCreate"]) }() - client.ImagePullFn = func(_ context.Context, refStr string, options engineapi.ImagePullOptions) (io.ReadCloser, error) { + apiClient.ImagePullFn = func(_ context.Context, refStr string, options client.ImagePullOptions) (io.ReadCloser, error) { if refStr == config.image() { return io.NopCloser(bytes.NewBuffer([]byte{})), nil } panic("unexpected call of ImagePull") } - client.ContainerCreateFn = func(_ context.Context, options engineapi.ContainerCreateOptions) (engineapi.ContainerCreateResult, error) { + apiClient.ContainerCreateFn = func(_ context.Context, options client.ContainerCreateOptions) (client.ContainerCreateResult, error) { if reflect.DeepEqual(*options.Config, *config.config()) && reflect.DeepEqual(*options.HostConfig, *config.hostConfig()) && reflect.DeepEqual(*options.NetworkingConfig, *config.networkingConfig()) && options.Name == config.name() { - return engineapi.ContainerCreateResult{ID: "container-id-" + task.ID}, nil + return client.ContainerCreateResult{ID: "container-id-" + task.ID}, nil } panic("unexpected call to ContainerCreate") } @@ -55,31 +55,31 @@ func TestControllerPrepare(t *testing.T) { func TestControllerPrepareAlreadyPrepared(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ImagePull"]) - assert.Equal(t, 1, client.calls["ContainerCreate"]) - assert.Equal(t, 1, client.calls["ContainerInspect"]) + assert.Equal(t, 1, apiClient.calls["ImagePull"]) + assert.Equal(t, 1, apiClient.calls["ContainerCreate"]) + assert.Equal(t, 1, apiClient.calls["ContainerInspect"]) }() - client.ImagePullFn = func(_ context.Context, refStr string, options engineapi.ImagePullOptions) (io.ReadCloser, error) { + apiClient.ImagePullFn = func(_ context.Context, refStr string, options client.ImagePullOptions) (io.ReadCloser, error) { if refStr == config.image() { return io.NopCloser(bytes.NewBuffer([]byte{})), nil } panic("unexpected call of ImagePull") } - client.ContainerCreateFn = func(_ context.Context, options engineapi.ContainerCreateOptions) (engineapi.ContainerCreateResult, error) { + apiClient.ContainerCreateFn = func(_ context.Context, options client.ContainerCreateOptions) (client.ContainerCreateResult, error) { if reflect.DeepEqual(*options.Config, *config.config()) && reflect.DeepEqual(*options.NetworkingConfig, *config.networkingConfig()) && options.Name == config.name() { - return engineapi.ContainerCreateResult{}, fmt.Errorf("Conflict. The name") + return client.ContainerCreateResult{}, fmt.Errorf("Conflict. The name") } panic("unexpected call of ContainerCreate") } - client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { + apiClient.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { return container.InspectResponse{}, nil } @@ -94,14 +94,14 @@ func TestControllerPrepareAlreadyPrepared(t *testing.T) { func TestControllerStart(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ContainerInspect"]) - assert.Equal(t, 1, client.calls["ContainerStart"]) + assert.Equal(t, 1, apiClient.calls["ContainerInspect"]) + assert.Equal(t, 1, apiClient.calls["ContainerStart"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { + apiClient.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { return container.InspectResponse{ State: &container.State{ @@ -112,8 +112,8 @@ func TestControllerStart(t *testing.T) { panic("unexpected call of ContainerInspect") } - client.ContainerStartFn = func(_ context.Context, containerName string, options engineapi.ContainerStartOptions) error { - if containerName == config.name() && reflect.DeepEqual(options, engineapi.ContainerStartOptions{}) { + apiClient.ContainerStartFn = func(_ context.Context, containerName string, options client.ContainerStartOptions) error { + if containerName == config.name() && reflect.DeepEqual(options, client.ContainerStartOptions{}) { return nil } panic("unexpected call of ContainerStart") @@ -124,13 +124,13 @@ func TestControllerStart(t *testing.T) { func TestControllerStartAlreadyStarted(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ContainerInspect"]) + assert.Equal(t, 1, apiClient.calls["ContainerInspect"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { + apiClient.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { return container.InspectResponse{ State: &container.State{ @@ -149,21 +149,21 @@ func TestControllerStartAlreadyStarted(t *testing.T) { func TestControllerWait(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 2, client.calls["ContainerInspect"]) - assert.Equal(t, 1, client.calls["Events"]) + assert.Equal(t, 2, apiClient.calls["ContainerInspect"]) + assert.Equal(t, 1, apiClient.calls["Events"]) }() - client.ContainerInspectFn = func(_ context.Context, ctrID string) (container.InspectResponse, error) { - if client.calls["ContainerInspect"] == 1 && ctrID == config.name() { + apiClient.ContainerInspectFn = func(_ context.Context, ctrID string) (container.InspectResponse, error) { + if apiClient.calls["ContainerInspect"] == 1 && ctrID == config.name() { return container.InspectResponse{ State: &container.State{ Status: "running", }, }, nil - } else if client.calls["ContainerInspect"] == 2 && ctrID == config.name() { + } else if apiClient.calls["ContainerInspect"] == 2 && ctrID == config.name() { return container.InspectResponse{ State: &container.State{ Status: "stopped", // can be anything but created @@ -173,8 +173,8 @@ func TestControllerWait(t *testing.T) { panic("unexpected call of ContainerInspect") } - client.EventsFn = func(_ context.Context, options engineapi.EventsListOptions) engineapi.EventsResult { - if reflect.DeepEqual(options, engineapi.EventsListOptions{ + apiClient.EventsFn = func(_ context.Context, options client.EventsListOptions) client.EventsResult { + if reflect.DeepEqual(options, client.EventsListOptions{ Since: "0", Filters: config.eventFilter(), }) { @@ -188,14 +188,14 @@ func TestControllerWait(t *testing.T) { func TestControllerWaitUnhealthy(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ContainerInspect"]) - assert.Equal(t, 1, client.calls["Events"]) - assert.Equal(t, 1, client.calls["ContainerStop"]) + assert.Equal(t, 1, apiClient.calls["ContainerInspect"]) + assert.Equal(t, 1, apiClient.calls["Events"]) + assert.Equal(t, 1, apiClient.calls["ContainerStop"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { + apiClient.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { return container.InspectResponse{ State: &container.State{ @@ -206,8 +206,8 @@ func TestControllerWaitUnhealthy(t *testing.T) { panic("unexpected call ContainerInspect") } res := makeEvents(t, config, events.ActionCreate, events.ActionHealthStatusUnhealthy) - client.EventsFn = func(_ context.Context, options engineapi.EventsListOptions) engineapi.EventsResult { - if reflect.DeepEqual(options, engineapi.EventsListOptions{ + apiClient.EventsFn = func(_ context.Context, options client.EventsListOptions) client.EventsResult { + if reflect.DeepEqual(options, client.EventsListOptions{ Since: "0", Filters: config.eventFilter(), }) { @@ -215,7 +215,7 @@ func TestControllerWaitUnhealthy(t *testing.T) { } panic("unexpected call of Events") } - client.ContainerStopFn = func(_ context.Context, containerName string, options engineapi.ContainerStopOptions) error { + apiClient.ContainerStopFn = func(_ context.Context, containerName string, options client.ContainerStopOptions) error { if containerName == config.name() && *options.Timeout == tenSecond { return nil } @@ -227,21 +227,21 @@ func TestControllerWaitUnhealthy(t *testing.T) { func TestControllerWaitExitError(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 2, client.calls["ContainerInspect"]) - assert.Equal(t, 1, client.calls["Events"]) + assert.Equal(t, 2, apiClient.calls["ContainerInspect"]) + assert.Equal(t, 1, apiClient.calls["Events"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { - if client.calls["ContainerInspect"] == 1 && containerName == config.name() { + apiClient.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { + if apiClient.calls["ContainerInspect"] == 1 && containerName == config.name() { return container.InspectResponse{ State: &container.State{ Status: "running", }, }, nil - } else if client.calls["ContainerInspect"] == 2 && containerName == config.name() { + } else if apiClient.calls["ContainerInspect"] == 2 && containerName == config.name() { return container.InspectResponse{ ID: "cid", State: &container.State{ @@ -254,8 +254,8 @@ func TestControllerWaitExitError(t *testing.T) { panic("unexpected call of ContainerInspect") } - client.EventsFn = func(_ context.Context, options engineapi.EventsListOptions) engineapi.EventsResult { - if reflect.DeepEqual(options, engineapi.EventsListOptions{ + apiClient.EventsFn = func(_ context.Context, options client.EventsListOptions) client.EventsResult { + if reflect.DeepEqual(options, client.EventsListOptions{ Since: "0", Filters: config.eventFilter(), }) { @@ -279,13 +279,13 @@ func checkExitError(t *testing.T, expectedCode int, err error) { func TestControllerWaitExitedClean(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ContainerInspect"]) + assert.Equal(t, 1, apiClient.calls["ContainerInspect"]) }() - client.ContainerInspectFn = func(_ context.Context, ctrID string) (container.InspectResponse, error) { + apiClient.ContainerInspectFn = func(_ context.Context, ctrID string) (container.InspectResponse, error) { if ctrID == config.name() { return container.InspectResponse{ State: &container.State{ @@ -302,13 +302,13 @@ func TestControllerWaitExitedClean(t *testing.T) { func TestControllerWaitExitedError(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ContainerInspect"]) + assert.Equal(t, 1, apiClient.calls["ContainerInspect"]) }() - client.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { + apiClient.ContainerInspectFn = func(_ context.Context, containerName string) (container.InspectResponse, error) { if containerName == config.name() { return container.InspectResponse{ ID: "cid", @@ -328,13 +328,13 @@ func TestControllerWaitExitedError(t *testing.T) { func TestControllerShutdown(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ContainerStop"]) + assert.Equal(t, 1, apiClient.calls["ContainerStop"]) }() - client.ContainerStopFn = func(_ context.Context, containerName string, option engineapi.ContainerStopOptions) error { + apiClient.ContainerStopFn = func(_ context.Context, containerName string, option client.ContainerStopOptions) error { if containerName == config.name() && *option.Timeout == tenSecond { return nil } @@ -346,13 +346,13 @@ func TestControllerShutdown(t *testing.T) { func TestControllerTerminate(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ContainerKill"]) + assert.Equal(t, 1, apiClient.calls["ContainerKill"]) }() - client.ContainerKillFn = func(_ context.Context, containerName, signal string) error { + apiClient.ContainerKillFn = func(_ context.Context, containerName, signal string) error { if containerName == config.name() && signal == "" { return nil } @@ -364,22 +364,22 @@ func TestControllerTerminate(t *testing.T) { func TestControllerRemove(t *testing.T) { task := genTask(t) - ctx, client, ctlr, config, finish := genTestControllerEnv(t, task) + ctx, apiClient, ctlr, config, finish := genTestControllerEnv(t, task) defer func() { finish() - assert.Equal(t, 1, client.calls["ContainerStop"]) - assert.Equal(t, 1, client.calls["ContainerRemove"]) + assert.Equal(t, 1, apiClient.calls["ContainerStop"]) + assert.Equal(t, 1, apiClient.calls["ContainerRemove"]) }() - client.ContainerStopFn = func(_ context.Context, container string, option engineapi.ContainerStopOptions) error { + apiClient.ContainerStopFn = func(_ context.Context, container string, option client.ContainerStopOptions) error { if container == config.name() && *option.Timeout == tenSecond { return nil } panic("unexpected call of ContainerStop") } - client.ContainerRemoveFn = func(_ context.Context, container string, options engineapi.ContainerRemoveOptions) error { - if container == config.name() && reflect.DeepEqual(options, engineapi.ContainerRemoveOptions{ + apiClient.ContainerRemoveFn = func(_ context.Context, container string, options client.ContainerRemoveOptions) error { + if container == config.name() && reflect.DeepEqual(options, client.ContainerRemoveOptions{ RemoveVolumes: true, Force: true, }) { @@ -400,8 +400,8 @@ func genTestControllerEnv(t *testing.T, task *api.Task) (context.Context, *StubA }, } - client := NewStubAPIClient() - ctlr, err := newController(client, testNodeDescription, task, nil) + apiClient := NewStubAPIClient() + ctlr, err := newController(apiClient, testNodeDescription, task, nil) assert.NoError(t, err) config, err := newContainerConfig(testNodeDescription, task) @@ -418,10 +418,10 @@ func genTestControllerEnv(t *testing.T, task *api.Task) (context.Context, *StubA } ctx, cancel := context.WithCancel(ctx) - return ctx, client, ctlr, config, cancel + return ctx, apiClient, ctlr, config, cancel } -func genTask(t *testing.T) *api.Task { +func genTask(*testing.T) *api.Task { const ( nodeID = "dockerexec-test-node-id" serviceID = "dockerexec-test-service" @@ -443,7 +443,7 @@ func genTask(t *testing.T) *api.Task { } } -func makeEvents(t *testing.T, container *containerConfig, actions ...events.Action) engineapi.EventsResult { +func makeEvents(t *testing.T, container *containerConfig, actions ...events.Action) client.EventsResult { t.Helper() evs := make(chan events.Message, len(actions)) for _, action := range actions { @@ -460,7 +460,7 @@ func makeEvents(t *testing.T, container *containerConfig, actions ...events.Acti } close(evs) - return engineapi.EventsResult{ + return client.EventsResult{ Messages: evs, Err: nil, } diff --git a/swarmd/dockerexec/executor.go b/swarmd/dockerexec/executor.go index 996136ca3a..0cc51cf048 100644 --- a/swarmd/dockerexec/executor.go +++ b/swarmd/dockerexec/executor.go @@ -6,7 +6,8 @@ import ( "strings" "sync" - engineapi "github.com/moby/moby/client" + "github.com/moby/moby/client" + "github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/agent/secrets" "github.com/moby/swarmkit/v2/api" @@ -14,7 +15,7 @@ import ( ) type executor struct { - client engineapi.APIClient + client client.APIClient secrets exec.SecretsManager genericResources []*api.GenericResource mutex sync.Mutex // This mutex protects the following node field @@ -22,7 +23,7 @@ type executor struct { } // NewExecutor returns an executor from the docker client. -func NewExecutor(client engineapi.APIClient, genericResources []*api.GenericResource) exec.Executor { +func NewExecutor(client client.APIClient, genericResources []*api.GenericResource) exec.Executor { var executor = &executor{ client: client, secrets: secrets.NewManager(), @@ -33,7 +34,7 @@ func NewExecutor(client engineapi.APIClient, genericResources []*api.GenericReso // Describe returns the underlying node description from the docker client. func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) { - res, err := e.client.Info(ctx, engineapi.InfoOptions{}) + res, err := e.client.Info(ctx, client.InfoOptions{}) if err != nil { return nil, err } @@ -57,7 +58,7 @@ func (e *executor) Describe(ctx context.Context) (*api.NodeDescription, error) { addPlugins("Authorization", info.Plugins.Authorization) // retrieve v2 plugins - v2plugins, err := e.client.PluginList(ctx, engineapi.PluginListOptions{}) + v2plugins, err := e.client.PluginList(ctx, client.PluginListOptions{}) if err != nil { log.L.WithError(err).Warning("PluginList operation failed") } else { diff --git a/swarmd/go.work.sum b/swarmd/go.work.sum index 50298f3839..a7f45b1ff9 100644 --- a/swarmd/go.work.sum +++ b/swarmd/go.work.sum @@ -532,6 +532,8 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9 github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 h1:59MxjQVfjXsBpLy+dbd2/ELV5ofnUkUZBvWSC85sheA= github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0/go.mod h1:OahwfttHWG6eJ0clwcfBAHoDI6X/LV/15hx/wlMZSrU= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.25.0 h1:3c8yed4lgqTt+oTQ+JNMDo+F4xprBf+O/il4ZC0nRLw= @@ -639,10 +641,6 @@ github.com/containerd/continuity v0.4.4 h1:/fNVfTJ7wIl/YPMHjf+5H32uFhl63JucB34Pl github.com/containerd/continuity v0.4.4/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4= github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= -github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= -github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= -github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= -github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU= github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY= @@ -708,10 +706,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954 h1:RMLoZVzv4GliuWafOuPuQDKSm1SJph7uCRnnS61JAn4= -github.com/docker/go-connections v0.7.0 h1:6SsRfJddP22WMrCkj19x9WKjEDTB+ahsdiGYf0mN39c= -github.com/docker/go-connections v0.7.0/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q= -github.com/docker/go-events v0.0.0-20260713150650-1ee7122bc07b h1:hNHejR92DFL4bzroHmZC1MQqt7WbgSFRt/Y0XqpJxIE= -github.com/docker/go-events v0.0.0-20260713150650-1ee7122bc07b/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= @@ -950,14 +944,8 @@ github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdI github.com/mitchellh/gox v0.4.0 h1:lfGJxY7ToLJQjHHwi0EX6uYBdK78egf954SQl13PQJc= github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= -github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= -github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= -github.com/moby/moby/api v1.55.0 h1:2/sexvQyqIWS8pRSCFddBfpW2qE7vR7FCL+vN8pxwMc= -github.com/moby/moby/api v1.55.0/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs= -github.com/moby/moby/client v0.5.1 h1:tYNaJno4c0HXz12y5BiqEDy0rVTYkWzI26lGvnTMiJw= -github.com/moby/moby/client v0.5.1/go.mod h1:odLstlZ6uSnfvAgVxMpvgmb8SUdd+siH2T0GBuxVAlM= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= @@ -975,6 +963,8 @@ github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85 github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= +github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= @@ -988,8 +978,6 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= -github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 h1:3snG66yBm59tKhhSPQrQ/0bCrv1LQbKt40LnUPiUxdc= @@ -1200,6 +1188,8 @@ go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVW go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4= go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4= +go.opentelemetry.io/proto/otlp v1.7.1 h1:gTOMpGDb0WTBOP8JaO72iL3auEZhVmAQg4ipjOVAtj4= +go.opentelemetry.io/proto/otlp v1.7.1/go.mod h1:b2rVh6rfI/s2pHWNlB7ILJcRALpcNDzKhACevjI+ZnE= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= @@ -1387,8 +1377,6 @@ k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b h1:wxEMGetGMur3J1xuGLQY7GEQYg9bZ k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= -pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=