Move sandbox info to cri types packages
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
		| @@ -51,7 +51,7 @@ import ( | |||||||
| 	dialer "github.com/containerd/containerd/v2/integration/remote/util" | 	dialer "github.com/containerd/containerd/v2/integration/remote/util" | ||||||
| 	criconfig "github.com/containerd/containerd/v2/pkg/cri/config" | 	criconfig "github.com/containerd/containerd/v2/pkg/cri/config" | ||||||
| 	"github.com/containerd/containerd/v2/pkg/cri/constants" | 	"github.com/containerd/containerd/v2/pkg/cri/constants" | ||||||
| 	"github.com/containerd/containerd/v2/pkg/cri/server/base" | 	"github.com/containerd/containerd/v2/pkg/cri/types" | ||||||
| 	"github.com/containerd/containerd/v2/pkg/cri/util" | 	"github.com/containerd/containerd/v2/pkg/cri/util" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -686,7 +686,7 @@ func CRIConfig() (*criconfig.Config, error) { | |||||||
| } | } | ||||||
|  |  | ||||||
| // SandboxInfo gets sandbox info. | // SandboxInfo gets sandbox info. | ||||||
| func SandboxInfo(id string) (*runtime.PodSandboxStatus, *base.SandboxInfo, error) { | func SandboxInfo(id string) (*runtime.PodSandboxStatus, *types.SandboxInfo, error) { | ||||||
| 	client, err := RawRuntimeClient() | 	client, err := RawRuntimeClient() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, nil, fmt.Errorf("failed to get raw runtime client: %w", err) | 		return nil, nil, fmt.Errorf("failed to get raw runtime client: %w", err) | ||||||
| @@ -699,7 +699,7 @@ func SandboxInfo(id string) (*runtime.PodSandboxStatus, *base.SandboxInfo, error | |||||||
| 		return nil, nil, fmt.Errorf("failed to get sandbox status: %w", err) | 		return nil, nil, fmt.Errorf("failed to get sandbox status: %w", err) | ||||||
| 	} | 	} | ||||||
| 	status := resp.GetStatus() | 	status := resp.GetStatus() | ||||||
| 	var info base.SandboxInfo | 	var info types.SandboxInfo | ||||||
| 	if err := json.Unmarshal([]byte(resp.GetInfo()["info"]), &info); err != nil { | 	if err := json.Unmarshal([]byte(resp.GetInfo()["info"]), &info); err != nil { | ||||||
| 		return nil, nil, fmt.Errorf("failed to unmarshal sandbox info: %w", err) | 		return nil, nil, fmt.Errorf("failed to unmarshal sandbox info: %w", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ import ( | |||||||
| 	criapiv1 "k8s.io/cri-api/pkg/apis/runtime/v1" | 	criapiv1 "k8s.io/cri-api/pkg/apis/runtime/v1" | ||||||
|  |  | ||||||
| 	"github.com/containerd/containerd/v2/internal/failpoint" | 	"github.com/containerd/containerd/v2/internal/failpoint" | ||||||
| 	"github.com/containerd/containerd/v2/pkg/cri/server/base" | 	"github.com/containerd/containerd/v2/pkg/cri/types" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| @@ -299,7 +299,7 @@ func TestRunPodSandboxAndTeardownCNISlow(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| // sbserverSandboxInfo gets sandbox info. | // sbserverSandboxInfo gets sandbox info. | ||||||
| func sbserverSandboxInfo(id string) (*criapiv1.PodSandboxStatus, *base.SandboxInfo, error) { | func sbserverSandboxInfo(id string) (*criapiv1.PodSandboxStatus, *types.SandboxInfo, error) { | ||||||
| 	client, err := RawRuntimeClient() | 	client, err := RawRuntimeClient() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, nil, fmt.Errorf("failed to get raw runtime client: %w", err) | 		return nil, nil, fmt.Errorf("failed to get raw runtime client: %w", err) | ||||||
| @@ -312,7 +312,7 @@ func sbserverSandboxInfo(id string) (*criapiv1.PodSandboxStatus, *base.SandboxIn | |||||||
| 		return nil, nil, fmt.Errorf("failed to get sandbox status: %w", err) | 		return nil, nil, fmt.Errorf("failed to get sandbox status: %w", err) | ||||||
| 	} | 	} | ||||||
| 	status := resp.GetStatus() | 	status := resp.GetStatus() | ||||||
| 	var info base.SandboxInfo | 	var info types.SandboxInfo | ||||||
| 	if err := json.Unmarshal([]byte(resp.GetInfo()["info"]), &info); err != nil { | 	if err := json.Unmarshal([]byte(resp.GetInfo()["info"]), &info); err != nil { | ||||||
| 		return nil, nil, fmt.Errorf("failed to unmarshal sandbox info: %w", err) | 		return nil, nil, fmt.Errorf("failed to unmarshal sandbox info: %w", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -26,8 +26,8 @@ import ( | |||||||
| 	containerd "github.com/containerd/containerd/v2/client" | 	containerd "github.com/containerd/containerd/v2/client" | ||||||
| 	"github.com/containerd/containerd/v2/core/containers" | 	"github.com/containerd/containerd/v2/core/containers" | ||||||
| 	"github.com/containerd/containerd/v2/core/sandbox" | 	"github.com/containerd/containerd/v2/core/sandbox" | ||||||
| 	"github.com/containerd/containerd/v2/pkg/cri/server/base" |  | ||||||
| 	"github.com/containerd/containerd/v2/pkg/cri/server/podsandbox/types" | 	"github.com/containerd/containerd/v2/pkg/cri/server/podsandbox/types" | ||||||
|  | 	critypes "github.com/containerd/containerd/v2/pkg/cri/types" | ||||||
| 	"github.com/containerd/errdefs" | 	"github.com/containerd/errdefs" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -63,7 +63,7 @@ func (c *Controller) Status(ctx context.Context, sandboxID string, verbose bool) | |||||||
|  |  | ||||||
| // toCRISandboxInfo converts internal container object information to CRI sandbox status response info map. | // toCRISandboxInfo converts internal container object information to CRI sandbox status response info map. | ||||||
| func toCRISandboxInfo(ctx context.Context, sb *types.PodSandbox) (map[string]string, error) { | func toCRISandboxInfo(ctx context.Context, sb *types.PodSandbox) (map[string]string, error) { | ||||||
| 	si := &base.SandboxInfo{ | 	si := &critypes.SandboxInfo{ | ||||||
| 		Pid:            sb.Pid, | 		Pid:            sb.Pid, | ||||||
| 		Config:         sb.Metadata.Config, | 		Config:         sb.Metadata.Config, | ||||||
| 		RuntimeHandler: sb.Metadata.RuntimeHandler, | 		RuntimeHandler: sb.Metadata.RuntimeHandler, | ||||||
|   | |||||||
| @@ -24,8 +24,8 @@ import ( | |||||||
|  |  | ||||||
| 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | ||||||
|  |  | ||||||
| 	"github.com/containerd/containerd/v2/pkg/cri/server/base" |  | ||||||
| 	sandboxstore "github.com/containerd/containerd/v2/pkg/cri/store/sandbox" | 	sandboxstore "github.com/containerd/containerd/v2/pkg/cri/store/sandbox" | ||||||
|  | 	"github.com/containerd/containerd/v2/pkg/cri/types" | ||||||
| 	"github.com/containerd/errdefs" | 	"github.com/containerd/errdefs" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -152,7 +152,7 @@ func toCRISandboxStatus(meta sandboxstore.Metadata, status string, createdAt tim | |||||||
| // but if controller.Status() returns a NotFound error, | // but if controller.Status() returns a NotFound error, | ||||||
| // we should fallback to get SandboxInfo from cached sandbox itself. | // we should fallback to get SandboxInfo from cached sandbox itself. | ||||||
| func toDeletedCRISandboxInfo(sandbox sandboxstore.Sandbox) (map[string]string, error) { | func toDeletedCRISandboxInfo(sandbox sandboxstore.Sandbox) (map[string]string, error) { | ||||||
| 	si := &base.SandboxInfo{ | 	si := &types.SandboxInfo{ | ||||||
| 		Pid:            sandbox.Status.Get().Pid, | 		Pid:            sandbox.Status.Get().Pid, | ||||||
| 		Config:         sandbox.Config, | 		Config:         sandbox.Config, | ||||||
| 		RuntimeHandler: sandbox.RuntimeHandler, | 		RuntimeHandler: sandbox.RuntimeHandler, | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ | |||||||
|    limitations under the License. |    limitations under the License. | ||||||
| */ | */ | ||||||
|  |  | ||||||
| package base | package types | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"github.com/containerd/go-cni" | 	"github.com/containerd/go-cni" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Derek McGowan
					Derek McGowan