-
Notifications
You must be signed in to change notification settings - Fork 152
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
Properly support disabling providers and changing init time settings in containers #4145
Comments
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
Would it be possible for us to do this via an environment var instead of mounting a config? |
The most specific change we could make would be to introduce a variable listing the providers to disable, since they are all enabled by default. Something like That would only fix this for providers and wouldn't cover any other cases where we'd want to modify the configuration (the initial logging level for one example). We could do both what is described in this issue and add an environment variable as a convenience. Something like #3609 to only run providers that exist in the policy sounds nice, but integrations that use leader election would then have to support disabling it in the inputs they use. |
The ability to disable providers is important for our team and also another use-case we have is to enable traces |
@cmacknz While this will work for now, I'm not sure it's a sufficient solution in our case. The enabled by default nature of providers could be problematic for agentless. Currently speaking, we don't want/need any provider enabled, and we don't want any future provider to be implicitly enabled. Trying to maintain a comprehensive up to date list of the providers in order to disable them like we do here is less than ideal (funny enough, @olegsu and I just noticed missing the What are your thoughts about a configuration option to change this default behavior of the providers? |
Something like this makes sense to address the maintenance concern you are raising. The solution in #3609 is overall nicer in that it gets rid of enabling and disabling entirely, but it would be significantly more work. |
Taking this into account, #3609 wouldn't work because it wouldn't stop an integration from accidentally enabling a provider by referencing data it populates in the policy. So adding a flag to unconditionally disable providers makes sense to me as the best path forward. |
I made a bit of an assumption that in an agentless deployment we want things like the host provider disabled permanently with no way to turn it on, because it will leak information about the machine hosting the agent. This possibly has security implications, and even if it didn't is leaking implementation details back to the user. |
Recently there have been several situations where users have needed to disable the leader election provider. Providers in agent cannot be configured in Fleet today, but even if they were they require a restart of the agent to take effect, which also isn't supported through Fleet. The providers are initialized when the composable controller is created at startup:
elastic-agent/internal/pkg/composable/controller.go
Lines 52 to 71 in 9d25f79
It is possible to disable providers by editing the elastic-agent.yml file read by the agent container when it starts, which on Kubernetes is most easily accomplished by mounting the file as a ConfigMap. Essentially the process is:
A simplified example follows:
The problem we hit is that we try to unconditionally replace the local agent configuration (in this case a bind mounted ConfigMap) with our default Fleet configuration. This is just an empty configuration that sets
fleet.enabled: true
:We unconditionally try to rotate the file during enrollment, which happens every time the agent container starts when the state path isn't persisted outside of the container file system. This happens in:
elastic-agent/internal/pkg/agent/cmd/enroll_cmd.go
Lines 173 to 178 in 9d25f79
The code path that does this continues with the
SafeFileRotate
rotate call, which is what fails for the bind mounted ConfigMap:elastic-agent/internal/pkg/agent/storage/replace_store.go
Lines 59 to 75 in 9d25f79
What we could do is change this to only attempt to replace the file if it doesn't already contain
fleet.enabled: true
(or any other key that isn't commented out in our default fleet configuration).This would allow overriding the initial contents of the elastic-agent.yml contents in a container in general, regardless of if those settings are available in Fleet.
In the case of providers, even if we did allow disabling leaderelection in the UI it would still be enabled until the agent receives the first policy change from Fleet, so disabling it in the initial configuration like this is likely the preferred route.
The text was updated successfully, but these errors were encountered: