From fa1d3a9ccb4533469940a55baa203fcf4bd1c846 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Thu, 12 Oct 2023 09:40:16 -0700 Subject: [PATCH] Fix dependencies after remove Signed-off-by: Maksym Pavlenko --- contrib/fuzz/cri_fuzzer.go | 8 +++---- contrib/fuzz/cri_server_fuzzer.go | 2 +- integration/image_pull_timeout_test.go | 2 +- integration/main_test.go | 2 +- pkg/cri/sbserver/fuzz.go | 3 +-- pkg/cri/sbserver/sandbox_run.go | 2 +- pkg/cri/sbserver/sandbox_status.go | 22 +++++++++++++++++++ pkg/cri/sbserver/service_test.go | 2 +- .../sbserver/update_runtime_config_test.go | 2 +- 9 files changed, 33 insertions(+), 12 deletions(-) diff --git a/contrib/fuzz/cri_fuzzer.go b/contrib/fuzz/cri_fuzzer.go index 92bf3c9bf..67a5597ba 100644 --- a/contrib/fuzz/cri_fuzzer.go +++ b/contrib/fuzz/cri_fuzzer.go @@ -24,8 +24,8 @@ import ( fuzz "github.com/AdaLogics/go-fuzz-headers" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" - "github.com/containerd/containerd/pkg/cri/sbserver" - "github.com/containerd/containerd/pkg/cri/server" + server "github.com/containerd/containerd/pkg/cri/sbserver" + "github.com/containerd/containerd/pkg/cri/sbserver/images" containerstore "github.com/containerd/containerd/pkg/cri/store/container" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ) @@ -191,7 +191,7 @@ func sandboxStore(cs server.CRIService) (*sandboxstore.Store, error) { ss, err = server.SandboxStore(cs) if err != nil { - ss, err = sbserver.SandboxStore(cs) + ss, err = server.SandboxStore(cs) if err != nil { return nil, err } @@ -535,6 +535,6 @@ func FuzzParseAuth(data []byte) int { if err != nil { return 0 } - _, _, _ = server.ParseAuth(auth, host) + _, _, _ = images.ParseAuth(auth, host) return 1 } diff --git a/contrib/fuzz/cri_server_fuzzer.go b/contrib/fuzz/cri_server_fuzzer.go index 2b6622bf8..1b5baa8fb 100644 --- a/contrib/fuzz/cri_server_fuzzer.go +++ b/contrib/fuzz/cri_server_fuzzer.go @@ -23,7 +23,7 @@ import ( "github.com/containerd/containerd" criconfig "github.com/containerd/containerd/pkg/cri/config" - "github.com/containerd/containerd/pkg/cri/server" + server "github.com/containerd/containerd/pkg/cri/sbserver" ) func FuzzCRIServer(data []byte) int { diff --git a/integration/image_pull_timeout_test.go b/integration/image_pull_timeout_test.go index 64d4fd345..7394c7330 100644 --- a/integration/image_pull_timeout_test.go +++ b/integration/image_pull_timeout_test.go @@ -38,7 +38,7 @@ import ( "github.com/containerd/containerd/leases" "github.com/containerd/containerd/namespaces" criconfig "github.com/containerd/containerd/pkg/cri/config" - criserver "github.com/containerd/containerd/pkg/cri/server" + criserver "github.com/containerd/containerd/pkg/cri/sbserver" "github.com/containerd/log" "github.com/containerd/log/logtest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/integration/main_test.go b/integration/main_test.go index ffe1e29a9..16f613c13 100644 --- a/integration/main_test.go +++ b/integration/main_test.go @@ -41,7 +41,7 @@ import ( dialer "github.com/containerd/containerd/integration/remote/util" criconfig "github.com/containerd/containerd/pkg/cri/config" "github.com/containerd/containerd/pkg/cri/constants" - "github.com/containerd/containerd/pkg/cri/server" + server "github.com/containerd/containerd/pkg/cri/sbserver" "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/log" "github.com/opencontainers/selinux/go-selinux" diff --git a/pkg/cri/sbserver/fuzz.go b/pkg/cri/sbserver/fuzz.go index 362817803..77e5d2c82 100644 --- a/pkg/cri/sbserver/fuzz.go +++ b/pkg/cri/sbserver/fuzz.go @@ -21,11 +21,10 @@ package sbserver import ( "fmt" - "github.com/containerd/containerd/pkg/cri/server" "github.com/containerd/containerd/pkg/cri/store/sandbox" ) -func SandboxStore(cs server.CRIService) (*sandbox.Store, error) { +func SandboxStore(cs CRIService) (*sandbox.Store, error) { s, ok := cs.(*criService) if !ok { return nil, fmt.Errorf("%+v is not sbserver.criService", cs) diff --git a/pkg/cri/sbserver/sandbox_run.go b/pkg/cri/sbserver/sandbox_run.go index f44a25f10..4503c4edd 100644 --- a/pkg/cri/sbserver/sandbox_run.go +++ b/pkg/cri/sbserver/sandbox_run.go @@ -32,9 +32,9 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/pkg/cri/annotations" + "github.com/containerd/containerd/pkg/cri/bandwidth" criconfig "github.com/containerd/containerd/pkg/cri/config" "github.com/containerd/containerd/pkg/cri/sbserver/podsandbox" - "github.com/containerd/containerd/pkg/cri/server/bandwidth" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/pkg/netns" diff --git a/pkg/cri/sbserver/sandbox_status.go b/pkg/cri/sbserver/sandbox_status.go index 0d547b4b6..24b9bd846 100644 --- a/pkg/cri/sbserver/sandbox_status.go +++ b/pkg/cri/sbserver/sandbox_status.go @@ -23,6 +23,8 @@ import ( "github.com/containerd/containerd/errdefs" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" + "github.com/containerd/go-cni" + runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) @@ -102,6 +104,26 @@ func (c *criService) getIPs(sandbox sandboxstore.Sandbox) (string, []string, err return sandbox.IP, sandbox.AdditionalIPs, nil } +// SandboxInfo is extra information for sandbox. +// TODO (mikebrow): discuss predefining constants structures for some or all of these field names in CRI +type SandboxInfo struct { + Pid uint32 `json:"pid"` + Status string `json:"processStatus"` + NetNSClosed bool `json:"netNamespaceClosed"` + Image string `json:"image"` + SnapshotKey string `json:"snapshotKey"` + Snapshotter string `json:"snapshotter"` + // Note: a new field `RuntimeHandler` has been added into the CRI PodSandboxStatus struct, and + // should be set. This `RuntimeHandler` field will be deprecated after containerd 1.3 (tracked + // in https://github.com/containerd/cri/issues/1064). + RuntimeHandler string `json:"runtimeHandler"` // see the Note above + RuntimeType string `json:"runtimeType"` + RuntimeOptions interface{} `json:"runtimeOptions"` + Config *runtime.PodSandboxConfig `json:"config"` + RuntimeSpec *runtimespec.Spec `json:"runtimeSpec"` + CNIResult *cni.Result `json:"cniResult"` +} + // toCRISandboxStatus converts sandbox metadata into CRI pod sandbox status. func toCRISandboxStatus(meta sandboxstore.Metadata, status string, createdAt time.Time, ip string, additionalIPs []string) *runtime.PodSandboxStatus { // Set sandbox state to NOTREADY by default. diff --git a/pkg/cri/sbserver/service_test.go b/pkg/cri/sbserver/service_test.go index b99ec00d9..915e78398 100644 --- a/pkg/cri/sbserver/service_test.go +++ b/pkg/cri/sbserver/service_test.go @@ -27,10 +27,10 @@ import ( "github.com/stretchr/testify/require" criconfig "github.com/containerd/containerd/pkg/cri/config" - servertesting "github.com/containerd/containerd/pkg/cri/server/testing" containerstore "github.com/containerd/containerd/pkg/cri/store/container" "github.com/containerd/containerd/pkg/cri/store/label" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" + servertesting "github.com/containerd/containerd/pkg/cri/testing" ostesting "github.com/containerd/containerd/pkg/os/testing" "github.com/containerd/containerd/pkg/registrar" ) diff --git a/pkg/cri/sbserver/update_runtime_config_test.go b/pkg/cri/sbserver/update_runtime_config_test.go index e416a7112..004b6bac0 100644 --- a/pkg/cri/sbserver/update_runtime_config_test.go +++ b/pkg/cri/sbserver/update_runtime_config_test.go @@ -28,7 +28,7 @@ import ( runtime "k8s.io/cri-api/pkg/apis/runtime/v1" criconfig "github.com/containerd/containerd/pkg/cri/config" - servertesting "github.com/containerd/containerd/pkg/cri/server/testing" + servertesting "github.com/containerd/containerd/pkg/cri/testing" ) func TestUpdateRuntimeConfig(t *testing.T) {