hcloud-cloud-controller-manager
hcloud-cloud-controller-manager copied to clipboard
fix(routes): many requests for outdated routes by rate limiting
Fixes #673
In routes.ListRoutes()
we have to find the matching server/node for every route in the network. We find the server by utilizing a cache that maps every private IP to the corresponding server.
This cache has a feature that refreshes the list of servers if an entry can not be found. This is sensible, as the server might have been just created. This is also fatal, as this refresh happens for every single cache access. If there are a lot of routes in the network that do not belong to any server, we refresh the cache many times for each ListRoutes()
. This is even more serious, as ListRoutes()
is being called every 10-30 seconds (see #395).
This commit introduces a rate.Limiter
in the AllServersCache
which only allows the refresh to happen every 30 seconds.