Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.8] Bug 2004336: Ensure host interfaces are deleted by CNI #745

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions go-controller/pkg/cni/helper_linux.go
Expand Up @@ -8,7 +8,6 @@ import (
"io/ioutil"
"net"
"os"
"os/exec"
"strconv"
"strings"

Expand Down Expand Up @@ -351,6 +350,7 @@ func (pr *PodRequest) ConfigureInterface(podLister corev1listers.PodLister, kcli
err = ConfigureOVS(pr.ctx, pr.PodNamespace, pr.PodName, hostIface.Name, ifInfo, pr.SandboxID,
podLister, kclient, pr.PodUID)
if err != nil {
pr.deletePorts()
return nil, err
}
}
Expand Down Expand Up @@ -416,18 +416,19 @@ func (pr *PodRequest) deletePodConntrack() {
}
}

// PlatformSpecificCleanup deletes the OVS port
func (pr *PodRequest) PlatformSpecificCleanup() error {
func (pr *PodRequest) deletePorts() {
ifaceName := pr.SandboxID[:15]
ovsArgs := []string{
"del-port", "br-int", ifaceName,
}
out, err := exec.Command("ovs-vsctl", ovsArgs...).CombinedOutput()
if err != nil && !strings.Contains(string(out), "no port named") {
out, err := ovsExec("del-port", "br-int", ifaceName)
_ = util.LinkDelete(ifaceName)
if err != nil && !strings.Contains(out, "no port named") {
// DEL should be idempotent; don't return an error just log it
klog.Warningf("Failed to delete OVS port %s: %v\n %q", ifaceName, err, string(out))
}
}

// PlatformSpecificCleanup deletes the OVS port
func (pr *PodRequest) PlatformSpecificCleanup() error {
pr.deletePorts()
_ = clearPodBandwidth(pr.SandboxID)
pr.deletePodConntrack()

Expand Down