diff --git a/cmd/containerd-shim-runc-v2/manager/manager_linux.go b/cmd/containerd-shim-runc-v2/manager/manager_linux.go index ca07ac51b..7955ce0e5 100644 --- a/cmd/containerd-shim-runc-v2/manager/manager_linux.go +++ b/cmd/containerd-shim-runc-v2/manager/manager_linux.go @@ -40,7 +40,6 @@ import ( "github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/runc" "github.com/containerd/containerd/v2/core/mount" "github.com/containerd/containerd/v2/pkg/namespaces" - "github.com/containerd/containerd/v2/pkg/oci" "github.com/containerd/containerd/v2/pkg/schedcore" "github.com/containerd/containerd/v2/pkg/shim" "github.com/containerd/containerd/v2/version" @@ -112,7 +111,8 @@ func newCommand(ctx context.Context, id, containerdAddress, containerdTTRPCAddre } func readSpec() (*spec, error) { - f, err := os.Open(oci.ConfigFilename) + const configFileName = "config.json" + f, err := os.Open(configFileName) if err != nil { return nil, err } diff --git a/cmd/containerd-shim-runc-v2/runc/util.go b/cmd/containerd-shim-runc-v2/runc/util.go index d810a2a32..7a3d88dff 100644 --- a/cmd/containerd-shim-runc-v2/runc/util.go +++ b/cmd/containerd-shim-runc-v2/runc/util.go @@ -20,9 +20,10 @@ package runc import ( "context" + "encoding/json" + "os" "path/filepath" - "github.com/containerd/containerd/v2/pkg/oci" "github.com/containerd/log" "github.com/opencontainers/runtime-spec/specs-go" ) @@ -30,7 +31,7 @@ import ( // ShouldKillAllOnExit reads the bundle's OCI spec and returns true if // there is an error reading the spec or if the container has a private PID namespace func ShouldKillAllOnExit(ctx context.Context, bundlePath string) bool { - spec, err := oci.ReadSpec(filepath.Join(bundlePath, oci.ConfigFilename)) + spec, err := readSpec(bundlePath) if err != nil { log.G(ctx).WithError(err).Error("shouldKillAllOnExit: failed to read config.json") return true @@ -45,3 +46,17 @@ func ShouldKillAllOnExit(ctx context.Context, bundlePath string) bool { } return true } + +func readSpec(p string) (*specs.Spec, error) { + const configFileName = "config.json" + f, err := os.Open(filepath.Join(p, configFileName)) + if err != nil { + return nil, err + } + defer f.Close() + var s specs.Spec + if err := json.NewDecoder(f).Decode(&s); err != nil { + return nil, err + } + return &s, nil +}