Skip to content
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

[cmd/builder] Allow configuring confmap providers #9513

Merged
merged 15 commits into from
Apr 22, 2024

Conversation

evan-bradley
Copy link
Contributor

@evan-bradley evan-bradley commented Feb 7, 2024

Description:

Allow configuring confmap providers in the builder's config. If the field isn't set, the default set of providers is used.

Link to tracking Issue:

Resolves #4759.

Testing:

Extended unit tests.

Documentation:

Updated the readme to include the new options in the example manifest file.

cc @mx-psi

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Attention: Patch coverage is 68.29268% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 91.63%. Comparing base (7b046d9) to head (6ef69ce).

Files Patch % Lines
cmd/builder/internal/builder/config.go 75.75% 4 Missing and 4 partials ⚠️
cmd/otelcorecol/main.go 0.00% 4 Missing ⚠️
cmd/builder/internal/command.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9513      +/-   ##
==========================================
- Coverage   91.65%   91.63%   -0.03%     
==========================================
  Files         360      360              
  Lines       16639    16676      +37     
==========================================
+ Hits        15251    15281      +30     
- Misses       1053     1058       +5     
- Partials      335      337       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 39 to 40
Providers *[]Module `mapstructure:"providers"`
Converters *[]Module `mapstructure:"converters"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making these optional introduces a lot of code complexity, but is necessary unless we want to take one of two routes:

  1. Remove the ability for users to specify none of either and check whether the set of modules is empty. In my opinion, we should let users specify they want nothing included in their distribution in case they have unusual requirements.
  2. Remove the set of default converters/providers and require the user to always specify the modules they want included.

I don't necessarily mind option 2, but it would be a fairly significant breaking change and would need a long transition period. If we take option 2, we could move the defaults list to otelcol and just always have the modules baked into every distro until we complete the transition.

Copy link
Member

Choose a reason for hiding this comment

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

An alternative is to have a custom unmarshaling function that differentiates between unset and set but empty. I think this is cleaner and I agree that even if we go with 2 we would want to have a transition period

cmd/builder/internal/builder/templates/main.go.tmpl Outdated Show resolved Hide resolved
@mx-psi
Copy link
Member

mx-psi commented Mar 1, 2024

Both dependencies have been merged, is this ready for review?

@evan-bradley evan-bradley force-pushed the builder-confmap-providers branch 2 times, most recently from ad19f53 to 486d1cd Compare March 4, 2024 03:16
@evan-bradley evan-bradley marked this pull request as ready for review March 4, 2024 03:16
@evan-bradley evan-bradley requested review from a team and mx-psi March 4, 2024 03:16
@evan-bradley evan-bradley force-pushed the builder-confmap-providers branch 4 times, most recently from a30c06d to 9b23b2a Compare March 4, 2024 03:45
@evan-bradley
Copy link
Contributor Author

@mx-psi I think this is ready to go, please take a look.

@evan-bradley evan-bradley changed the title [cmd/builder] Allow configuring confmap converters and providers [cmd/builder] Allow configuring confmap providers Mar 7, 2024
Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

We don't have a clear policy regarding how big the difference in versions between the builder and the API used is, but given the precedent with #8692, I think we should strive to keep some compatibility with older versions of the API, at least for some amount of time. To that end we should guard uses of new modules or new API with a check of the otelcol_version

cmd/builder/internal/builder/templates/main.go.tmpl Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Apr 2, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 2, 2024
@mx-psi mx-psi removed the Stale label Apr 2, 2024
@evan-bradley evan-bradley force-pushed the builder-confmap-providers branch 2 times, most recently from c95cbc6 to c73195e Compare April 8, 2024 14:00
@mx-psi
Copy link
Member

mx-psi commented Apr 16, 2024

Will wait for #9516 before giving another pass to this one

@evan-bradley
Copy link
Contributor Author

Will wait for #9516 before giving another pass to this one

I've also been waiting for that, I will let you know once I update this PR to include those changes.

mx-psi pushed a commit that referenced this pull request Apr 18, 2024
…ings (#9516)

**Description:**

Follows
#9443,
relates to
#9513.

This builds on
#9228 to
demonstrate the concept.

This shows one way of extending the otelcol APIs to allow passing
converters and providers from the builder with the new settings structs
for each type.

I think this approach has a few advantages:
1. This follows our pattern of passing in "factory" functions instead of
instances to the object that actually uses the instances.
2. Makes the API more declarative: the settings specify which modules to
instantiate and which settings to instantiate them with, but don't
require the caller to actually do this.
3. Compared to the current state, this allows us to update the config at
different layers. A distribution's `main.go` file can specify the
providers/converters it wants and leave the settings to be created by
`otelcol.Collector`.

The primary drawbacks I see here are:
1. This is a little more opinionated since you don't have access to the
converter/provider instances or control how they are instantiated. I
think this is acceptable and provides good encapsulation.
2. The scheme->provider map can now only be specified by the providers'
schemes, which is how it is currently done by default. I would want to
hear what use cases we see for more complex control here that
necessitates using schemes not specified by the providers.

cc @mx-psi

---------

Co-authored-by: Evan Bradley <[email protected]>
@evan-bradley
Copy link
Contributor Author

evan-bradley commented Apr 19, 2024

@mx-psi I've updated this to use confmap factories and to account for #9897.

I've updated this to not use the new APIs if the builder is working with versions before v0.99.0. It looks like the new strict versioning functionality will force the builder and core API versions to be equal, according to this line. Should we expect that when the flag to skip strict versioning is removed we can also remove the v0.99.0 version check?

@mx-psi
Copy link
Member

mx-psi commented Apr 19, 2024

@evan-bradley I did not intend for that change to go through just yet, and this is also not documented, so I filed #9999 to document it. We can handle this separately.

IMO we should be a bit more lenient and allow for some version skew between the builder and the Collector being built (at least one minor version of difference should be fine based on our deprecation guidelines, and would be in line with the Kubernetes version skew policy)

@evan-bradley
Copy link
Contributor Author

Thanks for the clarification. I agree we should probably allow some minor skew even if it's a bit inconvenient, it would feel pretty demanding to have to update the builder every single release.

I think this PR should be unaffected by that change and should still be ready to go.

cmd/builder/README.md Outdated Show resolved Hide resolved
.chloggen/builder-confmap-providers.yaml Outdated Show resolved Hide resolved
cmd/builder/internal/builder/main.go Outdated Show resolved Hide resolved
cmd/builder/internal/builder/main_test.go Show resolved Hide resolved
Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Will merge on Monday morning

@MovieStoreGuy block before then if you still have any concerns

cmd/builder/internal/builder/main.go Outdated Show resolved Hide resolved
codeboten added a commit that referenced this pull request Apr 19, 2024
Partially reverts #9897. This was not documented on the original PR and
is IMO too strict.
We likely want to allow for some skew between versions.

Mentioned on
#9513 (comment)

---------

Co-authored-by: Alex Boten <[email protected]>
@mx-psi mx-psi merged commit 256c7c3 into open-telemetry:main Apr 22, 2024
48 of 49 checks passed
@github-actions github-actions bot added this to the next release milestone Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow builder to accept multiple config providers
3 participants