diff --git a/server/container_status.go b/server/container_status.go index 9fb80022..1bfa9091 100644 --- a/server/container_status.go +++ b/server/container_status.go @@ -1,10 +1,7 @@ package server import ( - "encoding/json" - "github.com/kubernetes-incubator/cri-o/oci" - rspec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "golang.org/x/net/context" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" @@ -36,11 +33,14 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq } resp.Status.Image = &pb.ImageSpec{Image: c.ImageName()} - mounts, err := s.getMounts(containerID) - if err != nil { - return nil, err + mounts := []*pb.Mount{} + for _, cv := range c.Volumes() { + mounts = append(mounts, &pb.Mount{ + ContainerPath: cv.ContainerPath, + HostPath: cv.HostPath, + Readonly: cv.Readonly, + }) } - resp.Status.Mounts = mounts cState := s.Runtime().ContainerStatus(c) @@ -82,46 +82,3 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq logrus.Debugf("ContainerStatusResponse: %+v", resp) return resp, nil } - -func (s *Server) getMounts(id string) ([]*pb.Mount, error) { - config, err := s.Store().FromContainerDirectory(id, "config.json") - if err != nil { - return nil, err - } - var m rspec.Spec - if err = json.Unmarshal(config, &m); err != nil { - return nil, err - } - isRO := func(m rspec.Mount) bool { - var ro bool - for _, o := range m.Options { - if o == "ro" { - ro = true - break - } - } - return ro - } - isBind := func(m rspec.Mount) bool { - var bind bool - for _, o := range m.Options { - if o == "bind" || o == "rbind" { - bind = true - break - } - } - return bind - } - mounts := []*pb.Mount{} - for _, b := range m.Mounts { - if !isBind(b) { - continue - } - mounts = append(mounts, &pb.Mount{ - ContainerPath: b.Destination, - HostPath: b.Source, - Readonly: isRO(b), - }) - } - return mounts, nil -}