From edb1609c6121a550a3c882529e44387c217d2b03 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 2 Mar 2018 11:10:37 -0500 Subject: Update DB to hold CNI network information Replace our old IP and Subnet fields in state with CNI types that contain a lot more information. Retrieve these structs from the CNI plugins themselves. Signed-off-by: Matthew Heon Closes: #440 Approved by: baude --- libpod/networking.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libpod/networking.go') diff --git a/libpod/networking.go b/libpod/networking.go index 40756cf88..f92b80201 100644 --- a/libpod/networking.go +++ b/libpod/networking.go @@ -3,6 +3,7 @@ package libpod import ( "net" + cnitypes "github.com/containernetworking/cni/pkg/types/current" "github.com/containernetworking/plugins/pkg/ns" "github.com/cri-o/ocicni/pkg/ocicni" "github.com/pkg/errors" @@ -37,12 +38,17 @@ func (r *Runtime) createNetNS(ctr *Container) (err error) { logrus.Debugf("Made network namespace at %s for container %s", ctrNS.Path(), ctr.ID()) podNetwork := getPodNetwork(ctr.ID(), ctr.Name(), ctrNS.Path(), ctr.config.PortMappings) - _, err = r.netPlugin.SetUpPod(podNetwork) + result, err := r.netPlugin.SetUpPod(podNetwork) if err != nil { return errors.Wrapf(err, "error configuring network namespace for container %s", ctr.ID()) } + resultStruct := result.(*cnitypes.Result) + logrus.Debugf("Response from CNI plugins: %v", resultStruct.String()) + ctr.state.NetNS = ctrNS + ctr.state.IPs = resultStruct.IPs + ctr.state.Routes = resultStruct.Routes return nil } -- cgit v1.2.3-54-g00ecf