From dca211bccc7b579510e95d5409adcc334078cc20 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 26 Oct 2016 11:28:15 -0500 Subject: [PATCH 1/2] sdn: fix single-tenant pod setup Single-tenant needs to set vnid=0 for pod setup. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1388556 --- pkg/sdn/plugin/pod_linux.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pkg/sdn/plugin/pod_linux.go b/pkg/sdn/plugin/pod_linux.go index f80bb60ae4a6..7cd1149ea4fc 100644 --- a/pkg/sdn/plugin/pod_linux.go +++ b/pkg/sdn/plugin/pod_linux.go @@ -42,7 +42,7 @@ const ( ) type PodConfig struct { - vnid string + vnid uint32 ingressBandwidth string egressBandwidth string wantMacvlan bool @@ -86,14 +86,14 @@ func wantsMacvlan(pod *kapi.Pod) (bool, error) { // Create and return a PodConfig describing which openshift-sdn specific pod attributes // to configure func (m *podManager) getPodConfig(req *cniserver.PodRequest) (*PodConfig, *kapi.Pod, error) { - config := &PodConfig{} + var err error + config := &PodConfig{} if m.multitenant { - vnid, err := m.vnids.GetVNID(req.PodNamespace) + config.vnid, err = m.vnids.GetVNID(req.PodNamespace) if err != nil { return nil, nil, err } - config.vnid = strconv.FormatUint(uint64(vnid), 10) } pod, err := m.kClient.Pods(req.PodNamespace).Get(req.PodName) @@ -255,6 +255,10 @@ func getScriptError(output []byte) string { return string(output) } +func vnidToString(vnid uint32) string { + return strconv.FormatUint(uint64(vnid), 10) +} + // Set up all networking (host/container veth, OVS flows, IPAM, loopback, etc) func (m *podManager) setup(req *cniserver.PodRequest) (*cnitypes.Result, *kubehostport.RunningPod, error) { podConfig, pod, err := m.getPodConfig(req) @@ -324,11 +328,12 @@ func (m *podManager) setup(req *cniserver.PodRequest) (*cnitypes.Result, *kubeho } contVethMac := contVeth.Attrs().HardwareAddr.String() - out, err := exec.Command(sdnScript, setUpCmd, hostVeth.Attrs().Name, contVethMac, podIP.String(), podConfig.vnid, podConfig.ingressBandwidth, podConfig.egressBandwidth).CombinedOutput() + vnidStr := vnidToString(podConfig.vnid) + out, err := exec.Command(sdnScript, setUpCmd, hostVeth.Attrs().Name, contVethMac, podIP.String(), vnidStr, podConfig.ingressBandwidth, podConfig.egressBandwidth).CombinedOutput() glog.V(5).Infof("SetUpPod network plugin output: %s, %v", string(out), err) if isScriptError(err) { - return nil, nil, fmt.Errorf("error running network setup script:\nhostVethName %s, contVethMac %s, podIP %s, podConfig %#v\n %s", hostVeth.Attrs().Name, contVethMac, podIP.String(), podConfig, out) + return nil, nil, fmt.Errorf("error running network setup script:\nhostVethName %s, contVethMac %s, podIP %s, podConfig %#v\n %s", hostVeth.Attrs().Name, contVethMac, podIP.String(), podConfig, getScriptError(out)) } else if err != nil { return nil, nil, err } @@ -368,7 +373,8 @@ func (m *podManager) update(req *cniserver.PodRequest) error { return err } - out, err := exec.Command(sdnScript, updateCmd, hostVethName, contVethMac, podIP, podConfig.vnid, podConfig.ingressBandwidth, podConfig.egressBandwidth).CombinedOutput() + vnidStr := vnidToString(podConfig.vnid) + out, err := exec.Command(sdnScript, updateCmd, hostVethName, contVethMac, podIP, vnidStr, podConfig.ingressBandwidth, podConfig.egressBandwidth).CombinedOutput() glog.V(5).Infof("UpdatePod network plugin output: %s, %v", string(out), err) if isScriptError(err) { From 2000b4be07d32a7406e26145bf47a631d93a81a4 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 26 Oct 2016 11:54:54 -0500 Subject: [PATCH 2/2] sdn: no longer kill docker0 We no longer use docker for IPAM, so we don't need to mess with docker networking at all. Don't kill docker0 anymore on openshift-sdn startup. --- pkg/sdn/plugin/controller.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pkg/sdn/plugin/controller.go b/pkg/sdn/plugin/controller.go index 52eb1c05ddca..aa7e51065ee3 100644 --- a/pkg/sdn/plugin/controller.go +++ b/pkg/sdn/plugin/controller.go @@ -308,14 +308,6 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) { return false, err } - // Clean up docker0 since docker won't - itx = ipcmd.NewTransaction(exec, "docker0") - itx.SetLink("down") - itx.IgnoreError() - itx.DeleteLink() - itx.IgnoreError() - _ = itx.EndTransaction() - sysctl := sysctl.New() // Enable IP forwarding for ipv4 packets