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

Handle backwards compatibility of internal ballast removal #759

Merged
merged 4 commits into from
Sep 22, 2021
Merged

Conversation

pmcollins
Copy link
Contributor

This change adds a ballastParserProvider which wraps a
ConfigSourceParserProvider and adds a memory_ballast extension to the
Otel config if one isn't already present. Doing so ensures that users
have memory ballast regardless of whether they explicitly added the
newly-developed memory_ballast extension, which may not have existed
when they set up their collector.

This change adds a `ballastParserProvider` which wraps a
`ConfigSourceParserProvider` and adds a `memory_ballast` extension to the
Otel config if one isn't already present. Doing so ensures that users
have memory ballast regardless of whether they explicitly added the
newly-developed `memory_ballast` extension, which may not have existed
when they set up their collector.
@emaderer
Copy link
Contributor

I think that the main issue to address is what happens if the deprecated ballast field will get removed from the memory limiter processor
Collectors with old config files will fail to start in that case.
I am not sure if we want to add the memory_ballast extension even if it's not present, maybe just in cases where it's not present but the memory limiter processor contains ballast_size_mib

@pmcollins
Copy link
Contributor Author

I think that the main issue to address is what happens if the deprecated ballast field will get removed from the memory limiter processor
Collectors with old config files will fail to start in that case.
I am not sure if we want to add the memory_ballast extension even if it's not present, maybe just in cases where it's not present but the memory limiter processor contains ballast_size_mib

So, to my knowledge, the ballast field in the memory limiter processor never actually allocated a ballast. The memory limiter just used the ballast size (set manually) by subtracting it from the reported memory usage so the ballast wouldn't be counted when it calculated how much memory was being used. The ballast was actually allocated in the core of the collector (collector.go -- and it no longer is).

The Splunk Otel Collector at this point just sets the environment variable SPLUNK_BALLAST_SIZE_MIB either based on the --mem-ballast-size-mib command line arg or based on a calculation, and provides default configs that use this environment variable to set up a collector with a memory_ballast extension. This works fine for new installs, but previous installs of older versions of the collector, where the config has been modified (and possibly in other cases as well), won't get the new config and therefore after upgrading will no longer have a memory ballast allocated. That was my understanding of this issue (from Jay's comment).

My thought was that the memory limiter processor ballast field going away is an issue, but it's perhaps a separate one. In any case, it could be handled in this PR since we're updating the collector config anyway -- we could just delete that key if we find it.

Anyway, having said all that 😄 I'm happy to remove this PR's ballast extension addition code, and just remove the memory limiter ballast key (if you think that's the best way to handle its upcoming removal).

And I realize that enhancing a Collector config maybe feels a bit odd at this point, but my personal opinion is that in the long term we may want to take this route to make setup easier for users. I am interested in what other folks think about this as well.

@pmcollins
Copy link
Contributor Author

Here's another option @emaderer -- I just pushed the change. This one just removes the ballast key from the memory limiter processor, if one exists, and doesn't add a ballast extension. Alternatively we could do both 😄 .

Also remove adding ballast extension from the PR.
@emaderer
Copy link
Contributor

Here's another option @emaderer -- I just pushed the change. This one just removes the ballast key from the memory limiter processor, if one exists, and doesn't add a ballast extension. Alternatively we could do both 😄 .

Can we take the approach of - if the ballast key exists in the memory limiter processor remove it and make sure we enable the ballast extension with the same value, otherwise there is no need to do anything?

@pmcollins
Copy link
Contributor Author

Ok, discussed separately with Eyal, and we're going to just remove the ballast key if it exists in the memory limiter processor, which is what this PR does in its current form. I've tested these changes against a local copy of the core collector, removed the ballast field and saw that the collector started up (verified that it didn't without these changes).

@pmcollins pmcollins marked this pull request as ready for review September 21, 2021 17:00
@pmcollins pmcollins requested review from a team as code owners September 21, 2021 17:00
@pmcollins pmcollins marked this pull request as draft September 21, 2021 17:44
// converterProvider wraps a ParserProvider and accepts a list of functions that
// convert ConfigMaps. The idea is for this type to conform to the open-closed
// principle.
type converterProvider struct {
Copy link
Contributor Author

@pmcollins pmcollins Sep 22, 2021

Choose a reason for hiding this comment

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

We may want to make use of open-telemetry/opentelemetry-collector#4078 when it's ready.

@emaderer
Copy link
Contributor

This looks great now I think! can we add a kill switch to disable any kind of config conversion just in case?


var ballastKeyRegexp *regexp.Regexp

func init() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If RemoveBallastKey is only called once is there a benefit to doing this in an init if there's only one consumer of ballastKeyRegexp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there's no benefit. I'll move it to the function. (I hate init()s anyway 😛)

@pmcollins
Copy link
Contributor Author

This looks great now I think! can we add a kill switch to disable any kind of config conversion just in case?

Thanks -- yes sure. Should it be a command line switch?

@emaderer
Copy link
Contributor

This looks great now I think! can we add a kill switch to disable any kind of config conversion just in case?

Thanks -- yes sure. Should it be a command line switch?

command line switch sounds good.

@pmcollins pmcollins marked this pull request as ready for review September 22, 2021 19:21
@pmcollins pmcollins merged commit 938df81 into main Sep 22, 2021
@pmcollins pmcollins deleted the ballast branch September 22, 2021 19:36
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.

3 participants