-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[clusteragent/autoscaling] Check that autoscaling target is not cluster agent #28723
[clusteragent/autoscaling] Check that autoscaling target is not cluster agent #28723
Conversation
Test changes on VMUse this command from test-infra-definitions to manually test this PR changes on a VM: inv create-vm --pipeline-id=43465304 --os-family=ubuntu Note: This applies to commit 2182fa3 |
Regression DetectorRegression Detector ResultsRun ID: a17d9b0e-b178-499f-9ba5-f91b3b272426 Metrics dashboard Target profiles Baseline: 0cce24d Performance changes are noted in the perf column of each table:
No significant changes in experiment optimization goalsConfidence level: 90.00% There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.
|
perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
---|---|---|---|---|---|---|
➖ | uds_dogstatsd_to_api_cpu | % cpu utilization | +0.48 | [-0.39, +1.35] | 1 | Logs |
➖ | otel_to_otel_logs | ingress throughput | +0.38 | [-0.43, +1.19] | 1 | Logs |
➖ | file_tree | memory utilization | +0.14 | [+0.10, +0.17] | 1 | Logs |
➖ | idle | memory utilization | +0.05 | [+0.01, +0.08] | 1 | Logs |
➖ | tcp_dd_logs_filter_exclude | ingress throughput | +0.00 | [-0.01, +0.01] | 1 | Logs |
➖ | uds_dogstatsd_to_api | ingress throughput | -0.00 | [-0.00, +0.00] | 1 | Logs |
➖ | pycheck_lots_of_tags | % cpu utilization | -0.39 | [-2.75, +1.97] | 1 | Logs |
➖ | basic_py_check | % cpu utilization | -1.04 | [-3.98, +1.90] | 1 | Logs |
➖ | tcp_syslog_to_blackhole | ingress throughput | -4.14 | [-16.83, +8.55] | 1 | Logs |
Bounds Checks
perf | experiment | bounds_check_name | replicates_passed |
---|---|---|---|
❌ | idle | memory_usage | 0/10 |
Explanation
A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".
For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.
-
Its configuration does not mark it "erratic".
@@ -389,3 +408,10 @@ func (c *Controller) deletePodAutoscaler(ns, name string) error { | |||
} | |||
return nil | |||
} | |||
|
|||
func getDeploymentName() string { |
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.
Tooling already exists for that: https://github.com/DataDog/datadog-agent/blob/main/pkg/util/kubernetes/apiserver/common/common_linux.go
It reads DD_POD_NAME
which is already set and defaults to os.hostname()
(should work for DCA). From there you can use a variant of https://github.com/DataDog/datadog-agent/blob/main/pkg/util/kubernetes/helpers.go#L22-L40 to get Deployment name from POD 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.
Thanks! Made a new helper to get the deployment name from the pod name which reuses the code from the helper you shared here
@@ -272,6 +274,23 @@ func (c *Controller) syncPodAutoscaler(ctx context.Context, key, ns, name string | |||
// Reaching this point, we had an error in processing, clearing up global error | |||
podAutoscalerInternal.SetError(nil) | |||
|
|||
// Check that targetRef is not set to the cluster agent | |||
clusterAgentRef := autoscalingv2.CrossVersionObjectReference{ |
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.
You also need to check autoscaler namespace vs cluster agent namespace: https://github.com/DataDog/datadog-agent/blob/main/pkg/util/kubernetes/apiserver/common/common.go#L40-L49
Also not sure you need to compare the full CrossVersionObjectReference
. Basically if something has some name and namespace than DCA it's suspicious enough.
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.
Thinking more about it, you should try to cover both Cluster Agent Deployment AND direct ReplicaSet
APIVersion: "apps/v1", | ||
} | ||
|
||
if podAutoscaler.Spec.TargetRef == clusterAgentRef { |
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.
nit: The code should probably go to a dedicated function like validateAutoscaler
or validateRequirements
, the max 100 could also go there.
return nil | ||
} | ||
|
||
func (c *Controller) updateAutoscalerStatus(ctx context.Context, key, ns, name string, err error, podAutoscalerInternal model.PodAutoscalerInternal, podAutoscaler *datadoghq.DatadogPodAutoscaler) error { |
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.
I'd expect the method to highlight that it unlocks store and one line it:
return autoscaling.NoRequeue, c.updateAndUnlock(ctx, key, ns, name, validationErr, podAutoscalerInternal, podAutoscaler)
There's probably a better name to find for it!
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.
👍 for container-platform files
/merge |
🚂 MergeQueue: pull request added to the queue The median merge time in Use |
What does this PR do?
Check that the autoscaling target is not set to the cluster agent. If it is, set an error on the corresponding
DatadogPodAutoscaler
.Motivation
We do not want the cluster agent to be taken down due to autoscaler failures.
Additional Notes
If
CLUSTER_AGENT_DEPLOYMENT
is not set, it defaults to assumingdatadog-agent-cluster-agent
as the deployment name.Do we want to add
CLUSTER_AGENT_DEPLOYMENT
to the agent config rather than reading the environment variable directly?Possible Drawbacks / Trade-offs
Describe how to test/QA your changes
DatadogPodAutoscaler
resource that targets the cluster agent