From 3dd043c58151d430c627b898d3482f18515ab360 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Thu, 21 Sep 2017 10:17:39 +0200 Subject: [PATCH] sandbox_network: pass sandbox to newPodNetwork Signed-off-by: Antonio Murdaca --- server/sandbox_network.go | 4 ++-- server/utils.go | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/server/sandbox_network.go b/server/sandbox_network.go index 7ac6aada..15cf99c8 100644 --- a/server/sandbox_network.go +++ b/server/sandbox_network.go @@ -16,7 +16,7 @@ func (s *Server) networkStart(hostNetwork bool, sb *sandbox.Sandbox) (string, er return s.BindAddress(), nil } - podNetwork := newPodNetwork(sb.Namespace(), sb.KubeName(), sb.ID(), sb.NetNsPath()) + podNetwork := newPodNetwork(sb) err := s.netPlugin.SetUpPod(podNetwork) if err != nil { return "", fmt.Errorf("failed to create pod network sandbox %s(%s): %v", sb.Name(), sb.ID(), err) @@ -59,7 +59,7 @@ func (s *Server) networkStop(hostNetwork bool, sb *sandbox.Sandbox) error { sb.Name(), sb.ID(), err) } - podNetwork := newPodNetwork(sb.Namespace(), sb.KubeName(), sb.ID(), sb.NetNsPath()) + podNetwork := newPodNetwork(sb) if err := s.netPlugin.TearDownPod(podNetwork); err != nil { logrus.Warnf("failed to destroy network for pod sandbox %s(%s): %v", sb.Name(), sb.ID(), err) diff --git a/server/utils.go b/server/utils.go index 26c347f4..195942d3 100644 --- a/server/utils.go +++ b/server/utils.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/cri-o/ocicni/pkg/ocicni" + "github.com/kubernetes-incubator/cri-o/libkpod/sandbox" "github.com/opencontainers/runtime-tools/validate" "github.com/syndtr/gocapability/capability" ) @@ -149,12 +150,12 @@ func SysctlsFromPodAnnotation(annotation string) ([]Sysctl, error) { return sysctls, nil } -func newPodNetwork(namespace, name, id, netns string) ocicni.PodNetwork { +func newPodNetwork(sb *sandbox.Sandbox) ocicni.PodNetwork { return ocicni.PodNetwork{ - Name: name, - Namespace: namespace, - ID: id, - NetNS: netns, + Name: sb.KubeName(), + Namespace: sb.Namespace(), + ID: sb.ID(), + NetNS: sb.NetNsPath(), } }