-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[profiles] Reduce patch frequency #1317
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1317 +/- ##
==========================================
+ Coverage 47.36% 47.51% +0.15%
==========================================
Files 230 230
Lines 22027 22040 +13
==========================================
+ Hits 10432 10472 +40
+ Misses 11005 10976 -29
- Partials 590 592 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
@@ -1534,3 +1536,432 @@ func Test_removeStaleStatus(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func Test_labelNodesWithProfiles(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding comprehensive test!
// the node, it should be added. | ||
if !isDefaultProfile && !profileLabelExists { | ||
newLabels[agentprofile.ProfileLabelKey] = profileNamespacedName.Name | ||
if len(labelsToRemove) > 0 || len(labelsToAddOrChange) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a benefit to having this ||
instead of two separate conditionals? i think it might be more intuitive if it were separated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first for loop for labelsToRemove
goes through all the node labels but the second one for labelsToAddOrChange
doesn't. If we separated them, we'd need to loop through node.Labels
twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see, thanks! so we only populate newLabels
(with all wanted labels) if there's anything to change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one small comment, otherwise looks good!
* Reduce patch requests * Loop through all profilesByNode * Refactor * go lint
* Reduce patch requests * Loop through all profilesByNode * Refactor * go lint Co-authored-by: khewonc <[email protected]>
* Reduce patch requests * Loop through all profilesByNode * Refactor * go lint
* Reduce patch requests * Loop through all profilesByNode * Refactor * go lint
What does this PR do?
Nodes were being patched every reconcile when there was no change in labels. This only patches nodes when there is a label change
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Minimum Agent Versions
Are there minimum versions of the Datadog Agent and/or Cluster Agent required?
Describe your test plan
Test in staging:
Checklist
bug
,enhancement
,refactoring
,documentation
,tooling
, and/ordependencies
qa/skip-qa
label