-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add DD_AGENT_IPC_* env vars #1604
Conversation
This PR adds DD_AGENT_IPC_PORT and DD_AGENT_IPC_CONFIG_REFRESH_INTERVAL env vars in otel agent and core agent. It does not override them if they are added by the user. THis is necessary for the otel-agent to pull the api key from core config in the case where backend secrets are used.
Value: "60", | ||
} | ||
// don't set env var if it was already set by user. | ||
mergeFunc := func(current, newEnv *corev1.EnvVar) (*corev1.EnvVar, 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 don't think this can be tested by the current test framework, as the env vars added via WithEnvVars
helper don't make it into container env vars.
e.g.
{
Name: "otel agent user provided ipc port",
DDA: testutils.NewDatadogAgentBuilder().
WithOTelCollectorEnabled(true).
WithEnvVars([]corev1.EnvVar{
{
Name: v2alpha1.DDAgentIpcPort,
Value: "3333",
},
}).
Build(),
WantConfigure: true,
WantDependenciesFunc: testExpectedDepsCreatedCM,
Agent: testExpectedAgent(apicommon.OtelAgent, defaultExpectedPorts, defaultLocalObjectReferenceName,
expectedEnvVars{
agent_ipc_port: expectedEnvVar{
present: true,
value: "3333",
},
agent_ipc_refresh: expectedEnvVar{
present: true,
value: "60",
},
},
),
},
will fail.
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.
WithEnvVars
adds env variables to global
handled in
datadog-operator/internal/controller/datadogagent/override/global.go
Lines 145 to 149 in 0269ee1
if config.Env != nil { | |
for _, envVar := range config.Env { | |
manager.EnvVar().AddEnvVar(&envVar) | |
} | |
} |
controlelr_v2_test.go
could be used for this if you want to test outcome of whole reconcile.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1604 +/- ##
==========================================
+ Coverage 49.26% 49.29% +0.02%
==========================================
Files 218 218
Lines 21073 21089 +16
==========================================
+ Hits 10382 10395 +13
- Misses 10150 10152 +2
- Partials 541 542 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
} | ||
// don't set env var if it was already set by user. | ||
mergeFunc := func(current, newEnv *corev1.EnvVar) (*corev1.EnvVar, error) { | ||
return current, nil |
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.
Don't we want to add the two env vars if current
doesn't contain them?
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.
My understanding based on code is that the mergeFunc is only run if the container already contains the env var we are trying to add. In which case, I want to prioritize the one already set, which is why I return current.
If the env var is not present in the container, then the merge func is not run, and the env vars are added.
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, that's right. Thanks for clarifying.
What does this PR do?
This PR adds DD_AGENT_IPC_PORT and DD_AGENT_IPC_CONFIG_REFRESH_INTERVAL env vars in otel agent and core agent. It does not override them if they are added by the user. This is necessary for the otel-agent to pull the api key from core config in the case where backend secrets are used.
Motivation
OTEL-2323
Additional Notes
I have an open question about test, see PR comment.
Minimum Agent Versions
Are there minimum versions of the Datadog Agent and/or Cluster Agent required?
Describe your test plan
Run the otel-agent without API Key in otel collector config, and by providing api key in core agent via backend secret.
Setup 1:
operator config:
Validate config can be fetched by the otel agent by checking otel-agent logs contain:
Setup 2:
Same as above but user provided env vars, make sure these are not overriden.
Operator config:
Validate config can be fetched by the otel agent by checking otel-agent logs contain:
Checklist
bug
,enhancement
,refactoring
,documentation
,tooling
, and/ordependencies
qa/skip-qa
label