ratelimitmap: init maps before metrics collection #39361
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, starting the Cilium Agent can result in the following
warning when collecting metrics on the ratelimit metrics map starts
before the daemon initialized the ratelimit metrics map.
The reason is that the map gets initialized via the daemon init logic
(that calls
ratelimitmap.InitMaps
- while the metrics collectorgets registered via Hive lifecycle.
Therefore, this commit initializes the ratelimit metrics map
with a Hive lifecycle hook and lets the metrics registration depend
on the map. This way it's ensured that the map is created when
the metrics collection starts.
Seen on #39357 in the ci-ginkgo tests (e.g. https://github.com/cilium/cilium/actions/runs/14856075257/job/41713009262). It's likely that the change of Daemon dependencies in that PR lead to exposing this issue. But the actual issue exists in the current codebase.
Agent logs from a sysdump
-> daemon init starts after ratelimit metrics collection