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

Don't try to early-set env vars #2852

Merged
merged 1 commit into from
Jun 27, 2024
Merged

Conversation

DrJosh9000
Copy link
Contributor

Description

After some testing, I discovered that the env vars can't be set early enough to affect the bootstrap config, so this moves back to doing most of the socket setup in executor.go

Changes

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go fmt ./...)

@DrJosh9000 DrJosh9000 requested a review from zhming0 June 27, 2024 00:47
After some testing, I discovered that the env vars can't be set early enough to affect the bootstrap config
Copy link
Contributor

@zhming0 zhming0 left a comment

Choose a reason for hiding this comment

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

The change looks good. Hopefully the comprehensive code comment can help future traveller to understand 🤞🏿 .

Comment on lines +1219 to +1222
// To think about: how to obtain the env vars early enough to set
// them in ExecutorConfig (because of how urfave/cli works, it
// must happen before App.Run, which is before the program even knows
// which subcommand is running).
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for my knowledges, what environment variables were we trying to set "early"?

For our original goal of BUILDKITE_AGEND_ID, does this setup work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anything that normally configures the bootstrap subcommand, but especially the required flags/vars: BUILDKITE_JOB_ID, BUILDKITE_REPO, etc. I would have expected the command container to use these without having to set the env vars for them at schedule time. But that didn't work.

For the original goal of agent env vars that aren't known when the pod is scheduled, yes, this should still work. Commands, plugins etc would be run with the e.shell.Env, but for completeness this PR still inserts them into the current process env (os.Setenv).

@DrJosh9000 DrJosh9000 merged commit f4b9942 into main Jun 27, 2024
1 check passed
@DrJosh9000 DrJosh9000 deleted the ps-72-k8s-env-var-conveyor branch June 27, 2024 01: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.

2 participants