Skip to content

[cmd/opampsupervisor] Make configuration merge more customizable through special config files #40295

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

douglascamata
Copy link
Member

@douglascamata douglascamata commented May 26, 2025

Description

This PR refactors the logic of the configuration loading and merging in the cmd/opampsupervisor package to allow for more customization, control and to have a more explicit ordering for users.

Link to tracking issue

Fixes #39963.

Testing

Did some manual testing and ensured our current tests pass.

Documentation

  • Put very good notes on the changelog.
  • Update the specification docs.

@atoulme
Copy link
Contributor

atoulme commented May 29, 2025

Any chance to avoid the term magic? Would you please describe the intent, it looks like you have enough design going on a small RFC would help.

@douglascamata
Copy link
Member Author

Any chance to avoid the term magic?

The only other term that comes to my head and doesn't create even more confusion would be "special", which we could also use. Do you have any other suggestions, @atoulme?

Would you please describe the intent, it looks like you have enough design going on a small RFC would help.

We already have the initial intent in #39963, which was to be able to have local config files added into the configuration stack at the lowest priority level. The idea for the technical approach comes from a suggestion in the same issue.

If really necessary for this I can try to write an RFC. @evan-bradley, by chance do you already have something written somewhere about those future plans for writing all configs to disk and letting the Collector itself merge them all?

the configuration files specified are applied after the configuration from the OpAMP server.
After the configuration files, arguments present in `.agent.args` are passed to the executable binary.
The environmanet variables specified in `.agent.env` are set in the collector process environment.
There are a few "magic" configuration files that can be used to completely
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote we do not refer to these as magic configuration files. Something like reserved or key or global, variable or special as it feels more professional. I dont want users to think using these variables are something to be avoided.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update this to call them "special" for now. 👍

Comment on lines 273 to 280
- If the `$OPAMP_EXTENSION_CONFIG` is not specified, the Collector
will not be able to connect to the Supervisor, triggering a restart loop.
- If the `$OWN_METRICS_CONFIG` is not specified, the Collector will not be able
to report its own metrics.
- If the `$BUILTIN_CONFIG` is not specified, the Collector will not have the
expected identifying, non-identifying and resource attributes.
- If the `$REMOTE_CONFIG` is not specified, the Collector will not be able to
apply the remote configuration received from the Supervisor.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to provide validation against the merged config that the things we expect to be present are present? I feel like we are opening up ourselves to a lot of troubleshooting issues from users holding this feature incorrectly

Copy link
Member Author

@douglascamata douglascamata May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TylerHelmuth I thought about this a bit. One way we could avoid this problem is to automatically prepend any non-specified special file, so this way what we expect to be there will be there unless modified by later/higher-level configurations at the expense of having a bit of "hidden" behavior. I think this can be a good tradeoff. WDYT?

Copy link
Member

@TylerHelmuth TylerHelmuth May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya always prepending any of our special configurations if it is not specified in the list by the user feels like a safer default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay taking this on a case-by-case basis: for example, I'm not as worried about the own metrics config as the other ones.

However in general I think we should enable default anything that would cause the Supervisor to break in most cases (removing the OpAMP extension config) or introduce unclear behavior (the remote configuration capability is enabled, but the remote config merge order isn't set, so don't use remote config). For now I would be okay just always including all of the special configurations.

Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @douglascamata. I've only looked at the specification so far since I want to get that right before focusing on the implementation.

- `$BUILTIN_CONFIG`: built-in base configuration.
- `$REMOTE_CONFIG`: remote configuration received by the Supervisor.

If **none** of these are explicitly specified, they are automatically prepended to the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a breaking change for the current behavior, but I would vote for having these appended to the list if they're unspecified:

  1. The OpAMP extension configuration added by the Supervisor is essential for the Supervisor to work and disabling it should be something users have to explicitly opt into by putting the extension config before their custom config.
  2. Ultimately, remote configuration is the "most specific" configuration, since it's been deliberately sent to a Collector by an operator. I think we should always respect this configuration unless the Collector has been specifically set up to override values that may be present in the remote configuration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, @evan-bradley. I think it's fine for us to have this breaking change now, as the component is in a very early stage (alpha/dev) and we need a strong/solid base for the future.

@douglascamata
Copy link
Member Author

Hey folks, I updated the PR with your feedback.

The "magic" config files were renamed to "special".

The behavior now when any special config file is not present is to modify the config file list to achieve the following order:

  • $OWN_METRICS_CONFIG
  • $BUILTIN_CONFIG
  • <USER_PROVIDED_CONFIG_FILES>
  • $OPAMP_EXTENSION_CONFIG
  • $REMOTE_CONFIG

@douglascamata douglascamata changed the title [cmd/opampsupervisor] Make configuration merge more customizable through magic config files [cmd/opampsupervisor] Make configuration merge more customizable through special config files Jun 2, 2025
@douglascamata
Copy link
Member Author

ping @evan-bradley @TylerHelmuth @atoulme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[cmd/opampsupervisor] Add support for "base layer" local config for the Collector
4 participants