-
Notifications
You must be signed in to change notification settings - Fork 116
Add DD_AGENT_IPC_* env vars #1604
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,6 +209,25 @@ func (o *otelCollectorFeature) ManageNodeAgent(managers feature.PodTemplateManag | |
managers.Port().AddPortToContainer(apicommon.OtelAgent, port) | ||
} | ||
|
||
// (todo: mackjmr): remove this once IPC port is enabled by default. Enabling this port is required to fetch the API key from | ||
// core agent when secrets backend is used. | ||
agentIpcPortEnvVar := &corev1.EnvVar{ | ||
Name: v2alpha1.DDAgentIpcPort, | ||
Value: "5009", | ||
} | ||
agentIpcConfigRefreshIntervalEnvVar := &corev1.EnvVar{ | ||
Name: v2alpha1.DDAgentIpcConfigRefreshInterval, | ||
Value: "60", | ||
} | ||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. Don't we want to add the two env vars if There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. ah, that's right. Thanks for clarifying. |
||
} | ||
for _, container := range []apicommon.AgentContainerName{apicommon.CoreAgentContainerName, apicommon.OtelAgent} { | ||
managers.EnvVar().AddEnvVarToContainerWithMergeFunc(container, agentIpcPortEnvVar, mergeFunc) | ||
managers.EnvVar().AddEnvVarToContainerWithMergeFunc(container, agentIpcConfigRefreshIntervalEnvVar, mergeFunc) | ||
} | ||
|
||
var enableEnvVar *corev1.EnvVar | ||
if o.coreAgentConfig.enabled != nil { | ||
if *o.coreAgentConfig.enabled { | ||
|
@@ -238,6 +257,7 @@ func (o *otelCollectorFeature) ManageNodeAgent(managers feature.PodTemplateManag | |
Value: *o.coreAgentConfig.extension_url, | ||
}) | ||
} | ||
|
||
return 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.
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.
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 toglobal
handled indatadog-operator/internal/controller/datadogagent/override/global.go
Lines 145 to 149 in 0269ee1
controlelr_v2_test.go
could be used for this if you want to test outcome of whole reconcile.