Skip to content

Commit 355c729

Browse files
committed
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
1 parent 38c9545 commit 355c729

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Diff for: pkg/sdn/plugin/pod_linux.go

+12-6
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,7 +328,8 @@ 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) {
@@ -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)