Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 175ebed

Browse files
committed
Refactor destroyOVSInterface to avoid failing
1 parent 3d5bf27 commit 175ebed

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

pkg/kubestack/kubestack.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ func NewKubeHandler(driver *common.OpenStack) *KubeHandler {
4343
}
4444

4545
func (h *KubeHandler) Serve(addr string) error {
46+
glog.V(1).Infof("Starting kubestack at %s", addr)
4647
l, err := net.Listen("tcp", addr)
4748
if err != nil {
48-
glog.Fatal("Failed to listen: %s", addr)
49+
glog.Fatalf("Failed to listen: %s", addr)
4950
return err
5051
}
5152
return h.server.Serve(l)

pkg/plugins/openvswitch/openvswitch.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,31 +352,37 @@ func (p *OVSPlugin) SetupInterface(podName, podInfraContainerID string, port *po
352352
}
353353

354354
func (p *OVSPlugin) destroyOVSInterface(podName, podInfraContainerID, portID string) error {
355-
_, qvo := p.buildVethName(portID)
356-
output, err := exec.RunCommand("ip", "link", "set", "dev", qvo, "down")
355+
qvb, qvo := p.buildVethName(portID)
356+
bridge := p.buildBridgeName(portID)
357+
358+
output, err := exec.RunCommand("brctl", "delif", bridge, qvb)
357359
if err != nil {
358-
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
360+
glog.Warningf("Warning: brctl delif %s failed: %v, %v", qvb, output, err)
359361
}
360362

361-
output, err = exec.RunCommand("ip", "link", "delete", "dev", qvo)
363+
output, err = exec.RunCommand("ip", "link", "set", "dev", bridge, "down")
364+
if err != nil {
365+
glog.Warningf("Warning: set bridge %s down failed: %v, %v", bridge, output, err)
366+
}
367+
368+
output, err = exec.RunCommand("brctl", "delbr", bridge)
362369
if err != nil {
363-
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
370+
glog.Warningf("Warning: delete bridge %s failed: %v, %v", bridge, output, err)
364371
}
365372

366373
output, err = exec.RunCommand("ovs-vsctl", "-vconsole:off", "--if-exists", "del-port", qvo)
367374
if err != nil {
368-
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
375+
glog.Warningf("Warning: ovs del-port %s failed: %v, %v", qvo, output, err)
369376
}
370377

371-
bridge := p.buildBridgeName(portID)
372-
output, err = exec.RunCommand("ip", "link", "set", "dev", bridge, "down")
378+
output, err = exec.RunCommand("ip", "link", "set", "dev", qvo, "down")
373379
if err != nil {
374-
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
380+
glog.Warningf("Warning: set dev %s down failed: %v, %v", qvo, output, err)
375381
}
376382

377-
output, err = exec.RunCommand("brctl", "delbr", bridge)
383+
output, err = exec.RunCommand("ip", "link", "delete", "dev", qvo)
378384
if err != nil {
379-
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
385+
glog.Warningf("Warning: delete dev %s failed: %v, %v", qvo, output, err)
380386
}
381387

382388
return nil

0 commit comments

Comments
 (0)