server: store containers state on disk
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
2ddc062bbe
commit
da0b8a6157
7 changed files with 30 additions and 0 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/kubernetes-incubator/cri-o/pkg/storage"
|
||||
"github.com/kubernetes-incubator/cri-o/server/apparmor"
|
||||
"github.com/kubernetes-incubator/cri-o/server/seccomp"
|
||||
"github.com/moby/moby/pkg/ioutils"
|
||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/opencontainers/selinux/go-selinux/label"
|
||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
|
@ -155,6 +156,20 @@ func (s *Server) loadContainer(id string) error {
|
|||
return s.ctrIDIndex.Add(id)
|
||||
}
|
||||
|
||||
func (s *Server) containerStateToDisk(c *oci.Container) error {
|
||||
// ignore errors, this is a best effort to have up-to-date info about
|
||||
// a given container before its state gets stored
|
||||
s.runtime.UpdateStatus(c)
|
||||
|
||||
jsonSource, err := ioutils.NewAtomicFileWriter(c.StatePath(), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer jsonSource.Close()
|
||||
enc := json.NewEncoder(jsonSource)
|
||||
return enc.Encode(s.runtime.ContainerStatus(c))
|
||||
}
|
||||
|
||||
func configNetNsPath(spec rspec.Spec) (string, error) {
|
||||
for _, ns := range spec.Linux.Namespaces {
|
||||
if ns.Type != rspec.NetworkNamespace {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue