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

kubernetes-exec is now a flag #2814

Merged
merged 2 commits into from
Jun 6, 2024
Merged

kubernetes-exec is now a flag #2814

merged 2 commits into from
Jun 6, 2024

Conversation

DrJosh9000
Copy link
Contributor

Description

Replaces the kubernetes-exec "experiment" with a proper flag, environment variable, etc.

Context

The kubernetes-exec "experiment" was not really an experiment, but rather misused the experiments system as a way to pass a Boolean flag into various parts of the agent without setting up a flag, environment variable, etc.

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 marked this pull request as ready for review June 6, 2024 01:39
@DrJosh9000 DrJosh9000 force-pushed the deexperimentify-k8s branch from 972efcc to e163007 Compare June 6, 2024 01:40
@DrJosh9000 DrJosh9000 force-pushed the deexperimentify-k8s branch from e163007 to 33e5aa2 Compare June 6, 2024 01:41
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.

I have one question. But the rest looks good 👍🏿 .

agent/tags.go Outdated
@@ -78,7 +77,7 @@ type tagFetcher struct {
func (t *tagFetcher) Fetch(ctx context.Context, l logger.Logger, conf FetchTagsConfig) []string {
tags := conf.Tags

if experiments.IsEnabled(ctx, experiments.KubernetesExec) {
if t.k8s != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line right? the t.k8s seems to be set always?

Copy link
Contributor Author

@DrJosh9000 DrJosh9000 Jun 6, 2024

Choose a reason for hiding this comment

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

Good point, on one hand this is defensive in case we set t.k8s optionally, on the other YAGNI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it so that it used the same logic as before (only run t.k8s to create tags if kubernetes-exec is enabled).

@@ -488,6 +494,10 @@ func (r *JobRunner) createEnvironment(ctx context.Context) ([]string, error) {
env["BUILDKITE_STRICT_SINGLE_HOOKS"] = fmt.Sprintf("%t", r.conf.AgentConfiguration.StrictSingleHooks)
env["BUILDKITE_SIGNAL_GRACE_PERIOD_SECONDS"] = fmt.Sprintf("%d", int(r.conf.AgentConfiguration.SignalGracePeriod/time.Second))

if r.conf.KubernetesExec {
env["BUILDKITE_KUBERNETES_EXEC"] = "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be new. Just for my curiosity, what is this impacting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, if kubernetes-exec were enabled (as an experiment), it would be passed down to the subprocess via the BUILDKITE_AGENT_EXPERIMENTS variable. Now it could be set in the parent process via a flag, we should ensure that if enabled it should be passed to the subprocess.

But we'll make the k8s controller set this anyway, so it's probably unnecessary.

Copy link
Contributor

@moskyb moskyb left a comment

Choose a reason for hiding this comment

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

it's so good. it's so so good.

@DrJosh9000 DrJosh9000 merged commit f624a38 into main Jun 6, 2024
1 check passed
@DrJosh9000 DrJosh9000 deleted the deexperimentify-k8s branch June 6, 2024 03:20
@@ -165,6 +165,7 @@ type AgentStartConfig struct {
Experiments []string `cli:"experiment" normalize:"list"`
Profile string `cli:"profile"`
StrictSingleHooks bool `cli:"strict-single-hooks"`
KuberentesExec bool `cli:"kubernetes-exec"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Heads up there's a typo here KuberentesExec

Copy link
Contributor

Choose a reason for hiding this comment

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

lol, whoops. i've just put a PR in to fix it, but there should be no impact

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.

4 participants