From b58832f2b1757258527f098659bb40343651fdf0 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 5 Sep 2017 15:10:42 -0500 Subject: [PATCH] server/sandbox: consistently use kubeName, not containerName Plugins expect the Kubernetes container name, not the unique contianer name generated by CNI. For plugins, the uniqueness is provided by the container ID instead. Signed-off-by: Dan Williams --- server/sandbox_run.go | 4 ++-- server/sandbox_stop.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/sandbox_run.go b/server/sandbox_run.go index 815175e2..a3de2313 100644 --- a/server/sandbox_run.go +++ b/server/sandbox_run.go @@ -472,7 +472,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest } if len(portMappings) != 0 { - ip, err := s.netPlugin.GetContainerNetworkStatus(netNsPath, namespace, id, containerName) + ip, err := s.netPlugin.GetContainerNetworkStatus(netNsPath, namespace, id, kubeName) if err != nil { return nil, fmt.Errorf("failed to get network status for container %s in sandbox %s: %v", containerName, id, err) } @@ -483,7 +483,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest } if err = s.hostportManager.Add(id, &hostport.PodPortMapping{ - Name: name, + Name: kubeName, PortMappings: portMappings, IP: ip4, HostNetwork: false, diff --git a/server/sandbox_stop.go b/server/sandbox_stop.go index bdd85a24..aeef9dd1 100644 --- a/server/sandbox_stop.go +++ b/server/sandbox_stop.go @@ -51,7 +51,7 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque } if _, err := os.Stat(netnsPath); err == nil { if err2 := s.hostportManager.Remove(sb.ID(), &hostport.PodPortMapping{ - Name: sb.Name(), + Name: sb.KubeName(), PortMappings: sb.PortMappings(), HostNetwork: false, }); err2 != nil {