@@ -351,34 +351,45 @@ func (p *OVSPlugin) SetupInterface(podName, podInfraContainerID string, port *po
351
351
return nil
352
352
}
353
353
354
- func (p * OVSPlugin ) destroyOVSInterface (podName , podInfraContainerID string , port * ports.Port ) error {
355
- _ , qvo := p .buildVethName (port .ID )
356
- _ , err := exec .RunCommand ("ip" , "link" , "delete" , qvo )
354
+ func (p * OVSPlugin ) destroyOVSInterface (podName , podInfraContainerID , portID string ) error {
355
+ qvb , qvo := p .buildVethName (portID )
356
+ bridge := p .buildBridgeName (portID )
357
+
358
+ output , err := exec .RunCommand ("brctl" , "delif" , bridge , qvb )
357
359
if err != nil {
358
- glog .V ( 5 ). Infof ( "Warning: DestroyInterface failed: %v" , err )
360
+ glog .Warningf ( "Warning: brctl delif %s failed: %v, %v" , qvb , output , err )
359
361
}
360
362
361
- _ , err = exec .RunCommand ("ovs-vsctl " , "-vconsole:off " , "--if-exists " , "del-port " , qvo )
363
+ output , err = exec .RunCommand ("ip " , "link " , "set " , "dev " , bridge , "down" )
362
364
if err != nil {
363
- glog .V ( 5 ). Infof ( "Warning: DestroyInterface failed: %v" , err )
365
+ glog .Warningf ( "Warning: set bridge %s down failed: %v, %v" , bridge , output , err )
364
366
}
365
367
366
- bridge := p .buildBridgeName (port .ID )
367
- _ , err = exec .RunCommand ("ip" , "link" , "set" , bridge , "down" )
368
+ output , err = exec .RunCommand ("brctl" , "delbr" , bridge )
368
369
if err != nil {
369
- glog .V ( 5 ). Infof ( "Warning: DestroyInterface failed: %v" , err )
370
+ glog .Warningf ( "Warning: delete bridge %s failed: %v, %v" , bridge , output , err )
370
371
}
371
372
372
- _ , err = exec .RunCommand ("brctl " , "delbr " , bridge )
373
+ output , err = exec .RunCommand ("ovs-vsctl " , "-vconsole:off " , "--if-exists" , "del-port" , qvo )
373
374
if err != nil {
374
- glog .V (5 ).Infof ("Warning: DestroyInterface failed: %v" , err )
375
+ glog .Warningf ("Warning: ovs del-port %s failed: %v, %v" , qvo , output , err )
376
+ }
377
+
378
+ output , err = exec .RunCommand ("ip" , "link" , "set" , "dev" , qvo , "down" )
379
+ if err != nil {
380
+ glog .Warningf ("Warning: set dev %s down failed: %v, %v" , qvo , output , err )
381
+ }
382
+
383
+ output , err = exec .RunCommand ("ip" , "link" , "delete" , "dev" , qvo )
384
+ if err != nil {
385
+ glog .Warningf ("Warning: delete dev %s failed: %v, %v" , qvo , output , err )
375
386
}
376
387
377
388
return nil
378
389
}
379
390
380
- func (p * OVSPlugin ) destroyDockerInterface (podName , podInfraContainerID string , port * ports. Port ) error {
381
- tapName , _ := p .buildTapName (port . ID )
391
+ func (p * OVSPlugin ) destroyDockerInterface (podName , podInfraContainerID , portID string ) error {
392
+ tapName , _ := p .buildTapName (portID )
382
393
_ , err := exec .RunCommand ("ip" , "link" , "delete" , tapName )
383
394
if err != nil {
384
395
glog .V (5 ).Infof ("Warning: DestroyInterface failed: %v" , err )
@@ -401,11 +412,11 @@ func (p *OVSPlugin) destroyDockerInterface(podName, podInfraContainerID string,
401
412
}
402
413
403
414
func (p * OVSPlugin ) DestroyInterface (podName , podInfraContainerID string , port * ports.Port , containerRuntime string ) error {
404
- p .destroyOVSInterface (podName , podInfraContainerID , port )
415
+ p .destroyOVSInterface (podName , podInfraContainerID , port . ID )
405
416
406
417
switch containerRuntime {
407
418
case runtimeTypeDocker :
408
- p .destroyDockerInterface (podName , podInfraContainerID , port )
419
+ p .destroyDockerInterface (podName , podInfraContainerID , port . ID )
409
420
default :
410
421
glog .V (4 ).Infof ("DestroyInterface for %s done" , containerRuntime )
411
422
}
0 commit comments