Skip to content

Commit

Permalink
Bump github.com/docker/docker to v25.0.6 (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwneisen authored Dec 12, 2024
1 parent 64d89e3 commit 7119864
Show file tree
Hide file tree
Showing 132 changed files with 2,498 additions and 1,342 deletions.
1 change: 1 addition & 0 deletions .github/workflows/Merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- release/*

jobs:
vet:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name: PR
on:
pull_request:
types: ['opened', 'reopened', 'synchronize']
branches: [ "master", release/* ]
branches:
- master
- release/*
paths:
- '**' # all files otherwise excludes wont work
- '!**/**/*.md' # ignore markdown files
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ run: cri-dockerd ## Run cri-docker in a running minikube
dev: cri-dockerd ## Run cri-docker in a running minikube
./scripts/replace-in-minikube

.PHONY: vendor
vendor: ## Go mod tidy and vendor
go mod tidy
go mod vendor

#### Testing
.PHONY: integration
integration: ## Run integration tests
Expand All @@ -82,6 +87,12 @@ integration: ## Run integration tests
test: ## Run unit tests
go test ./...

# This needs the archived version of mockgen
# https://github.com/golang/mock
.PHONY: mock
mock: ## Generate the test mocks
mockgen -source libdocker/client.go -destination libdocker/testing/mock_client.go -package testing

### Documentation
.PHONY: docs
docs: ## Run docs server
Expand Down
3 changes: 1 addition & 2 deletions core/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"path/filepath"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/strslice"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
Expand Down Expand Up @@ -65,7 +64,7 @@ func (ds *dockerService) CreateContainer(
}
containerName := makeContainerName(sandboxConfig, config)
terminationMessagePath, _ := config.Annotations["io.kubernetes.container.terminationMessagePath"]
createConfig := types.ContainerCreateConfig{
createConfig := libdocker.ContainerCreateConfig{
Name: containerName,
Config: &container.Config{
Entrypoint: strslice.StrSlice(config.Command),
Expand Down
8 changes: 5 additions & 3 deletions core/helpers_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ package core

import (
"fmt"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/blang/semver"
dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
Expand All @@ -34,7 +36,7 @@ func DefaultMemorySwap() int64 {
}

func (ds *dockerService) updateCreateConfig(
createConfig *dockertypes.ContainerCreateConfig,
createConfig *libdocker.ContainerCreateConfig,
config *runtimeapi.ContainerConfig,
sandboxConfig *runtimeapi.PodSandboxConfig,
podSandboxID string, securityOptSep rune, apiVersion *semver.Version) error {
Expand Down Expand Up @@ -97,12 +99,12 @@ func getNetworkNamespace(c *dockertypes.ContainerJSON) (string, error) {

type containerCleanupInfo struct{}

// applyPlatformSpecificDockerConfig applies platform-specific configurations to a dockertypes.ContainerCreateConfig struct.
// applyPlatformSpecificDockerConfig applies platform-specific configurations to a libdocker.ContainerCreateConfig struct.
// The containerCleanupInfo struct it returns will be passed as is to performPlatformSpecificContainerCleanup
// after either the container creation has failed or the container has been removed.
func (ds *dockerService) applyPlatformSpecificDockerConfig(
*runtimeapi.CreateContainerRequest,
*dockertypes.ContainerCreateConfig,
*libdocker.ContainerCreateConfig,
) (*containerCleanupInfo, error) {
return nil, nil
}
Expand Down
3 changes: 2 additions & 1 deletion core/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/Mirantis/cri-dockerd/libdocker"

dockertypes "github.com/docker/docker/api/types"
dockerregistry "github.com/docker/docker/api/types/registry"
dockernat "github.com/docker/go-connections/nat"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -140,7 +141,7 @@ func TestParsingCreationConflictError(t *testing.T) {

func TestEnsureSandboxImageExists(t *testing.T) {
sandboxImage := "gcr.io/test/image"
authConfig := dockertypes.AuthConfig{Username: "user", Password: "pass"}
authConfig := dockerregistry.AuthConfig{Username: "user", Password: "pass"}
for desc, test := range map[string]struct {
injectImage bool
imgNeedsAuth bool
Expand Down
7 changes: 4 additions & 3 deletions core/helpers_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package core
import (
"fmt"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/blang/semver"
dockertypes "github.com/docker/docker/api/types"
"github.com/sirupsen/logrus"
Expand All @@ -47,7 +48,7 @@ func (ds *dockerService) getSandBoxSecurityOpts(separator rune) []string {
}

func (ds *dockerService) updateCreateConfig(
createConfig *dockertypes.ContainerCreateConfig,
createConfig *libdocker.ContainerCreateConfig,
config *runtimeapi.ContainerConfig,
sandboxConfig *runtimeapi.PodSandboxConfig,
podSandboxID string, securityOptSep rune, apiVersion *semver.Version) error {
Expand All @@ -66,12 +67,12 @@ func getNetworkNamespace(c *dockertypes.ContainerJSON) (string, error) {

type containerCleanupInfo struct{}

// applyPlatformSpecificDockerConfig applies platform-specific configurations to a dockertypes.ContainerCreateConfig struct.
// applyPlatformSpecificDockerConfig applies platform-specific configurations to a libdocker.ContainerCreateConfig struct.
// The containerCleanupInfo struct it returns will be passed as is to performPlatformSpecificContainerCleanup
// after either the container creation has failed or the container has been removed.
func (ds *dockerService) applyPlatformSpecificDockerConfig(
*runtimeapi.CreateContainerRequest,
*dockertypes.ContainerCreateConfig,
*libdocker.ContainerCreateConfig,
) (*containerCleanupInfo, error) {
return nil, nil
}
Expand Down
12 changes: 7 additions & 5 deletions core/helpers_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import (
"crypto/rand"
"encoding/hex"
"fmt"
"golang.org/x/sys/windows/registry"
"os"
"regexp"
"runtime"

"golang.org/x/sys/windows/registry"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/blang/semver"
dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
Expand All @@ -42,7 +44,7 @@ func DefaultMemorySwap() int64 {
}

func (ds *dockerService) updateCreateConfig(
createConfig *dockertypes.ContainerCreateConfig,
createConfig *libdocker.ContainerCreateConfig,
config *runtimeapi.ContainerConfig,
sandboxConfig *runtimeapi.PodSandboxConfig,
podSandboxID string, securityOptSep rune, apiVersion *semver.Version) error {
Expand Down Expand Up @@ -147,12 +149,12 @@ type containerCleanupInfo struct {
gMSARegistryValueName string
}

// applyPlatformSpecificDockerConfig applies platform-specific configurations to a dockertypes.ContainerCreateConfig struct.
// applyPlatformSpecificDockerConfig applies platform-specific configurations to a libdocker.ContainerCreateConfig struct.
// The containerCleanupInfo struct it returns will be passed as is to performPlatformSpecificContainerCleanup
// after either the container creation has failed or the container has been removed.
func (ds *dockerService) applyPlatformSpecificDockerConfig(
request *runtimeapi.CreateContainerRequest,
createConfig *dockertypes.ContainerCreateConfig,
createConfig *libdocker.ContainerCreateConfig,
) (*containerCleanupInfo, error) {
cleanupInfo := &containerCleanupInfo{}

Expand All @@ -173,7 +175,7 @@ func (ds *dockerService) applyPlatformSpecificDockerConfig(
// https://github.com/moby/moby/pull/38777
func applyGMSAConfig(
config *runtimeapi.ContainerConfig,
createConfig *dockertypes.ContainerCreateConfig,
createConfig *libdocker.ContainerCreateConfig,
cleanupInfo *containerCleanupInfo,
) error {
var credSpec string
Expand Down
3 changes: 2 additions & 1 deletion core/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

dockertypes "github.com/docker/docker/api/types"
dockerfilters "github.com/docker/docker/api/types/filters"
dockerregistry "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/pkg/jsonmessage"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -137,7 +138,7 @@ func (ds *dockerService) PullImage(
) (*runtimeapi.PullImageResponse, error) {
image := r.GetImage()
auth := r.GetAuth()
authConfig := dockertypes.AuthConfig{}
authConfig := dockerregistry.AuthConfig{}

if auth != nil {
authConfig.Username = auth.Username
Expand Down
24 changes: 13 additions & 11 deletions core/sandbox_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ package core

import (
"fmt"
"os"
"strings"
"time"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/Mirantis/cri-dockerd/utils"
"github.com/Mirantis/cri-dockerd/utils/errors"
"k8s.io/kubernetes/pkg/credentialprovider"
"os"
"strings"
"time"

"github.com/Mirantis/cri-dockerd/config"
dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
dockerregistry "github.com/docker/docker/api/types/registry"
"github.com/sirupsen/logrus"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
)
Expand Down Expand Up @@ -169,7 +171,7 @@ func (ds *dockerService) getPodSandboxDetails(
func (ds *dockerService) applySandboxLinuxOptions(
hc *dockercontainer.HostConfig,
lc *runtimeapi.LinuxPodSandboxConfig,
createConfig *dockertypes.ContainerCreateConfig,
createConfig *libdocker.ContainerCreateConfig,
image string,
separator rune,
) error {
Expand Down Expand Up @@ -207,11 +209,11 @@ func (ds *dockerService) applySandboxResources(
return nil
}

// makeSandboxDockerConfig returns dockertypes.ContainerCreateConfig based on runtimeapi.PodSandboxConfig.
// makeSandboxDockerConfig returns libdocker.ContainerCreateConfig based on runtimeapi.PodSandboxConfig.
func (ds *dockerService) makeSandboxDockerConfig(
c *runtimeapi.PodSandboxConfig,
image string,
) (*dockertypes.ContainerCreateConfig, error) {
) (*libdocker.ContainerCreateConfig, error) {
// Merge annotations and labels because docker supports only labels.
labels := makeLabels(c.GetLabels(), c.GetAnnotations())
// Apply a label to distinguish sandboxes from regular containers.
Expand All @@ -222,7 +224,7 @@ func (ds *dockerService) makeSandboxDockerConfig(
hc := &dockercontainer.HostConfig{
IpcMode: dockercontainer.IpcMode("shareable"),
}
createConfig := &dockertypes.ContainerCreateConfig{
createConfig := &libdocker.ContainerCreateConfig{
Name: makeSandboxName(c),
Config: &dockercontainer.Config{
Hostname: c.Hostname,
Expand Down Expand Up @@ -374,7 +376,7 @@ func rewriteFile(filePath, stringToWrite string) error {

func recoverFromCreationConflictIfNeeded(
client libdocker.DockerClientInterface,
createConfig dockertypes.ContainerCreateConfig,
createConfig libdocker.ContainerCreateConfig,
err error,
) (*dockercontainer.CreateResponse, error) {
matches := conflictRE.FindStringSubmatch(err.Error())
Expand All @@ -384,7 +386,7 @@ func recoverFromCreationConflictIfNeeded(

id := matches[1]
logrus.Infof("Unable to create pod sandbox due to conflict. Attempting to remove sandbox. Container %v", id)
rmErr := client.RemoveContainer(id, dockertypes.ContainerRemoveOptions{RemoveVolumes: true})
rmErr := client.RemoveContainer(id, dockercontainer.RemoveOptions{RemoveVolumes: true})
if rmErr == nil {
logrus.Infof("Successfully removed conflicting container: %v", id)
return nil, err
Expand Down Expand Up @@ -421,7 +423,7 @@ func ensureSandboxImageExists(client libdocker.DockerClientInterface, image stri
if !withCredentials {
logrus.Infof("Pulling the image without credentials. Image: %v", image)

err := client.PullImage(image, dockertypes.AuthConfig{}, dockertypes.ImagePullOptions{})
err := client.PullImage(image, dockerregistry.AuthConfig{}, dockertypes.ImagePullOptions{})
if err != nil {
return fmt.Errorf("failed pulling image %q: %v", image, err)
}
Expand All @@ -431,7 +433,7 @@ func ensureSandboxImageExists(client libdocker.DockerClientInterface, image stri

var pullErrs []error
for _, currentCreds := range creds {
authConfig := dockertypes.AuthConfig(currentCreds)
authConfig := dockerregistry.AuthConfig(currentCreds)
err := client.PullImage(image, authConfig, dockertypes.ImagePullOptions{})
// If there was no error, return success
if err == nil {
Expand Down
12 changes: 2 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/coreos/go-systemd/v22 v22.5.0
github.com/davecgh/go-spew v1.1.1
github.com/docker/distribution v2.8.3+incompatible
github.com/docker/docker v24.0.9+incompatible
github.com/docker/docker v25.0.6+incompatible
github.com/docker/go-connections v0.5.0
github.com/emicklei/go-restful v2.16.0+incompatible
github.com/golang/mock v1.6.0
Expand Down Expand Up @@ -50,13 +50,9 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/checkpoint-restore/go-criu/v5 v5.3.0 // indirect
github.com/cilium/ebpf v0.9.1 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/containerd/containerd v1.6.26 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
Expand Down Expand Up @@ -97,7 +93,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/mrunalp/fileutils v0.5.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78 // indirect
Expand All @@ -107,12 +102,8 @@ require (
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/seccomp/libseccomp-golang v0.10.0 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/urfave/cli v1.22.4 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
Expand Down Expand Up @@ -160,6 +151,7 @@ require (
)

replace (
go.opentelemetry.io/otel/exporters/otlp/otlptrace => go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0
google.golang.org/grpc/naming => google.golang.org/grpc v1.29.0
k8s.io/api => k8s.io/api v0.29.10
k8s.io/apimachinery => k8s.io/apimachinery v0.29.10
Expand Down
Loading

0 comments on commit 7119864

Please sign in to comment.