cri: skip stats collection for non-running containers and sandboxes#13150
Open
aattilio wants to merge 1 commit intocontainerd:mainfrom
Open
cri: skip stats collection for non-running containers and sandboxes#13150aattilio wants to merge 1 commit intocontainerd:mainfrom
aattilio wants to merge 1 commit intocontainerd:mainfrom
Conversation
10d2216 to
ef9f878
Compare
Member
A few comments before looking at the code:
|
ef9f878 to
41083ac
Compare
0bddf04 to
2ce0f19
Compare
2ce0f19 to
d4a84f1
Compare
Author
|
I introduced a new unit test in internal/cri/server/stats_collector_linux_test.go to validate the reduction in CPU load, confirming the StatsCollector now correctly filters containers based on their status and manages the removal of obsolete data from the TimedStore, moreover resolving the linter issues by restoring the normalizePodSandboxStatsFilter function. |
Member
I don't think it does that? It validates that exited containers are removed from the stores. |
d4a84f1 to
9b56a1d
Compare
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com> Assisted-by: Gemini CLI <gemini-cli@google.com>
9b56a1d to
f3d3f10
Compare
Author
|
I added Result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This change addresses performance and memory issues when a node has a large number of stopped containers (e.g. Succeeded/Completed pods in Kubernetes).
Fixes #13037
Key changes:
This significantly reduces CPU usage and memory churn on nodes with high pod churn.
Verification:
internal/cri/server/container_stats_list_test.goto verify thatbuildTaskMetricsRequestcorrectly filters for running containers when no filter is provided.internal/cri/server/stats_collector_linux_test.gowith a unit test to verify that the backgroundStatsCollectorcorrectly filters containers/sandboxes based on state and removes stale data.internal/cri/server/stats_collector_linux_test.go(BenchmarkCollectContainerStats) to demonstrate the efficiency of the filtering logic in high-churn scenarios (e.g., 1000 containers).Maintainer Feedback Addressed:
upstream/mainto remove merge commits.Assisted-bytrailer to the commit.