hcloud-cloud-controller-manager icon indicating copy to clipboard operation
hcloud-cloud-controller-manager copied to clipboard

fix(routes): many requests for outdated routes by rate limiting

Open apricote opened this issue 5 days ago • 1 comments

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.

apricote avatar Jul 02 '24 13:07 apricote