Merge pull request #814 from runcom/cache-ip-sandbox

cache sandbox's IP address
This commit is contained in:
Mrunal Patel 2017-09-06 09:51:03 -07:00 committed by GitHub
commit ac12018973
16 changed files with 112 additions and 74 deletions

View file

@ -294,6 +294,8 @@ func (c *ContainerServer) LoadSandbox(id string) error {
return err
}
ip := m.Annotations[annotations.IP]
processLabel, mountLabel, err := label.InitLabels(label.DupSecOpt(m.Process.SelinuxLabel))
if err != nil {
return err
@ -311,6 +313,7 @@ func (c *ContainerServer) LoadSandbox(id string) error {
if err != nil {
return err
}
sb.AddIP(ip)
// We add a netNS only if we can load a permanent one.
// Otherwise, the sandbox will live in the host namespace.

View file

@ -154,6 +154,8 @@ type Sandbox struct {
hostname string
portMappings []*hostport.PortMapping
stopped bool
// ipv4 or ipv6 cache
ip string
}
const (
@ -202,6 +204,16 @@ func New(id, namespace, name, kubeName, logDir string, labels, annotations map[s
return sb, nil
}
// AddIP stores the ip in the sandbox
func (s *Sandbox) AddIP(ip string) {
s.ip = ip
}
// IP returns the ip of the sandbox
func (s *Sandbox) IP() string {
return s.ip
}
// ID returns the id of the sandbox
func (s *Sandbox) ID() string {
return s.id