From d9e1cd1cad29de427bfdeea25aea71092c51a613 Mon Sep 17 00:00:00 2001 From: Mengxin Liu Date: Fri, 6 Dec 2019 13:59:13 +0800 Subject: [PATCH] fix: gc logical_switch_port form listing pods and nodes --- docs/install.md | 1 + pkg/controller/controller.go | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/install.md b/docs/install.md index 9b98ddb7434..cbb40e8c33f 100644 --- a/docs/install.md +++ b/docs/install.md @@ -93,5 +93,6 @@ You can use `--default-cidr` flags below to config default Pod CIDR or create a rm -rf /etc/origin/openvswitch/ rm -rf /etc/openvswitch rm -rf /etc/cni/net.d/00-kube-ovn.conflist + rm -rf /var/log/openvswitch ``` 3. Reboot the Node to remove ipset/iptables rules and nics. diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 0bd5ba9fe36..ceca98a3944 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -419,14 +419,22 @@ func (c *Controller) gcNode() error { func (c *Controller) gcLogicalSwitchPort() error { klog.Infof("start to gc logical switch ports") - ips, err := c.ipsLister.List(labels.Everything()) + pods, err := c.podsLister.List(labels.Everything()) if err != nil { klog.Errorf("failed to list ip, %v", err) return err } - ipNames := make([]string, 0, len(ips)) - for _, ip := range ips { - ipNames = append(ipNames, ip.Name) + nodes, err := c.nodesLister.List(labels.Everything()) + if err != nil { + klog.Errorf("failed to list node, %v", err) + return err + } + ipNames := make([]string, 0, len(pods) + len(nodes)) + for _, pod := range pods { + ipNames = append(ipNames, fmt.Sprintf("%s.%s", pod.Name, pod.Namespace)) + } + for _, node := range nodes { + ipNames = append(ipNames, fmt.Sprintf("node-%s", node.Name)) } lsps, err := c.ovnClient.ListLogicalSwitchPort() if err != nil {