Skip to content

Create tool or subcommand that allows migrating configuration #7631

Open
@mx-psi

Description

Is your feature request related to a problem? Please describe.

Changes in recommended configuration happen frequently in the Collector, including both Collector-wide changes (e.g. see #7111 which is the main motivation for this) and in individual components (e.g. most recently see open-telemetry/opentelemetry-collector-contrib/issues/18642, see also #6334 for a change that probably affected many configurations). They are a normal part of component stabilization and will continue happening across the Collector.

Currently, we rely on warnings, updated examples and documentation to reflect our recommendation and expect users to check these and then upgrade their configuration manually. Our current approach probably means that only a small number of users migrate to the new configuration, and this makes it hard for us to drop old syntax/configuration flags without hurting many users. It also makes it hard to come to a consensus in issues like #5686.

Describe the solution you'd like

Add a subcommand that automates as much as possible of any given configuration migration. Ideally, the user passes the configuration in the same way they would do it for a normal Collector run and the Collector then prints out the updated configuration as well as a list of the changes that were made and their rationale.

Describe alternatives you've considered

An alternative is to provide a separate tool for this. This would work for the ${...} -> ${env:..} migration, but would make it hard for components to introduce custom migration rules.

Additional context

Note: This section lists some requirements of a fully working solution. While we should consider all of these when designing a first solution, we don't have to support all of them, and an MVP should leave things like custom component migration out of scope for now.

Some requirements

The solution should:

  1. Allow adding support for components providing custom migration rules (similar to what we do for unmarshaling and validation). We should take this into account in the design phase but leave implementation explicitly out of the first version of this subcommand.
  2. Work at the confmap level, at least for the ${..} to ${env:...} migration. It probably is useful also for components to work at the confmap level.
  3. Provide output that is as close as possible to the way the user provided the configuration. With the current implementation it's hard to map back a given configuration to the individual files/environment variables/other sources where it comes from, so doing this 'the right way' means adding some sort of metadata to confmap.Conf noting the source of each configuration section/scalar value.

Open questions

  1. How should we provide the output? If configuration comes from multiple sources, should we map back to these sources? How do we do this given merging happens very early? We can't modify user input in some cases (protected files, env variables, URLs), so should we just print things out to stdout?
  2. Should components be able to recommend configuration changes outside of their configuration section? This could be useful for situations like [Proposal] Move batching to exporterhelper #4646, where we want to move configuration from one component to another.
  3. For some configuration changes, we may not be able to fully automate the process no matter how clever we are (e.g. if we drop some functionality because it is moved to the SDKs). What should we do in these cases? Should we have support for warnings/lints? This functionality would also be useful for Log a warning when an environment variable without a value is expanded #5615.

Some follow up tasks once we have this

  • Add this to our CI to run on examples for dogfooding
  • Add warnings in logs to nudge users to migrate to the new configuration (e.g. by doing a dry-run and checking if there are changes reported)

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions