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

Allow patching some container commands/args #461

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

DrJosh9000
Copy link
Contributor

@DrJosh9000 DrJosh9000 commented Dec 19, 2024

It came to me last night in a dream... wait, why am I dreaming about work? 🫤

What

Allow patching some container commands and args with PodSpecPatch: sidecars and new containers added by patch are allowed to make any command/args modification, and command container patches are interposed back into BUILDKITE_COMMAND form as we do for non-patch containers.

Why

The command modification check was added to prevent breaking the pod. I wrote an explanation in #449 - if buildkite-agent start isn't run in the agent container, or buildkite-agent bootstrap isn't run in the checkout or command containers, the pod will break in various ways.

However, it was always too strict:

  • sidecar containers never have buildkite-agent added to it, so they should be modifiable
  • new containers added via PodSpecPatch also don't have the command interposition applied, so they should be allowed to have commands

What about command containers? I think if a user tried to override the command/args of a command container, they probably expect the patch to be interpreted the same way as we do currently for command containers specified with podSpec: substitute buildkite-agent bootstrap for the command and interpose the supplied command into BUILDKITE_COMMAND.

Original command containers can be identified by having had this transform already applied, so we just need to match them against the patch by the same process that strategic merge patch uses: container name.

Patching the checkout container is more complicated - it's a container we add rather than one the user supplies anywhere else, with scripts for adjusting user and group IDs, etc. What do we do with a user supplied command? (schlep it into a checkout hook? that could work... 🤔 but what if the user supplied a checkout hook already?)

@DrJosh9000 DrJosh9000 force-pushed the allow-some-command-patching branch 3 times, most recently from e8c4537 to c24a4bf Compare December 19, 2024 00:24
@DrJosh9000 DrJosh9000 force-pushed the allow-some-command-patching branch from c24a4bf to 9d4505e Compare December 19, 2024 00:32
Copy link
Contributor

@wolfeidau wolfeidau left a comment

Choose a reason for hiding this comment

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

Looks good, pretty straight forward 🎉 ☁️ 💤

@DrJosh9000 DrJosh9000 merged commit 8b10034 into main Dec 19, 2024
1 check passed
@DrJosh9000 DrJosh9000 deleted the allow-some-command-patching branch December 19, 2024 00:47
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