sandbox: restore portMappings on restart
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
c3f1e7aec2
commit
e5fc48a3ca
3 changed files with 15 additions and 1 deletions
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
||||
"k8s.io/kubernetes/pkg/kubelet/network/hostport"
|
||||
)
|
||||
|
||||
// ContainerServer implements the ImageServer
|
||||
|
@ -332,10 +333,15 @@ func (c *ContainerServer) LoadSandbox(id string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
portMappings := []*hostport.PortMapping{}
|
||||
if err := json.Unmarshal([]byte(m.Annotations[annotations.PortMappings]), &portMappings); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
privileged := isTrue(m.Annotations[annotations.PrivilegedRuntime])
|
||||
trusted := isTrue(m.Annotations[annotations.TrustedSandbox])
|
||||
|
||||
sb, err := sandbox.New(id, m.Annotations[annotations.Namespace], name, m.Annotations[annotations.KubeName], filepath.Dir(m.Annotations[annotations.LogPath]), labels, kubeAnnotations, processLabel, mountLabel, &metadata, m.Annotations[annotations.ShmPath], m.Annotations[annotations.CgroupParent], privileged, trusted, m.Annotations[annotations.ResolvPath], m.Annotations[annotations.HostName], nil)
|
||||
sb, err := sandbox.New(id, m.Annotations[annotations.Namespace], name, m.Annotations[annotations.KubeName], filepath.Dir(m.Annotations[annotations.LogPath]), labels, kubeAnnotations, processLabel, mountLabel, &metadata, m.Annotations[annotations.ShmPath], m.Annotations[annotations.CgroupParent], privileged, trusted, m.Annotations[annotations.ResolvPath], m.Annotations[annotations.HostName], portMappings)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -40,6 +40,9 @@ const (
|
|||
// KubeName is the kubernetes name annotation
|
||||
KubeName = "io.kubernetes.cri-o.KubeName"
|
||||
|
||||
// PortMappings holds the port mappings for the sandbox
|
||||
PortMappings = "io.kubernetes.cri-o.PortMappings"
|
||||
|
||||
// Labels are the kubernetes labels annotation
|
||||
Labels = "io.kubernetes.cri-o.Labels"
|
||||
|
||||
|
|
|
@ -363,6 +363,11 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
|
|||
g.AddAnnotation(annotations.Created, created.Format(time.RFC3339Nano))
|
||||
|
||||
portMappings := convertPortMappings(req.GetConfig().GetPortMappings())
|
||||
portMappingsJSON, err := json.Marshal(portMappings)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
g.AddAnnotation(annotations.PortMappings, string(portMappingsJSON))
|
||||
|
||||
// setup cgroup settings
|
||||
cgroupParent := req.GetConfig().GetLinux().GetCgroupParent()
|
||||
|
|
Loading…
Reference in a new issue