Skip to content

Commit 5c6a24d

Browse files
authored
Fix NPE when performing cleanup() (#458)
* Fix NPE when performing cleanup() * update cleanup documentaion
1 parent 1c7866c commit 5c6a24d

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

docs/user-guide.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ kube-router --master=http://192.168.1.99:8080/ --run-firewall=true --run-service
9595

9696
## cleanup configuration
9797

98-
You can clean up all the configurations done (to ipvs, iptables, ip routes) by kube-router on the node by running
98+
Please delete kube-router daemonset and then clean up all the configurations done (to ipvs, iptables, ipset, ip routes etc) by kube-router on the node by running below command.
99+
99100
```
100-
kube-router --cleanup-config
101+
docker run --privileged --net=host cloudnativelabs/kube-router --cleanup-config
101102
```
102103

103104
## trying kube-router as alternative to kube-proxy

pkg/controllers/netpol/network_policy_controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,15 @@ func (npc *NetworkPolicyController) Cleanup() {
14141414
}
14151415

14161416
// delete all ipsets
1417-
err = npc.ipSetHandler.DestroyAllWithin()
1417+
ipset, err := utils.NewIPSet()
1418+
if err != nil {
1419+
glog.Errorf("Failed to clean up ipsets: " + err.Error())
1420+
}
1421+
err = ipset.Save()
1422+
if err != nil {
1423+
glog.Errorf("Failed to clean up ipsets: " + err.Error())
1424+
}
1425+
err = ipset.DestroyAllWithin()
14181426
if err != nil {
14191427
glog.Errorf("Failed to clean up ipsets: " + err.Error())
14201428
}

pkg/controllers/routing/network_routes_controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,16 @@ func (nrc *NetworkRoutingController) Cleanup() {
446446
glog.Warningf("Error deleting Pod egress iptable rule: %s", err.Error())
447447
}
448448

449-
err = nrc.ipSetHandler.DestroyAllWithin()
449+
// delete all ipsets created by kube-router
450+
ipset, err := utils.NewIPSet()
451+
if err != nil {
452+
glog.Errorf("Failed to clean up ipsets: " + err.Error())
453+
}
454+
err = ipset.Save()
455+
if err != nil {
456+
glog.Errorf("Failed to clean up ipsets: " + err.Error())
457+
}
458+
err = ipset.DestroyAllWithin()
450459
if err != nil {
451460
glog.Warningf("Error deleting ipset: %s", err.Error())
452461
}

0 commit comments

Comments
 (0)