-
Notifications
You must be signed in to change notification settings - Fork 129
Component reconcile refactor #2434
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
base: main
Are you sure you want to change the base?
Conversation
…ts/utils; test pass
57dcb1e to
17063f8
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2434 +/- ##
==========================================
+ Coverage 38.06% 38.10% +0.03%
==========================================
Files 290 290
Lines 24760 24750 -10
==========================================
+ Hits 9425 9431 +6
+ Misses 14620 14609 -11
+ Partials 715 710 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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 also have the implementation in the DDAI code path, which was not changed to follow the same pattern.
The bug I described below only applies in the DDA code path
| condition.UpdateDatadogAgentStatusConditions( | ||
| params.Status, | ||
| now, | ||
| metav1.NewTime(time.Now()), |
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 this intended instead of using the function-level now ?
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 an issue here: if the component override struct is not empty but not explicitly disabled, we reconcile a component that should not be possibly (CCR is not enabled by default).
features:
clusterChecks:
enabled: true
useClusterChecksRunners: false
override:
clusterChecksRunner:
disabled: true
containers:
agent:
resources:
requests: 256m-> we get a CCR deployment (no pods scheduled cuz missing dependencies but the component shouldnt be reconciled at all)
We could early exit instead of further reconciling:
// Explicit override disable always wins (and may create a conflict condition if the component is otherwise enabled).
if ok && apiutils.BoolValue(componentOverride.Disabled) {
if componentEnabled {
// The override supersedes what's set in requiredComponents; update status to reflect the conflict
condition.UpdateDatadogAgentStatusConditions(
params.Status,
now,
common.OverrideReconcileConflictConditionType,
metav1.ConditionTrue,
"OverrideConflict",
fmt.Sprintf("%s component is set to disabled", component.Name()),
true,
)
}
return r.Cleanup(ctx, params, component)
}
// If the component isn't enabled, we should cleanup regardless of whether an override struct exists.
// (Overrides should not implicitly enable a component.)
if !componentEnabled {
return r.Cleanup(ctx, params, component)
}
// Apply non-disable overrides.
if ok {
override.PodTemplateSpec(params.Logger, podManagers, componentOverride, component.Name(), params.DDA.Name)
override.Deployment(deployment, componentOverride)
}| podManagers := feature.NewPodTemplateManagers(&deployment.Spec.Template) | ||
|
|
||
| // Set Global setting on the default deployment | ||
| component.GetGlobalSettingsFunc()(params.Logger, podManagers, params.DDA.GetObjectMeta(), ¶ms.DDA.Spec, params.ResourceManagers, params.RequiredComponents) |
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.
| component.GetGlobalSettingsFunc()(params.Logger, podManagers, params.DDA.GetObjectMeta(), ¶ms.DDA.Spec, params.ResourceManagers, params.RequiredComponents) | |
| component.GetGlobalSettingsFunc()(deploymentLogger, podManagers, params.DDA.GetObjectMeta(), ¶ms.DDA.Spec, params.ResourceManagers, params.RequiredComponents) |
| continue | ||
| return r.Cleanup(ctx, params, component) | ||
| } | ||
| override.PodTemplateSpec(params.Logger, podManagers, componentOverride, component.Name(), params.DDA.Name) |
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.
| override.PodTemplateSpec(params.Logger, podManagers, componentOverride, component.Name(), params.DDA.Name) | |
| override.PodTemplateSpec(deploymentLogger, podManagers, componentOverride, component.Name(), params.DDA.Name) |
What does this PR do?
Ultimate goal of this change is to move
ReconcileandCleanupto ComponentRegistry and remove those from theComponentReconcilerinterface. Assumption is that these two should be almost same for all components (except maybe Agent). Two hooks are still necessary: 1) for cleaning up DCA RBAC 2) deleting CLC if DCA is disabled. These are added to the interface.ComponentReconciler/Registry refactor following approach in #2380.
controller_reconcile_deployment_test.goto assert on existing behavior.controller_reconcile_deployment_test.gobut disables as tests fail. There seems some variation between DDA/DDAI components, hence this change can't be drop-in replacement of DDAI components.cleanupV2***functions in two parts: 1) deleting deployment 2) updating status. Regular reconcile flow executes both,cleanupOld***only deployment deletion. Reasoning is that deleting old/stale deployments after rename shouldn't cleanup status on DDA.controller_reconcile_v2_helpers.goas this is not component specific any more.ComponentRegistry, some minor cleanup.ComponentReconcilerReconcile()from components to a common one inComponentRegistry, removes interface function.Cleanup.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
Write there any instructions and details you may have to test your PR.
Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel