@@ -21,14 +21,13 @@ package runc
2121
2222import (
2323 "context"
24- "encoding/json"
25- "os"
2624 "path/filepath"
2725
2826 "github.com/containerd/containerd/api/events"
2927 "github.com/containerd/containerd/log"
28+ "github.com/containerd/containerd/oci"
3029 "github.com/containerd/containerd/runtime"
31- specs "github.com/opencontainers/runtime-spec/specs-go"
30+ "github.com/opencontainers/runtime-spec/specs-go"
3231 "github.com/sirupsen/logrus"
3332)
3433
@@ -65,18 +64,14 @@ func GetTopic(e interface{}) string {
6564// ShouldKillAllOnExit reads the bundle's OCI spec and returns true if
6665// there is an error reading the spec or if the container has a private PID namespace
6766func ShouldKillAllOnExit (ctx context.Context , bundlePath string ) bool {
68- var bundleSpec specs.Spec
69- bundleConfigContents , err := os .ReadFile (filepath .Join (bundlePath , "config.json" ))
67+ spec , err := oci .ReadSpec (filepath .Join (bundlePath , oci .ConfigFilename ))
7068 if err != nil {
7169 log .G (ctx ).WithError (err ).Error ("shouldKillAllOnExit: failed to read config.json" )
7270 return true
7371 }
74- if err := json .Unmarshal (bundleConfigContents , & bundleSpec ); err != nil {
75- log .G (ctx ).WithError (err ).Error ("shouldKillAllOnExit: failed to unmarshal bundle json" )
76- return true
77- }
78- if bundleSpec .Linux != nil {
79- for _ , ns := range bundleSpec .Linux .Namespaces {
72+
73+ if spec .Linux != nil {
74+ for _ , ns := range spec .Linux .Namespaces {
8075 if ns .Type == specs .PIDNamespace && ns .Path == "" {
8176 return false
8277 }
0 commit comments