Skip to content

Commit 0538a2a

Browse files
authored
perform clean-up of external ip from custom route table for external ip only if the table is not empty (#437)
1 parent 6d86656 commit 0538a2a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pkg/controllers/proxy/network_services_controller.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,17 +1686,19 @@ func (ln *linuxNetworking) setupRoutesForExternalIPForDSR(serviceInfoMap service
16861686
}
16871687
}
16881688

1689-
// clean up stale external IPs
1690-
for _, line := range strings.Split(strings.Trim(outStr, "\n"), "\n") {
1691-
route := strings.Split(strings.Trim(line, " "), " ")
1692-
ip := route[0]
1693-
1694-
if !activeExternalIPs[ip] {
1695-
args := []string{"route", "del", "table", externalIPRouteTableId}
1696-
args = append(args, route...)
1697-
if err = exec.Command("ip", args...).Run(); err != nil {
1698-
glog.Errorf("Failed to del route for %v in custom route table for external IP's due to: %s", ip, err)
1699-
continue
1689+
// check if there are any pbr in externalIPRouteTableId for external IP's
1690+
if len(outStr) > 0 {
1691+
// clean up stale external IPs
1692+
for _, line := range strings.Split(strings.Trim(outStr, "\n"), "\n") {
1693+
route := strings.Split(strings.Trim(line, " "), " ")
1694+
ip := route[0]
1695+
if !activeExternalIPs[ip] {
1696+
args := []string{"route", "del", "table", externalIPRouteTableId}
1697+
args = append(args, route...)
1698+
if err = exec.Command("ip", args...).Run(); err != nil {
1699+
glog.Errorf("Failed to del route for %v in custom route table for external IP's due to: %s", ip, err)
1700+
continue
1701+
}
17001702
}
17011703
}
17021704
}

0 commit comments

Comments
 (0)