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

Commit 3d5bf27

Browse files
committed
Set logging level to warning for failed commands
1 parent 6b5a6f2 commit 3d5bf27

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

pkg/exec/exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ func RunCommand(cmd string, args ...string) ([]string, error) {
4747
return nil, err
4848
}
4949

50-
output, err := command.Output()
50+
output, err := command.CombinedOutput()
5151
if err != nil {
52-
return nil, err
52+
return []string{string(output)}, err
5353
}
5454
return strings.Split(strings.TrimSpace(string(output)), "\n"), nil
5555
}

pkg/plugins/openvswitch/openvswitch.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -351,34 +351,39 @@ func (p *OVSPlugin) SetupInterface(podName, podInfraContainerID string, port *po
351351
return nil
352352
}
353353

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+
_, qvo := p.buildVethName(portID)
356+
output, err := exec.RunCommand("ip", "link", "set", "dev", qvo, "down")
357357
if err != nil {
358-
glog.V(5).Infof("Warning: DestroyInterface failed: %v", err)
358+
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
359359
}
360360

361-
_, err = exec.RunCommand("ovs-vsctl", "-vconsole:off", "--if-exists", "del-port", qvo)
361+
output, err = exec.RunCommand("ip", "link", "delete", "dev", qvo)
362362
if err != nil {
363-
glog.V(5).Infof("Warning: DestroyInterface failed: %v", err)
363+
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
364364
}
365365

366-
bridge := p.buildBridgeName(port.ID)
367-
_, err = exec.RunCommand("ip", "link", "set", bridge, "down")
366+
output, err = exec.RunCommand("ovs-vsctl", "-vconsole:off", "--if-exists", "del-port", qvo)
368367
if err != nil {
369-
glog.V(5).Infof("Warning: DestroyInterface failed: %v", err)
368+
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
370369
}
371370

372-
_, err = exec.RunCommand("brctl", "delbr", bridge)
371+
bridge := p.buildBridgeName(portID)
372+
output, err = exec.RunCommand("ip", "link", "set", "dev", bridge, "down")
373373
if err != nil {
374-
glog.V(5).Infof("Warning: DestroyInterface failed: %v", err)
374+
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
375+
}
376+
377+
output, err = exec.RunCommand("brctl", "delbr", bridge)
378+
if err != nil {
379+
glog.Warningf("Warning: DestroyInterface failed: %v, %v", output, err)
375380
}
376381

377382
return nil
378383
}
379384

380-
func (p *OVSPlugin) destroyDockerInterface(podName, podInfraContainerID string, port *ports.Port) error {
381-
tapName, _ := p.buildTapName(port.ID)
385+
func (p *OVSPlugin) destroyDockerInterface(podName, podInfraContainerID, portID string) error {
386+
tapName, _ := p.buildTapName(portID)
382387
_, err := exec.RunCommand("ip", "link", "delete", tapName)
383388
if err != nil {
384389
glog.V(5).Infof("Warning: DestroyInterface failed: %v", err)
@@ -401,11 +406,11 @@ func (p *OVSPlugin) destroyDockerInterface(podName, podInfraContainerID string,
401406
}
402407

403408
func (p *OVSPlugin) DestroyInterface(podName, podInfraContainerID string, port *ports.Port, containerRuntime string) error {
404-
p.destroyOVSInterface(podName, podInfraContainerID, port)
409+
p.destroyOVSInterface(podName, podInfraContainerID, port.ID)
405410

406411
switch containerRuntime {
407412
case runtimeTypeDocker:
408-
p.destroyDockerInterface(podName, podInfraContainerID, port)
413+
p.destroyDockerInterface(podName, podInfraContainerID, port.ID)
409414
default:
410415
glog.V(4).Infof("DestroyInterface for %s done", containerRuntime)
411416
}

0 commit comments

Comments
 (0)