DataDog / extendeddaemonset

Kubernetes Extended Daemonset controller
Apache License 2.0
98 stars 13 forks source link

fix: simplify cleanupReplicaSet for less memory allocations #132

Closed ahmed-mez closed 2 years ago

ahmed-mez commented 2 years ago

What does this PR do?

Simplify cleanupReplicaSet: instead of getting full pod list to decide whether a ERS must be deleted, rely on the info stored in its status.

Querying the a pod list is a costly operation especially in larger clusters during a rolling update as the old ERS still have a large non-nil list of pods attached to it.

Motivation

image

A is before the rolling update, B is during the rolling update (cluster size: 1.6k nodes)

Additional Notes

cleanupReplicaSet is covered by unit tests/

Describe your test plan

Rollout new workload versions multiple times, make sure old ERSs get deleted.

codecov-commenter commented 2 years ago

Codecov Report

Merging #132 (ea7e95f) into main (aa7cbbf) will increase coverage by 0.02%. The diff coverage is 60.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #132      +/-   ##
==========================================
+ Coverage   62.35%   62.37%   +0.02%     
==========================================
  Files          41       41              
  Lines        2186     2166      -20     
==========================================
- Hits         1363     1351      -12     
+ Misses        715      710       -5     
+ Partials      108      105       -3     
Flag Coverage Δ
unittests 62.37% <60.00%> (+0.02%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
controllers/extendeddaemonset/utils.go 90.24% <ø> (+2.74%) :arrow_up:
controllers/extendeddaemonset/controller.go 77.06% <60.00%> (+1.03%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update aa7cbbf...ea7e95f. Read the comment docs.