Skip to content

PS-1583: Replace Alpine-specific shell commands with portable alternatives#811

Merged
zhming0 merged 2 commits into
mainfrom
PS-1583
Jan 28, 2026
Merged

PS-1583: Replace Alpine-specific shell commands with portable alternatives#811
zhming0 merged 2 commits into
mainfrom
PS-1583

Conversation

@zhming0
Copy link
Copy Markdown
Contributor

@zhming0 zhming0 commented Jan 27, 2026

This PR builds on top of the awesome #809(@seemethere). Solve #808.

The goal remain the same:

Use /bin/sh instead of ash and add auto-detection for user/group creation commands to support both Alpine (BusyBox) and glibc-based images (Ubuntu, Debian, Rocky Linux). This enables use of non-Alpine agent images which may be needed for glibc-specific features like TCP-based DNS queries (use-vc resolv.conf option).

I fixed a number of paper cuts issue in #809:

  • improved naming.
  • added an integration test.
  • increase readability on the script constructing code path, unify some duplicated condition.
  • fix the incorrect tinit-static path.

Use /bin/sh instead of ash and add auto-detection for user/group
creation commands to support both Alpine (BusyBox) and glibc-based
images (Ubuntu, Debian, Rocky Linux). This enables use of non-Alpine
agent images which may be needed for glibc-specific features like
TCP-based DNS queries (use-vc resolv.conf option).

Signed-off-by: Eli Uriegas <[email protected]>
Comment thread internal/controller/scheduler/shell.go
)}
createUserScript := generateCreateUserScript(podUser, gid, "buildkite-agent", groupname)
bootstrapCmd := fmt.Sprintf(`su buildkite-agent -c "%s && buildkite-agent-entrypoint kubernetes-bootstrap"`, gitConfigCmd)
checkoutScript := strings.Join([]string{"set -exuf", createUserScript, bootstrapCmd}, "\n")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

worth noting that we're losing -o pipefail here — is that what we want?

Copy link
Copy Markdown
Contributor Author

@zhming0 zhming0 Jan 28, 2026

Choose a reason for hiding this comment

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

Yeah good catch. I tried to get a portable set -o pipefail but failed, because for example in dash, set -o pipefail will end the shell even though I tried to capture it set -o pipefail || true.

I think it's fine. Our own script here don't use pipe syntax. It's arguable though, whether agent should handle the pipefail? But I think it's out of scope.

@zhming0 zhming0 enabled auto-merge January 28, 2026 04:20
@zhming0 zhming0 merged commit 06be5c0 into main Jan 28, 2026
1 check passed
@zhming0 zhming0 deleted the PS-1583 branch January 28, 2026 04:24
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