@@ -42,7 +42,7 @@ const (
42
42
)
43
43
44
44
type PodConfig struct {
45
- vnid string
45
+ vnid uint32
46
46
ingressBandwidth string
47
47
egressBandwidth string
48
48
wantMacvlan bool
@@ -86,14 +86,14 @@ func wantsMacvlan(pod *kapi.Pod) (bool, error) {
86
86
// Create and return a PodConfig describing which openshift-sdn specific pod attributes
87
87
// to configure
88
88
func (m * podManager ) getPodConfig (req * cniserver.PodRequest ) (* PodConfig , * kapi.Pod , error ) {
89
- config := & PodConfig {}
89
+ var err error
90
90
91
+ config := & PodConfig {}
91
92
if m .multitenant {
92
- vnid , err : = m .vnids .GetVNID (req .PodNamespace )
93
+ config . vnid , err = m .vnids .GetVNID (req .PodNamespace )
93
94
if err != nil {
94
95
return nil , nil , err
95
96
}
96
- config .vnid = strconv .FormatUint (uint64 (vnid ), 10 )
97
97
}
98
98
99
99
pod , err := m .kClient .Pods (req .PodNamespace ).Get (req .PodName )
@@ -255,6 +255,10 @@ func getScriptError(output []byte) string {
255
255
return string (output )
256
256
}
257
257
258
+ func vnidToString (vnid uint32 ) string {
259
+ return strconv .FormatUint (uint64 (vnid ), 10 )
260
+ }
261
+
258
262
// Set up all networking (host/container veth, OVS flows, IPAM, loopback, etc)
259
263
func (m * podManager ) setup (req * cniserver.PodRequest ) (* cnitypes.Result , * kubehostport.RunningPod , error ) {
260
264
podConfig , pod , err := m .getPodConfig (req )
@@ -324,11 +328,12 @@ func (m *podManager) setup(req *cniserver.PodRequest) (*cnitypes.Result, *kubeho
324
328
}
325
329
326
330
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 ()
328
333
glog .V (5 ).Infof ("SetUpPod network plugin output: %s, %v" , string (out ), err )
329
334
330
335
if isScriptError (err ) {
331
- return nil , nil , fmt .Errorf ("error running network setup script:\n hostVethName %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:\n hostVethName %s, contVethMac %s, podIP %s, podConfig %#v\n %s" , hostVeth .Attrs ().Name , contVethMac , podIP .String (), podConfig , getScriptError ( out ) )
332
337
} else if err != nil {
333
338
return nil , nil , err
334
339
}
@@ -368,7 +373,8 @@ func (m *podManager) update(req *cniserver.PodRequest) error {
368
373
return err
369
374
}
370
375
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 ()
372
378
glog .V (5 ).Infof ("UpdatePod network plugin output: %s, %v" , string (out ), err )
373
379
374
380
if isScriptError (err ) {
0 commit comments