Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update to v1.26.0-rc.0 #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion backend/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/sirupsen/logrus"
"google.golang.org/grpc"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
"k8s.io/kubernetes/pkg/kubelet/util"

"github.com/Mirantis/cri-dockerd/core"
Expand Down
12 changes: 6 additions & 6 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/pflag"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
)

const (
Expand All @@ -57,20 +57,20 @@ func NewDockerCRICommand(stopCh <-chan struct{}) *cobra.Command {
// initial flag parse, since we disable cobra's flag parsing
if err := cleanFlagSet.Parse(args); err != nil {
cmd.Usage()
logrus.Fatal(err)
logrus.Panic(err)
}

// check if there are non-flag arguments in the command line
cmds := cleanFlagSet.Args()
if len(cmds) > 0 {
cmd.Usage()
logrus.Fatalf("Unknown command: %s", cmds[0])
logrus.Panicf("Unknown command: %s", cmds[0])
}

// short-circuit on help
help, err := cleanFlagSet.GetBool("help")
if err != nil {
logrus.Fatal(`"help" flag is non-bool`)
logrus.Panic(`"help" flag is non-bool`)
}
if help {
cmd.Help()
Expand Down Expand Up @@ -105,13 +105,13 @@ func NewDockerCRICommand(stopCh <-chan struct{}) *cobra.Command {
if logFlag != "" {
level, err := logrus.ParseLevel(logFlag)
if err != nil {
logrus.Fatalf("Unknown log level: %s", logFlag)
logrus.Panicf("Unknown log level: %s", logFlag)
}
logrus.SetLevel(level)
}

if err := RunCriDockerd(kubeletFlags, stopCh); err != nil {
logrus.Fatal(err)
logrus.Panic(err)
}
},
}
Expand Down
7 changes: 3 additions & 4 deletions config/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package config

import (
"io/ioutil"
"os"
"path/filepath"
"time"
Expand All @@ -36,7 +35,7 @@ type OSInterface interface {
Hostname() (name string, err error)
Chtimes(path string, atime time.Time, mtime time.Time) error
Pipe() (r *os.File, w *os.File, err error)
ReadDir(dirname string) ([]os.FileInfo, error)
ReadDir(dirname string) ([]os.DirEntry, error)
Glob(pattern string) ([]string, error)
Open(name string) (*os.File, error)
OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
Expand Down Expand Up @@ -99,8 +98,8 @@ func (RealOS) Pipe() (r *os.File, w *os.File, err error) {
}

// ReadDir will call ioutil.ReadDir to return the files under the directory.
func (RealOS) ReadDir(dirname string) ([]os.FileInfo, error) {
return ioutil.ReadDir(dirname)
func (RealOS) ReadDir(dirname string) ([]os.DirEntry, error) {
return os.ReadDir(dirname)
}

// Glob will call filepath.Glob to return the names of all files matching
Expand Down
17 changes: 12 additions & 5 deletions containermanager/container_manager_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

/*
Expand Down Expand Up @@ -27,7 +28,10 @@ import (

"github.com/opencontainers/runc/libcontainer/cgroups"
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
cgroupfs2 "github.com/opencontainers/runc/libcontainer/cgroups/fs2"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/devices"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
utilversion "k8s.io/apimachinery/pkg/util/version"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -75,7 +79,7 @@ func (m *containerManager) Start() error {
if len(m.cgroupsName) != 0 {
manager, err := createCgroupManager(m.cgroupsName)
if err != nil {
return err
return errors.Wrapf(err, "failed to create cgroup manager %s", m.cgroupsName)
}
m.cgroupsManager = manager
}
Expand Down Expand Up @@ -124,18 +128,21 @@ func createCgroupManager(name string) (cgroups.Manager, error) {
Memory: int64(memoryLimit),
MemorySwap: -1,
SkipDevices: true,
Devices: []*configs.DeviceRule{
Devices: []*devices.Rule{
{
Minor: configs.Wildcard,
Major: configs.Wildcard,
Minor: devices.Wildcard,
Major: devices.Wildcard,
Type: 'a',
Permissions: "rwm",
Allow: true,
},
},
},
}
return cgroupfs.NewManager(cg, nil, false), nil
if cgroups.IsCgroup2UnifiedMode() {
return cgroupfs2.NewManager(cg, "")
}
return cgroupfs.NewManager(cg, nil)
}

// getMemoryCapacity returns the memory capacity on the machine in bytes.
Expand Down
4 changes: 2 additions & 2 deletions core/container_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package core

import (
"context"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/Mirantis/cri-dockerd/streaming"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
Expand All @@ -37,4 +38,3 @@ func (ds *dockerService) Attach(
}
return ds.streamingServer.GetAttach(req)
}

2 changes: 1 addition & 1 deletion core/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"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/v1alpha2"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// CreateContainer creates a new container in the given PodSandbox
Expand Down
6 changes: 3 additions & 3 deletions core/container_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"bytes"
"context"
"fmt"
"time"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/Mirantis/cri-dockerd/streaming"
"github.com/Mirantis/cri-dockerd/utils"
"google.golang.org/grpc/codes"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
"time"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// ExecSync executes a command in the container, and returns the stdout output.
Expand Down Expand Up @@ -79,4 +80,3 @@ func (ds *dockerService) Exec(
}
return ds.streamingServer.GetExec(req)
}

3 changes: 2 additions & 1 deletion core/container_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package core

import (
"context"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/sirupsen/logrus"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// ListContainers lists all containers matching the filter.
Expand Down
7 changes: 4 additions & 3 deletions core/container_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package core
import (
"context"
"fmt"
"time"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/docker/docker/api/types"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
"time"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// RemoveContainer removes the container.
Expand Down Expand Up @@ -92,4 +93,4 @@ func getContainerTimestamps(r *types.ContainerJSON) (time.Time, time.Time, time.
return createdAt, startedAt, finishedAt, err
}
return createdAt, startedAt, finishedAt, nil
}
}
4 changes: 2 additions & 2 deletions core/container_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package core
import (
"context"
"fmt"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"

v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// StartContainer starts the container.
Expand Down Expand Up @@ -58,4 +59,3 @@ func transformStartContainerError(err error) error {
}
return err
}

4 changes: 2 additions & 2 deletions core/container_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package core
import (
"context"
"fmt"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/sirupsen/logrus"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// ContainerStatus inspects the docker container and returns the status.
Expand Down Expand Up @@ -146,4 +147,3 @@ func (ds *dockerService) ContainerStatus(
}
return &res, nil
}

4 changes: 2 additions & 2 deletions core/container_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ package core

import (
"context"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
"time"

v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// StopContainer stops a running container with a grace period (i.e., timeout).
Expand All @@ -33,4 +34,3 @@ func (ds *dockerService) StopContainer(
}
return &v1.StopContainerResponse{}, nil
}

2 changes: 1 addition & 1 deletion core/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
)

Expand Down
3 changes: 2 additions & 1 deletion core/container_update_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ package core
import (
"context"
"fmt"

"github.com/docker/docker/api/types/container"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
)

func (ds *dockerService) UpdateContainerResources(
Expand Down
2 changes: 1 addition & 1 deletion core/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
dockercontainer "github.com/docker/docker/api/types/container"
dockerimagetypes "github.com/docker/docker/api/types/image"

runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"

digest "github.com/opencontainers/go-digest"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down
2 changes: 1 addition & 1 deletion core/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
dockertypes "github.com/docker/docker/api/types"
"github.com/stretchr/testify/assert"

runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
)

func TestConvertDockerStatusToRuntimeAPIState(t *testing.T) {
Expand Down
17 changes: 16 additions & 1 deletion core/docker_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"github.com/sirupsen/logrus"

v1 "k8s.io/api/core/v1"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
)

const (
Expand Down Expand Up @@ -452,3 +452,18 @@ func (ds *dockerService) getDockerVersionFromCache() (*dockertypes.Version, erro
}
return dv, nil
}

func (ds *dockerService) CheckpointContainer(ctx context.Context, options *runtimeapi.CheckpointContainerRequest) (*runtimeapi.CheckpointContainerResponse, error) {
return nil, nil
}
func (ds *dockerService) GetContainerEvents(eventReq *runtimeapi.GetEventsRequest, containerEventServer runtimeapi.RuntimeService_GetContainerEventsServer) error {
return nil
}

func (ds *dockerService) ListMetricDescriptors(ctx context.Context, s *runtimeapi.ListMetricDescriptorsRequest) (*runtimeapi.ListMetricDescriptorsResponse, error) {
return nil, nil
}

func (ds *dockerService) ListPodSandboxMetrics(ctx context.Context, s *runtimeapi.ListPodSandboxMetricsRequest) (*runtimeapi.ListPodSandboxMetricsResponse, error) {
return nil, nil
}
4 changes: 2 additions & 2 deletions core/docker_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/util/clock"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
clock "k8s.io/utils/clock/testing"

"github.com/Mirantis/cri-dockerd/libdocker"
"github.com/Mirantis/cri-dockerd/network"
Expand Down
4 changes: 3 additions & 1 deletion core/helpers_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

/*
Expand All @@ -20,11 +21,12 @@ package core

import (
"fmt"

"github.com/blang/semver"
dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
"github.com/sirupsen/logrus"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// DefaultMemorySwap always returns 0 for no memory swap in a sandbox
Expand Down
7 changes: 3 additions & 4 deletions core/helpers_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

/*
Expand All @@ -20,7 +21,6 @@ package core

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -65,11 +65,10 @@ func TestGetSeccompSecurityOpts(t *testing.T) {
}

func TestLoadSeccompLocalhostProfiles(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "seccomp-local-profile-test")
require.NoError(t, err)
tmpdir := filepath.Join(os.TempDir(), "seccomp-local-profile-test")
defer os.RemoveAll(tmpdir)
testProfile := `{"foo": "bar"}`
err = ioutil.WriteFile(filepath.Join(tmpdir, "test"), []byte(testProfile), 0644)
err := os.WriteFile(filepath.Join(tmpdir, "test"), []byte(testProfile), 0644)
require.NoError(t, err)

tests := []struct {
Expand Down
Loading