Skip to content

Commit 583d848

Browse files
author
OpenShift Bot
authored
Merge pull request #11588 from dcbw/sdn-fix-single-tenant
Merged by openshift-bot
2 parents a553668 + 2000b4b commit 583d848

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

pkg/sdn/plugin/controller.go

-8
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,6 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
308308
return false, err
309309
}
310310

311-
// Clean up docker0 since docker won't
312-
itx = ipcmd.NewTransaction(exec, "docker0")
313-
itx.SetLink("down")
314-
itx.IgnoreError()
315-
itx.DeleteLink()
316-
itx.IgnoreError()
317-
_ = itx.EndTransaction()
318-
319311
sysctl := sysctl.New()
320312

321313
// Enable IP forwarding for ipv4 packets

pkg/sdn/plugin/pod_linux.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const (
4242
)
4343

4444
type PodConfig struct {
45-
vnid string
45+
vnid uint32
4646
ingressBandwidth string
4747
egressBandwidth string
4848
wantMacvlan bool
@@ -86,14 +86,14 @@ func wantsMacvlan(pod *kapi.Pod) (bool, error) {
8686
// Create and return a PodConfig describing which openshift-sdn specific pod attributes
8787
// to configure
8888
func (m *podManager) getPodConfig(req *cniserver.PodRequest) (*PodConfig, *kapi.Pod, error) {
89-
config := &PodConfig{}
89+
var err error
9090

91+
config := &PodConfig{}
9192
if m.multitenant {
92-
vnid, err := m.vnids.GetVNID(req.PodNamespace)
93+
config.vnid, err = m.vnids.GetVNID(req.PodNamespace)
9394
if err != nil {
9495
return nil, nil, err
9596
}
96-
config.vnid = strconv.FormatUint(uint64(vnid), 10)
9797
}
9898

9999
pod, err := m.kClient.Pods(req.PodNamespace).Get(req.PodName)
@@ -255,6 +255,10 @@ func getScriptError(output []byte) string {
255255
return string(output)
256256
}
257257

258+
func vnidToString(vnid uint32) string {
259+
return strconv.FormatUint(uint64(vnid), 10)
260+
}
261+
258262
// Set up all networking (host/container veth, OVS flows, IPAM, loopback, etc)
259263
func (m *podManager) setup(req *cniserver.PodRequest) (*cnitypes.Result, *kubehostport.RunningPod, error) {
260264
podConfig, pod, err := m.getPodConfig(req)
@@ -324,11 +328,12 @@ func (m *podManager) setup(req *cniserver.PodRequest) (*cnitypes.Result, *kubeho
324328
}
325329

326330
contVethMac := contVeth.Attrs().HardwareAddr.String()
327-
out, err := exec.Command(sdnScript, setUpCmd, hostVeth.Attrs().Name, contVethMac, podIP.String(), podConfig.vnid, podConfig.ingressBandwidth, podConfig.egressBandwidth).CombinedOutput()
331+
vnidStr := vnidToString(podConfig.vnid)
332+
out, err := exec.Command(sdnScript, setUpCmd, hostVeth.Attrs().Name, contVethMac, podIP.String(), vnidStr, podConfig.ingressBandwidth, podConfig.egressBandwidth).CombinedOutput()
328333
glog.V(5).Infof("SetUpPod network plugin output: %s, %v", string(out), err)
329334

330335
if isScriptError(err) {
331-
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)
336+
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))
332337
} else if err != nil {
333338
return nil, nil, err
334339
}
@@ -368,7 +373,8 @@ func (m *podManager) update(req *cniserver.PodRequest) error {
368373
return err
369374
}
370375

371-
out, err := exec.Command(sdnScript, updateCmd, hostVethName, contVethMac, podIP, podConfig.vnid, podConfig.ingressBandwidth, podConfig.egressBandwidth).CombinedOutput()
376+
vnidStr := vnidToString(podConfig.vnid)
377+
out, err := exec.Command(sdnScript, updateCmd, hostVethName, contVethMac, podIP, vnidStr, podConfig.ingressBandwidth, podConfig.egressBandwidth).CombinedOutput()
372378
glog.V(5).Infof("UpdatePod network plugin output: %s, %v", string(out), err)
373379

374380
if isScriptError(err) {

0 commit comments

Comments
 (0)