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

work around otel reading envvars #181 #208

Merged
merged 3 commits into from
May 22, 2023
Merged

Conversation

tobert
Copy link
Collaborator

@tobert tobert commented May 22, 2023

I thought this was going to be more complex but thought of a simpler solution that is completely obvious in retrospect. This PR backs up the env at config time, then modifies exec and status to use that backup. This solves the problem.

Amy Tobey added 3 commits May 22, 2023 16:14
We have to delete envvars during configuration that might also be read
by the OTel collector client. Also, users of otel-cli exec expect
envvars including OTEL stuff to pass through  so they don't have to do
weird backflips to configure embedded exec usage, which is one of the
earliest documented features of otel-cli.

To accomplish this, refactored the PersistentPreRun func to be a full
func instead of inline. Modified it to inject os.Environ() into the
private config field before calling the envvar config func.
When I rewrote the envvar handling for otel-cli and removed Viper, one
of the problems I tried to solve was envvars being read by both otel-cli
and the otel collector backend it uses. Otel-cli allows some things that
the collector doesn't, and besides, otel-cli can't make any guarantees
for code paths that it doesn't test. So, envvars have to be deleted from
the os environment to prevent that, but we still need to pass the
original env through.

The easy path forward is to back up the env early at startup, which
happens now, and then have exec and status use that backup instead of
os.Environ(). This commit implements that.

status was updated to also pass through so it's easier to test.

Added a test for pass-through, as well as updated tests that use
`status` so they now expect envvars to pass through again.
@tobert tobert merged commit fcc3825 into main May 22, 2023
@tobert tobert deleted the workaround-otel-reading-envvars branch May 22, 2023 20:37
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.

1 participant