@@ -105,19 +105,38 @@ func (ln *linuxNetworking) ipAddrDel(iface netlink.Link, ip string, nodeIP strin
105
105
Scope : syscall .RT_SCOPE_HOST ,
106
106
Src : parsedNodeIP ,
107
107
}
108
- err = netlink .RouteDel (nRoute )
108
+ routes , err := netlink .RouteListFiltered (netlink .FAMILY_ALL , nRoute ,
109
+ netlink .RT_FILTER_TYPE | netlink .RT_FILTER_DST | netlink .RT_FILTER_OIF | netlink .RT_FILTER_TABLE | netlink .RT_FILTER_SRC )
109
110
if err != nil {
110
- if ! strings .Contains (err .Error (), "no such process" ) {
111
- klog .Errorf ("Failed to delete route to service VIP %s configured on %s. Error: %v" ,
112
- ip , iface .Attrs ().Name , err )
113
- } else {
114
- klog .Warningf ("got a No such process error while trying to remove route: %v (this is not normally bad " +
115
- "enough to stop processing)" , err )
116
- return nil
111
+ return fmt .Errorf ("failed to list filtered routes for route %s: %v" , nRoute , err )
112
+ }
113
+
114
+ // Let the user know if we found more than 1 route that matched a single route filter
115
+ if len (routes ) > 1 {
116
+ klog .Warning ("Found more than 1 route that matched a single route filter, this is not expected, please " +
117
+ "report this upstream as a bug if you see this message along with the information below:" )
118
+ for _ , route := range routes {
119
+ klog .Infof ("Found route: %s" , route )
117
120
}
121
+ klog .Warningf ("Continuing with deletion of the route we know about: %s" , nRoute )
118
122
}
119
123
120
- return err
124
+ // If we found one or no routes, this is expected, so we can proceed with the action
125
+ if len (routes ) > 0 {
126
+ klog .V (1 ).Infof ("Found %d routes for interface %s, deleting them..." , len (routes ), iface .Attrs ().Name )
127
+ err = netlink .RouteDel (nRoute )
128
+ if err != nil {
129
+ if ! strings .Contains (err .Error (), "no such process" ) {
130
+ return fmt .Errorf ("failed to delete route %s: %v" , nRoute , err )
131
+ }
132
+ klog .Warningf ("got a No such process error while trying to remove route %s: %v (this is not normally bad " +
133
+ "enough to stop processing)" , nRoute , err )
134
+ }
135
+ } else {
136
+ klog .V (1 ).Infof ("No routes found for %s, skipping deletion" , nRoute )
137
+ }
138
+
139
+ return nil
121
140
}
122
141
123
142
// utility method to assign an IP to an interface. Mainly used to assign service VIP's
0 commit comments