diff --git a/pkg/kubelet/cri/remote/conversion.go b/pkg/kubelet/cri/remote/conversion.go index c05b6bf81b3..de4a3cab49e 100644 --- a/pkg/kubelet/cri/remote/conversion.go +++ b/pkg/kubelet/cri/remote/conversion.go @@ -44,14 +44,20 @@ func fromV1alpha2ContainerStatus(from *v1alpha2.ContainerStatus) *runtimeapi.Con } func fromV1alpha2ExecResponse(from *v1alpha2.ExecResponse) *runtimeapi.ExecResponse { + // If this function changes, also adapt the corresponding Exec dockershim code in + // pkg/kubelet/dockershim/docker_streaming.go return (*runtimeapi.ExecResponse)(unsafe.Pointer(from)) } func fromV1alpha2AttachResponse(from *v1alpha2.AttachResponse) *runtimeapi.AttachResponse { + // If this function changes, also adapt the corresponding Attach dockershim code in + // pkg/kubelet/dockershim/docker_streaming.go return (*runtimeapi.AttachResponse)(unsafe.Pointer(from)) } func fromV1alpha2PortForwardResponse(from *v1alpha2.PortForwardResponse) *runtimeapi.PortForwardResponse { + // If this function changes, also adapt the corresponding PortForward dockershim code in + // pkg/kubelet/dockershim/docker_streaming.go return (*runtimeapi.PortForwardResponse)(unsafe.Pointer(from)) } @@ -108,14 +114,20 @@ func v1alpha2LinuxContainerResources(from *runtimeapi.LinuxContainerResources) * } func v1alpha2ExecRequest(from *runtimeapi.ExecRequest) *v1alpha2.ExecRequest { + // If this function changes, also adapt the corresponding Exec dockershim code in + // pkg/kubelet/dockershim/docker_streaming.go return (*v1alpha2.ExecRequest)(unsafe.Pointer(from)) } func v1alpha2AttachRequest(from *runtimeapi.AttachRequest) *v1alpha2.AttachRequest { + // If this function changes, also adapt the corresponding Attach dockershim code in + // pkg/kubelet/dockershim/docker_streaming.go return (*v1alpha2.AttachRequest)(unsafe.Pointer(from)) } func v1alpha2PortForwardRequest(from *runtimeapi.PortForwardRequest) *v1alpha2.PortForwardRequest { + // If this function changes, also adapt the corresponding PortForward dockershim code in + // pkg/kubelet/dockershim/docker_streaming.go return (*v1alpha2.PortForwardRequest)(unsafe.Pointer(from)) } diff --git a/pkg/kubelet/dockershim/convert.go b/pkg/kubelet/dockershim/convert.go index 0899de5ea25..dcbe9d07333 100644 --- a/pkg/kubelet/dockershim/convert.go +++ b/pkg/kubelet/dockershim/convert.go @@ -26,7 +26,7 @@ import ( dockertypes "github.com/docker/docker/api/types" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" ) diff --git a/pkg/kubelet/dockershim/convert_test.go b/pkg/kubelet/dockershim/convert_test.go index f3ece1e1eef..f663fe0122d 100644 --- a/pkg/kubelet/dockershim/convert_test.go +++ b/pkg/kubelet/dockershim/convert_test.go @@ -25,7 +25,7 @@ import ( dockertypes "github.com/docker/docker/api/types" "github.com/stretchr/testify/assert" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) func TestConvertDockerStatusToRuntimeAPIState(t *testing.T) { diff --git a/pkg/kubelet/dockershim/docker_container.go b/pkg/kubelet/dockershim/docker_container.go index 6d13a0f4169..8cc686d9885 100644 --- a/pkg/kubelet/dockershim/docker_container.go +++ b/pkg/kubelet/dockershim/docker_container.go @@ -32,7 +32,7 @@ import ( dockerstrslice "github.com/docker/docker/api/types/strslice" "k8s.io/klog/v2" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" ) diff --git a/pkg/kubelet/dockershim/docker_container_test.go b/pkg/kubelet/dockershim/docker_container_test.go index e30cbec2864..071864cbe1b 100644 --- a/pkg/kubelet/dockershim/docker_container_test.go +++ b/pkg/kubelet/dockershim/docker_container_test.go @@ -32,7 +32,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" containertest "k8s.io/kubernetes/pkg/kubelet/container/testing" ) diff --git a/pkg/kubelet/dockershim/docker_container_unsupported.go b/pkg/kubelet/dockershim/docker_container_unsupported.go index 133d2f324c7..597002bbe4d 100644 --- a/pkg/kubelet/dockershim/docker_container_unsupported.go +++ b/pkg/kubelet/dockershim/docker_container_unsupported.go @@ -21,7 +21,7 @@ package dockershim import ( dockertypes "github.com/docker/docker/api/types" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) type containerCleanupInfo struct{} diff --git a/pkg/kubelet/dockershim/docker_container_windows.go b/pkg/kubelet/dockershim/docker_container_windows.go index cb3c3e87377..e76b4fd3080 100644 --- a/pkg/kubelet/dockershim/docker_container_windows.go +++ b/pkg/kubelet/dockershim/docker_container_windows.go @@ -30,7 +30,7 @@ import ( dockertypes "github.com/docker/docker/api/types" dockercontainer "github.com/docker/docker/api/types/container" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) type containerCleanupInfo struct { diff --git a/pkg/kubelet/dockershim/docker_container_windows_test.go b/pkg/kubelet/dockershim/docker_container_windows_test.go index f127a36a311..c7af2818774 100644 --- a/pkg/kubelet/dockershim/docker_container_windows_test.go +++ b/pkg/kubelet/dockershim/docker_container_windows_test.go @@ -29,7 +29,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/sys/windows/registry" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) type dummyRegistryKey struct { diff --git a/pkg/kubelet/dockershim/docker_image.go b/pkg/kubelet/dockershim/docker_image.go index e8fbca9fe4d..1982adedbd0 100644 --- a/pkg/kubelet/dockershim/docker_image.go +++ b/pkg/kubelet/dockershim/docker_image.go @@ -28,7 +28,7 @@ import ( dockerfilters "github.com/docker/docker/api/types/filters" "github.com/docker/docker/pkg/jsonmessage" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/klog/v2" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" ) diff --git a/pkg/kubelet/dockershim/docker_image_linux.go b/pkg/kubelet/dockershim/docker_image_linux.go index 11466fec29a..ecd695d65db 100644 --- a/pkg/kubelet/dockershim/docker_image_linux.go +++ b/pkg/kubelet/dockershim/docker_image_linux.go @@ -25,7 +25,7 @@ import ( "path/filepath" "time" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) // ImageFsInfo returns information of the filesystem that is used to store images. diff --git a/pkg/kubelet/dockershim/docker_image_test.go b/pkg/kubelet/dockershim/docker_image_test.go index 4592838011e..5a0e15cc225 100644 --- a/pkg/kubelet/dockershim/docker_image_test.go +++ b/pkg/kubelet/dockershim/docker_image_test.go @@ -28,7 +28,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" ) diff --git a/pkg/kubelet/dockershim/docker_image_unsupported.go b/pkg/kubelet/dockershim/docker_image_unsupported.go index 3b84fc37e98..02420213e54 100644 --- a/pkg/kubelet/dockershim/docker_image_unsupported.go +++ b/pkg/kubelet/dockershim/docker_image_unsupported.go @@ -23,7 +23,7 @@ import ( "context" "fmt" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) // ImageFsInfo returns information of the filesystem that is used to store images. diff --git a/pkg/kubelet/dockershim/docker_image_windows.go b/pkg/kubelet/dockershim/docker_image_windows.go index af77b504da9..ad617116677 100644 --- a/pkg/kubelet/dockershim/docker_image_windows.go +++ b/pkg/kubelet/dockershim/docker_image_windows.go @@ -25,7 +25,7 @@ import ( "k8s.io/klog/v2" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/winstats" ) diff --git a/pkg/kubelet/dockershim/docker_logs.go b/pkg/kubelet/dockershim/docker_logs.go index 21faa2a8183..d68903ef15c 100644 --- a/pkg/kubelet/dockershim/docker_logs.go +++ b/pkg/kubelet/dockershim/docker_logs.go @@ -23,7 +23,7 @@ import ( "context" "fmt" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) // ReopenContainerLog reopens the container log file. diff --git a/pkg/kubelet/dockershim/docker_sandbox.go b/pkg/kubelet/dockershim/docker_sandbox.go index 211f2c0c575..8914786a91d 100644 --- a/pkg/kubelet/dockershim/docker_sandbox.go +++ b/pkg/kubelet/dockershim/docker_sandbox.go @@ -31,7 +31,7 @@ import ( dockercontainer "github.com/docker/docker/api/types/container" dockerfilters "github.com/docker/docker/api/types/filters" utilerrors "k8s.io/apimachinery/pkg/util/errors" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/klog/v2" "k8s.io/kubernetes/pkg/kubelet/checkpointmanager" "k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors" diff --git a/pkg/kubelet/dockershim/docker_sandbox_test.go b/pkg/kubelet/dockershim/docker_sandbox_test.go index 69f3c2093a2..c2c2e2c6100 100644 --- a/pkg/kubelet/dockershim/docker_sandbox_test.go +++ b/pkg/kubelet/dockershim/docker_sandbox_test.go @@ -31,7 +31,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" "k8s.io/kubernetes/pkg/kubelet/dockershim/network" diff --git a/pkg/kubelet/dockershim/docker_service.go b/pkg/kubelet/dockershim/docker_service.go index 2cd840252b6..c6ad4aed011 100644 --- a/pkg/kubelet/dockershim/docker_service.go +++ b/pkg/kubelet/dockershim/docker_service.go @@ -35,7 +35,7 @@ import ( "k8s.io/klog/v2" v1 "k8s.io/api/core/v1" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config" "k8s.io/kubernetes/pkg/kubelet/checkpointmanager" "k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors" diff --git a/pkg/kubelet/dockershim/docker_service_test.go b/pkg/kubelet/dockershim/docker_service_test.go index 00aea98ccfb..6f89594b69e 100644 --- a/pkg/kubelet/dockershim/docker_service_test.go +++ b/pkg/kubelet/dockershim/docker_service_test.go @@ -30,7 +30,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/checkpointmanager" containertest "k8s.io/kubernetes/pkg/kubelet/container/testing" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" diff --git a/pkg/kubelet/dockershim/docker_stats.go b/pkg/kubelet/dockershim/docker_stats.go index 558b67d2fad..e673bcd1170 100644 --- a/pkg/kubelet/dockershim/docker_stats.go +++ b/pkg/kubelet/dockershim/docker_stats.go @@ -24,7 +24,7 @@ import ( "errors" "fmt" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) var ErrNotImplemented = errors.New("Not implemented") diff --git a/pkg/kubelet/dockershim/docker_stats_linux.go b/pkg/kubelet/dockershim/docker_stats_linux.go index 3810ae4cf33..b7be67a6fe4 100644 --- a/pkg/kubelet/dockershim/docker_stats_linux.go +++ b/pkg/kubelet/dockershim/docker_stats_linux.go @@ -22,7 +22,7 @@ package dockershim import ( "time" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) func (ds *dockerService) getContainerStats(c *runtimeapi.Container) (*runtimeapi.ContainerStats, error) { diff --git a/pkg/kubelet/dockershim/docker_stats_test.go b/pkg/kubelet/dockershim/docker_stats_test.go index 6ee89cea5d1..a26743aa7d3 100644 --- a/pkg/kubelet/dockershim/docker_stats_test.go +++ b/pkg/kubelet/dockershim/docker_stats_test.go @@ -25,7 +25,7 @@ import ( dockertypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/assert" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" ) diff --git a/pkg/kubelet/dockershim/docker_stats_unsupported.go b/pkg/kubelet/dockershim/docker_stats_unsupported.go index 2b7688ff93a..1f3f5747a4b 100644 --- a/pkg/kubelet/dockershim/docker_stats_unsupported.go +++ b/pkg/kubelet/dockershim/docker_stats_unsupported.go @@ -22,7 +22,7 @@ package dockershim import ( "fmt" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) func (ds *dockerService) getContainerStats(c *runtimeapi.Container) (*runtimeapi.ContainerStats, error) { diff --git a/pkg/kubelet/dockershim/docker_stats_windows.go b/pkg/kubelet/dockershim/docker_stats_windows.go index a60a5346993..df9f0b37597 100644 --- a/pkg/kubelet/dockershim/docker_stats_windows.go +++ b/pkg/kubelet/dockershim/docker_stats_windows.go @@ -24,7 +24,7 @@ import ( "time" "github.com/Microsoft/hcsshim" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/klog/v2" ) diff --git a/pkg/kubelet/dockershim/docker_streaming.go b/pkg/kubelet/dockershim/docker_streaming.go index b95611fefb8..106a5ff1f43 100644 --- a/pkg/kubelet/dockershim/docker_streaming.go +++ b/pkg/kubelet/dockershim/docker_streaming.go @@ -27,13 +27,15 @@ import ( "io" "math" "time" + "unsafe" dockertypes "github.com/docker/docker/api/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "k8s.io/client-go/tools/remotecommand" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapiv1 "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" "k8s.io/kubernetes/pkg/kubelet/cri/streaming" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" @@ -123,7 +125,14 @@ func (ds *dockerService) Exec(_ context.Context, req *runtimeapi.ExecRequest) (* if err != nil { return nil, err } - return ds.streamingServer.GetExec(req) + // This conversion has been copied from the functions in + // pkg/kubelet/cri/remote/conversion.go + r := (*runtimeapiv1.ExecRequest)(unsafe.Pointer(req)) + resp, err := ds.streamingServer.GetExec(r) + if err != nil { + return nil, err + } + return (*runtimeapi.ExecResponse)(unsafe.Pointer(resp)), nil } // Attach prepares a streaming endpoint to attach to a running container, and returns the address. @@ -135,7 +144,14 @@ func (ds *dockerService) Attach(_ context.Context, req *runtimeapi.AttachRequest if err != nil { return nil, err } - return ds.streamingServer.GetAttach(req) + // This conversion has been copied from the functions in + // pkg/kubelet/cri/remote/conversion.go + r := (*runtimeapiv1.AttachRequest)(unsafe.Pointer(req)) + resp, err := ds.streamingServer.GetAttach(r) + if err != nil { + return nil, err + } + return (*runtimeapi.AttachResponse)(unsafe.Pointer(resp)), nil } // PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address. @@ -148,7 +164,14 @@ func (ds *dockerService) PortForward(_ context.Context, req *runtimeapi.PortForw return nil, err } // TODO(tallclair): Verify that ports are exposed. - return ds.streamingServer.GetPortForward(req) + // This conversion has been copied from the functions in + // pkg/kubelet/cri/remote/conversion.go + r := (*runtimeapiv1.PortForwardRequest)(unsafe.Pointer(req)) + resp, err := ds.streamingServer.GetPortForward(r) + if err != nil { + return nil, err + } + return (*runtimeapi.PortForwardResponse)(unsafe.Pointer(resp)), nil } func checkContainerStatus(client libdocker.Interface, containerID string) (*dockertypes.ContainerJSON, error) { diff --git a/pkg/kubelet/dockershim/helpers.go b/pkg/kubelet/dockershim/helpers.go index 5a24a9603de..ca3db5e1818 100644 --- a/pkg/kubelet/dockershim/helpers.go +++ b/pkg/kubelet/dockershim/helpers.go @@ -36,7 +36,7 @@ import ( v1 "k8s.io/api/core/v1" utilerrors "k8s.io/apimachinery/pkg/util/errors" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/credentialprovider" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" "k8s.io/kubernetes/pkg/kubelet/types" diff --git a/pkg/kubelet/dockershim/helpers_linux.go b/pkg/kubelet/dockershim/helpers_linux.go index 3d84f8ac2c7..154c503a1ca 100644 --- a/pkg/kubelet/dockershim/helpers_linux.go +++ b/pkg/kubelet/dockershim/helpers_linux.go @@ -32,7 +32,7 @@ import ( dockertypes "github.com/docker/docker/api/types" dockercontainer "github.com/docker/docker/api/types/container" v1 "k8s.io/api/core/v1" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) // DefaultMemorySwap always returns 0 for no memory swap in a sandbox diff --git a/pkg/kubelet/dockershim/helpers_test.go b/pkg/kubelet/dockershim/helpers_test.go index ec3d769640f..b70b447f705 100644 --- a/pkg/kubelet/dockershim/helpers_test.go +++ b/pkg/kubelet/dockershim/helpers_test.go @@ -31,8 +31,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "k8s.io/api/core/v1" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + v1 "k8s.io/api/core/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" ) diff --git a/pkg/kubelet/dockershim/helpers_unsupported.go b/pkg/kubelet/dockershim/helpers_unsupported.go index d3e00912e96..3c655c5551f 100644 --- a/pkg/kubelet/dockershim/helpers_unsupported.go +++ b/pkg/kubelet/dockershim/helpers_unsupported.go @@ -24,7 +24,7 @@ import ( "github.com/blang/semver" dockertypes "github.com/docker/docker/api/types" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/klog/v2" ) diff --git a/pkg/kubelet/dockershim/helpers_windows.go b/pkg/kubelet/dockershim/helpers_windows.go index 58ec28c04be..1fd8155bec4 100644 --- a/pkg/kubelet/dockershim/helpers_windows.go +++ b/pkg/kubelet/dockershim/helpers_windows.go @@ -29,7 +29,7 @@ import ( dockerfilters "github.com/docker/docker/api/types/filters" "k8s.io/klog/v2" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) // DefaultMemorySwap always returns 0 for no memory swap in a sandbox diff --git a/pkg/kubelet/dockershim/naming.go b/pkg/kubelet/dockershim/naming.go index a45141e34ea..faf35b6bf68 100644 --- a/pkg/kubelet/dockershim/naming.go +++ b/pkg/kubelet/dockershim/naming.go @@ -25,7 +25,7 @@ import ( "strconv" "strings" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/leaky" ) diff --git a/pkg/kubelet/dockershim/naming_test.go b/pkg/kubelet/dockershim/naming_test.go index 2659da24cb1..16c3f6b7ad0 100644 --- a/pkg/kubelet/dockershim/naming_test.go +++ b/pkg/kubelet/dockershim/naming_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) func TestSandboxNameRoundTrip(t *testing.T) { diff --git a/pkg/kubelet/dockershim/network/cni/cni.go b/pkg/kubelet/dockershim/network/cni/cni.go index 4e2215aad55..fd9d1dbb19f 100644 --- a/pkg/kubelet/dockershim/network/cni/cni.go +++ b/pkg/kubelet/dockershim/network/cni/cni.go @@ -32,7 +32,7 @@ import ( "github.com/containernetworking/cni/libcni" cnitypes "github.com/containernetworking/cni/pkg/types" "k8s.io/apimachinery/pkg/util/wait" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/klog/v2" kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" diff --git a/pkg/kubelet/dockershim/network/cni/cni_others.go b/pkg/kubelet/dockershim/network/cni/cni_others.go index 2b71058ffb4..66446d30210 100644 --- a/pkg/kubelet/dockershim/network/cni/cni_others.go +++ b/pkg/kubelet/dockershim/network/cni/cni_others.go @@ -23,7 +23,7 @@ import ( "fmt" "github.com/containernetworking/cni/libcni" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" "k8s.io/kubernetes/pkg/kubelet/dockershim/network" ) diff --git a/pkg/kubelet/dockershim/network/cni/cni_windows.go b/pkg/kubelet/dockershim/network/cni/cni_windows.go index 04023216d31..f1b4aca6fe5 100644 --- a/pkg/kubelet/dockershim/network/cni/cni_windows.go +++ b/pkg/kubelet/dockershim/network/cni/cni_windows.go @@ -23,7 +23,7 @@ import ( "context" "fmt" cniTypes020 "github.com/containernetworking/cni/pkg/types/020" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/klog/v2" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" "k8s.io/kubernetes/pkg/kubelet/dockershim/network" diff --git a/pkg/kubelet/dockershim/remote/docker_server.go b/pkg/kubelet/dockershim/remote/docker_server.go index 5847472d74c..433f53890e0 100644 --- a/pkg/kubelet/dockershim/remote/docker_server.go +++ b/pkg/kubelet/dockershim/remote/docker_server.go @@ -24,7 +24,7 @@ import ( "os" "google.golang.org/grpc" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/klog/v2" "k8s.io/kubernetes/pkg/kubelet/dockershim" "k8s.io/kubernetes/pkg/kubelet/util" diff --git a/pkg/kubelet/dockershim/remote/docker_server_test.go b/pkg/kubelet/dockershim/remote/docker_server_test.go new file mode 100644 index 00000000000..6cecb514aa8 --- /dev/null +++ b/pkg/kubelet/dockershim/remote/docker_server_test.go @@ -0,0 +1,174 @@ +//go:build !dockerless +// +build !dockerless + +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package remote + +import ( + "context" + "io/ioutil" + "testing" + + "github.com/stretchr/testify/assert" + "google.golang.org/grpc" + + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" +) + +func TestServer(t *testing.T) { + file, err := ioutil.TempFile("", "docker-server-") + assert.Nil(t, err) + endpoint := "unix://" + file.Name() + + server := NewDockerServer(endpoint, &fakeCRIService{}) + assert.Nil(t, server.Start()) + + ctx := context.Background() + conn, err := grpc.Dial(endpoint, grpc.WithInsecure()) + assert.Nil(t, err) + + runtimeClient := runtimeapi.NewRuntimeServiceClient(conn) + _, err = runtimeClient.Version(ctx, &runtimeapi.VersionRequest{}) + assert.Nil(t, err) + + imageClient := runtimeapi.NewImageServiceClient(conn) + _, err = imageClient.ImageFsInfo(ctx, &runtimeapi.ImageFsInfoRequest{}) + assert.Nil(t, err) +} + +type fakeCRIService struct{} + +func (*fakeCRIService) Start() error { + return nil +} + +func (*fakeCRIService) Version(context.Context, *runtimeapi.VersionRequest) (*runtimeapi.VersionResponse, error) { + return &runtimeapi.VersionResponse{}, nil +} + +func (*fakeCRIService) RunPodSandbox(context.Context, *runtimeapi.RunPodSandboxRequest) (*runtimeapi.RunPodSandboxResponse, error) { + return nil, nil +} + +func (*fakeCRIService) StopPodSandbox(context.Context, *runtimeapi.StopPodSandboxRequest) (*runtimeapi.StopPodSandboxResponse, error) { + return nil, nil +} + +func (*fakeCRIService) RemovePodSandbox(context.Context, *runtimeapi.RemovePodSandboxRequest) (*runtimeapi.RemovePodSandboxResponse, error) { + return nil, nil +} + +func (*fakeCRIService) PodSandboxStatus(context.Context, *runtimeapi.PodSandboxStatusRequest) (*runtimeapi.PodSandboxStatusResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ListPodSandbox(context.Context, *runtimeapi.ListPodSandboxRequest) (*runtimeapi.ListPodSandboxResponse, error) { + return nil, nil +} + +func (*fakeCRIService) CreateContainer(context.Context, *runtimeapi.CreateContainerRequest) (*runtimeapi.CreateContainerResponse, error) { + return nil, nil +} + +func (*fakeCRIService) StartContainer(context.Context, *runtimeapi.StartContainerRequest) (*runtimeapi.StartContainerResponse, error) { + return nil, nil +} + +func (*fakeCRIService) StopContainer(context.Context, *runtimeapi.StopContainerRequest) (*runtimeapi.StopContainerResponse, error) { + return nil, nil +} + +func (*fakeCRIService) RemoveContainer(context.Context, *runtimeapi.RemoveContainerRequest) (*runtimeapi.RemoveContainerResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ListContainers(context.Context, *runtimeapi.ListContainersRequest) (*runtimeapi.ListContainersResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ContainerStatus(context.Context, *runtimeapi.ContainerStatusRequest) (*runtimeapi.ContainerStatusResponse, error) { + return nil, nil +} + +func (*fakeCRIService) UpdateContainerResources(context.Context, *runtimeapi.UpdateContainerResourcesRequest) (*runtimeapi.UpdateContainerResourcesResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ReopenContainerLog(context.Context, *runtimeapi.ReopenContainerLogRequest) (*runtimeapi.ReopenContainerLogResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ExecSync(context.Context, *runtimeapi.ExecSyncRequest) (*runtimeapi.ExecSyncResponse, error) { + return nil, nil +} + +func (*fakeCRIService) Exec(context.Context, *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) { + return nil, nil +} + +func (*fakeCRIService) Attach(context.Context, *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) { + return nil, nil +} + +func (*fakeCRIService) PortForward(context.Context, *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ContainerStats(context.Context, *runtimeapi.ContainerStatsRequest) (*runtimeapi.ContainerStatsResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ListContainerStats(context.Context, *runtimeapi.ListContainerStatsRequest) (*runtimeapi.ListContainerStatsResponse, error) { + return nil, nil +} + +func (*fakeCRIService) PodSandboxStats(context.Context, *runtimeapi.PodSandboxStatsRequest) (*runtimeapi.PodSandboxStatsResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ListPodSandboxStats(context.Context, *runtimeapi.ListPodSandboxStatsRequest) (*runtimeapi.ListPodSandboxStatsResponse, error) { + return nil, nil +} + +func (*fakeCRIService) UpdateRuntimeConfig(context.Context, *runtimeapi.UpdateRuntimeConfigRequest) (*runtimeapi.UpdateRuntimeConfigResponse, error) { + return nil, nil +} + +func (*fakeCRIService) Status(context.Context, *runtimeapi.StatusRequest) (*runtimeapi.StatusResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ListImages(context.Context, *runtimeapi.ListImagesRequest) (*runtimeapi.ListImagesResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ImageStatus(context.Context, *runtimeapi.ImageStatusRequest) (*runtimeapi.ImageStatusResponse, error) { + return nil, nil +} + +func (*fakeCRIService) PullImage(context.Context, *runtimeapi.PullImageRequest) (*runtimeapi.PullImageResponse, error) { + return nil, nil +} + +func (*fakeCRIService) RemoveImage(context.Context, *runtimeapi.RemoveImageRequest) (*runtimeapi.RemoveImageResponse, error) { + return nil, nil +} + +func (*fakeCRIService) ImageFsInfo(context.Context, *runtimeapi.ImageFsInfoRequest) (*runtimeapi.ImageFsInfoResponse, error) { + return &runtimeapi.ImageFsInfoResponse{}, nil +} diff --git a/pkg/kubelet/dockershim/security_context.go b/pkg/kubelet/dockershim/security_context.go index 89ace100b5f..25a12c450eb 100644 --- a/pkg/kubelet/dockershim/security_context.go +++ b/pkg/kubelet/dockershim/security_context.go @@ -25,7 +25,7 @@ import ( dockercontainer "github.com/docker/docker/api/types/container" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" knetwork "k8s.io/kubernetes/pkg/kubelet/dockershim/network" ) diff --git a/pkg/kubelet/dockershim/security_context_test.go b/pkg/kubelet/dockershim/security_context_test.go index e73f4d6499c..01f46fa1b52 100644 --- a/pkg/kubelet/dockershim/security_context_test.go +++ b/pkg/kubelet/dockershim/security_context_test.go @@ -27,7 +27,7 @@ import ( dockercontainer "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/assert" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) func TestModifyContainerConfig(t *testing.T) { diff --git a/pkg/kubelet/dockershim/selinux_util.go b/pkg/kubelet/dockershim/selinux_util.go index 02d33e88c4c..4d299a7f934 100644 --- a/pkg/kubelet/dockershim/selinux_util.go +++ b/pkg/kubelet/dockershim/selinux_util.go @@ -22,7 +22,7 @@ package dockershim import ( "fmt" - runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" + runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) // selinuxLabelUser returns the fragment of a Docker security opt that