mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-06 23:41:08 +02:00
perform clean-up of external ip from custom route table for external ip only if the table is not empty (#437)
This commit is contained in:
parent
6d86656f5e
commit
0538a2a93e
@ -1686,17 +1686,19 @@ func (ln *linuxNetworking) setupRoutesForExternalIPForDSR(serviceInfoMap service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up stale external IPs
|
// check if there are any pbr in externalIPRouteTableId for external IP's
|
||||||
for _, line := range strings.Split(strings.Trim(outStr, "\n"), "\n") {
|
if len(outStr) > 0 {
|
||||||
route := strings.Split(strings.Trim(line, " "), " ")
|
// clean up stale external IPs
|
||||||
ip := route[0]
|
for _, line := range strings.Split(strings.Trim(outStr, "\n"), "\n") {
|
||||||
|
route := strings.Split(strings.Trim(line, " "), " ")
|
||||||
if !activeExternalIPs[ip] {
|
ip := route[0]
|
||||||
args := []string{"route", "del", "table", externalIPRouteTableId}
|
if !activeExternalIPs[ip] {
|
||||||
args = append(args, route...)
|
args := []string{"route", "del", "table", externalIPRouteTableId}
|
||||||
if err = exec.Command("ip", args...).Run(); err != nil {
|
args = append(args, route...)
|
||||||
glog.Errorf("Failed to del route for %v in custom route table for external IP's due to: %s", ip, err)
|
if err = exec.Command("ip", args...).Run(); err != nil {
|
||||||
continue
|
glog.Errorf("Failed to del route for %v in custom route table for external IP's due to: %s", ip, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user