Skip to content

Commit

Permalink
fix: gc logical_switch_port form listing pods and nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Dec 6, 2019
1 parent d07b104 commit d9e1cd1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 12 additions & 4 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d9e1cd1

Please sign in to comment.