-
Notifications
You must be signed in to change notification settings - Fork 131
[AGENTONB-2760] use UUID instead of HostName in metadata payload #2468
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2468 +/- ##
=======================================
Coverage 37.30% 37.30%
=======================================
Files 290 290
Lines 24699 24686 -13
=======================================
- Hits 9213 9209 -4
+ Misses 14773 14764 -9
Partials 713 713
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
|
||
| type HelmMetadataPayload struct { | ||
| Hostname string `json:"hostname"` | ||
| UUID string `json:"uuid"` |
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.
Does this require schema or writer 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.
No, the dd-go backend creates a schema resource based on the HelmMetadataPayload object HelmMetadata (datadog_operator_helm_metadata) and the schema matches that struct.
tbavelier
left a comment
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.
We have payload.clusterUID, payload.UUID and payload.metadata.clusterUID for the same value, can we possibly remove clusterID from OperatorMetadata, CRDMetadata and HelmMetadata structs ? Also, possibly remove it from payload if it's not necessary in the schema at intake to only keep UUID ? (since it can be derived from UUID ?)
More generally (and outside the PR scope), we repeat a lot of OperatorVersion and KubernetesVersion keys in the structs, would it be possible to reduce duplication by using something like:
// CommonMetadata contains metadata fields shared across all metadata payload types.
// It is embedded anonymously in payload-specific metadata structs so the fields are
// flattened in JSON (e.g., "operator_version", "kubernetes_version").
type CommonMetadata struct {
OperatorVersion string `json:"operator_version"`
KubernetesVersion string `json:"kubernetes_version"`
}type OperatorMetadata struct {
// Shared
CommonMetadata
InstallMethodTool string `json:"install_method_tool"`
[...]type HelmMetadata struct {
// Shared
CommonMetadata
ChartName string `json:"chart_name"`Or differently since they're also present in sharedmetadata
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.
Not directly related to this PR, but we have a potential data race in func (omf *OperatorMetadataForwarder) GetPayload(clusterUID string).
In OperatorMetadataForwarder.GetPayload(), we use omf.mutex.RLock() (read lock) and then mutate shared state omf.OperatorMetadata.*.
- Multiple goroutines can hold an RLock() at the same time, so two callers could write to
omf.OperatorMetadataconcurrently. OperatorMetadatacontainsResourceCounts map[string]intwith maps not being safe for concurrent access if anyone might write.
A safe approach could be: copy under lock, unlock, then mutate the local copy and marshal
omf.mutex.RLock()
// Copy metadata while holding the lock, to avoid data races.
operatorMetadata := omf.OperatorMetadata
if omf.OperatorMetadata.ResourceCounts != nil {
operatorMetadata.ResourceCounts = make(map[string]int, len(omf.OperatorMetadata.ResourceCounts))
maps.Copy(operatorMetadata.ResourceCounts, omf.OperatorMetadata.ResourceCounts)
}
omf.mutex.RUnlock()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.
addressed in a separate PR: #2481
I think these will need to be kept since each instance of clusterID is needed for something different. One possible option would be to rely on |
yep, I have a card here to refactor sharedMetadata and reduce duplication. |
What does this PR do?
UUIDorHostNamepresent to send metadata payloads through it to REDAPL.hostNameto UUID. This makes more sense because metadata is not sent per host, rather it is sent once per cluster.UUIDis set toclusterUIDMotivation
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
Tested on a staging cluster (
gizmo), and verified that the payload is being successfully sent -- themodification_detected_atfield in DDSQL has been updated after the test image was deployed.Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel