Skip to content

fix: run the staged weka CLI in the drivers-builder container - #2790

Merged
graphite-app[bot] merged 1 commit into
mainfrom
09-02-fix_run_the_staged_weka_cli_in_the_drivers-builder_container
Sep 3, 2026
Merged

fix: run the staged weka CLI in the drivers-builder container#2790
graphite-app[bot] merged 1 commit into
mainfrom
09-02-fix_run_the_staged_weka_cli_in_the_drivers-builder_container

Conversation

@rugggger

@rugggger rugggger commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

copy-cli resolved the CLI through PATH, which in the cluster image points
at the release binary rather than the wekactl one, and staging it was
inert anyway: the builder invokes a bare weka, and the operator wrapper
at /usr/local/bin/weka execs /usr/bin/weka, so the staged copy was never
reached. Glob the wekactl binary by arch, make it executable (the source
is 0644), and shadow /usr/bin/weka with a subPath mount so the container
runs it without weka_runtime.py having to name the path.

Fall back to the previous PATH resolution for images with no wekactl-*,
and fail loudly if neither exists.

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

rugggger commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

How to use the Graphite Merge Queue

Add the label main-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown

Claude finished @rugggger's task in 3m 9s —— View job


Code review: run the staged weka CLI in the drivers-builder container

  • Read PR diff against 09-02-fix_stage_the_cluster_image_weka_cli_for_drivers-builder
  • Pull parent PR fix: stage the cluster image weka CLI for drivers-builder #2789 for context (GetBuilderCliImage, cliImage selection)
  • Trace both callers of copyWekaVersionToContainer and the runtime weka invocations
  • Post inline findings
  • Build / tests — not run (go build needs approval in this environment)

The core reasoning checks out. I confirmed the premise from the repo: weka_runtime.py:4366-4378 invokes bare weka version get / weka driver pack in drivers-builder mode, /usr/local/bin/weka is the operator's run-weka-cli.sh configmap mount (resources/pod.go:260-264), and its last line is /usr/bin/weka "$@" — so shadowing /usr/bin/weka is indeed the only way to redirect the builder without touching weka_runtime.py. Mount ordering is fine (/shared-weka-version and /usr/bin/weka don't nest), and the subPath file exists by the time the main container starts since init containers complete first.

Three things worth resolving before merge:

1. The /usr/bin/weka mount also lands on drivers-loader pods (inline) — the significant one. copyWekaVersionToContainer is shared with operations/load_drivers.go:508, where cliImage is the loader image, not the cluster image. The loader's load_drivers() calls bare weka driver download / weka driver install (weka_runtime.py:1631-1638), so a currently-working path silently switches binaries. The glob change compounds it: the loader's copy-weka-version init container at line 147 also now executes wekactl instead of the PATH-resolved binary. Either gate the mount on IsDriversBuilder() or state that the loader change is intended. Fix this →

2. PATH fallback can now form an exec loop (inline) — command -v weka may resolve a wrapper script that itself execs /usr/bin/weka, which this PR now replaces with that very script. Harmless before (the staged copy was only read by an init container), reachable now. Resolving the fallback as readlink -f /usr/bin/weka — the exact path being shadowed — closes it. Suggestion block included inline.

3. The wekactl-*-$ARCH glob is unverifiable from the repo (inline) — wekactl appears nowhere else in the tree. If the arch suffix is amd64 rather than x86_64, or the image arch differs from uname -m, every image silently takes the fallback and the PR is a no-op. A wekactl-* glob with arch used only to disambiguate would be robust to both.

Smaller notes, all optional:

  • chmod 0755 on the copied file is right, and dropping -a from cp is the correct pairing with it.
  • The script uses per-line || exit 1 while the sibling init container (addUIOLoaderInitContainer, line 17) uses set -e. set -eu at the top would be shorter and match the neighbour — the explicit if checks around $CLI stay either way, since they test emptiness rather than exit status.
  • head -1 makes the choice lexicographic if an image ever ships two matching binaries. Fine given the per-image hash, just non-obvious.
  • The two VolumeMounts appends at lines 161 and 167 could be one call.
  • No test covers the new mount. funcs_pod_ensure_test.go:90 already asserts on the copy-cli init container, so asserting Containers[0] has a shared-weka-version mount at /usr/bin/weka with subPath cli/weka would be a couple of lines — and would pin down whichever way finding 1 is resolved.

No security concerns: both images are weka-controlled, the privileged init container already existed, and nothing new is exposed to the host.
· branch 09-02-fix_run_the_staged_weka_cli_in_the_drivers-builder_container

Comment on lines +165 to +171
// the wrapper at /usr/local/bin/weka execs /usr/bin/weka, so shadowing that path makes the
// container use the CLI staged from the cluster image instead of its own older one
pod.Spec.Containers[0].VolumeMounts = append(pod.Spec.Containers[0].VolumeMounts, v1.VolumeMount{
Name: sharedVolumeName,
MountPath: "/usr/bin/weka",
SubPath: "cli/weka",
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Blast radius: this also changes the drivers-loader.

copyWekaVersionToContainer is reached from two places (resources/drivers.go:13):

  • drivers-builder — wekacontainer/funcs_pod_ensure.go:133, where the parent PR now makes cliImage the cluster image. This is the case the description is about.
  • drivers-loader — operations/load_drivers.go:508, where cliImage is the loader/builder image and targetImage is the cluster image.

For the loader, the main container runs DriversLoaderImage (the loader image) and now gets /usr/bin/weka replaced by that same image's wekactl-* binary. load_drivers() in weka_runtime.py:1625-1638 invokes bare weka version get / weka driver download / weka driver install, so a working path is now silently running a different binary than before. Combined with the glob change in copy-cli (which also changes what the loader's copy-weka-version init container executes at line 147), that's two behavior changes to the loader flow in a PR scoped to the builder.

If the intent is builder-only, gate the /usr/bin/weka mount on f.container.IsDriversBuilder(). If it's meant to apply to both, please say so in the description — it's not obvious that wekactl is a drop-in for the release weka in the loader's driver install path.

Comment on lines +106 to +109
if [ -z "$CLI" ]; then
# older images ship only the weka binary, reachable via PATH
CLI=$(readlink -f -- "$(command -v weka)")
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PATH fallback can now produce an exec loop that the old code was immune to.

command -v weka resolves through PATH, and /usr/local/bin/weka typically precedes /usr/bin. In the main container that path is the operator's run-weka-cli.sh wrapper (resources/pod.go:260-264), whose last line is exec-equivalent /usr/bin/weka "$@" (charts/weka-operator/resources/run-weka-cli.sh:31). The init container doesn't get that configmap mount, so this only bites if the image itself ships a /usr/local/bin/weka shell wrapper — but if it does, the fallback stages that script and the new mount below puts it at /usr/bin/weka, i.e. the wrapper now execs itself. Previously the staged copy was only read by copy-weka-version, so the loop couldn't form.

Since the mount target is /usr/bin/weka specifically, resolve the fallback against that exact path rather than PATH:

Suggested change
if [ -z "$CLI" ]; then
# older images ship only the weka binary, reachable via PATH
CLI=$(readlink -f -- "$(command -v weka)")
fi
if [ -z "$CLI" ]; then
# older images ship only the weka binary; resolve the path we shadow, not PATH,
# so a wrapper script can never be staged onto the path it delegates to
CLI=$(readlink -f -- /usr/bin/weka)
fi

Comment on lines +103 to +105
# the wekactl filename carries a per-image hash and the machine arch
ARCH=$(uname -m)
CLI=$(ls -1 /opt/weka/dist/image/wekactl-*-"$ARCH" 2>/dev/null | head -1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two assumptions here that nothing in this repo can verify — wekactl appears nowhere else in the tree, so this glob is the only encoding of the filename convention:

  1. The arch suffix is uname -m form (x86_64/aarch64) rather than Go form (amd64/arm64). If it's the latter the glob never matches and every image silently takes the PATH fallback — i.e. the exact bug this PR fixes, reintroduced without a signal beyond the staged $CLI line in the log.
  2. uname -m reflects the image arch. It reflects the host kernel, so an amd64 image on an arm64 node under emulation reports aarch64 and misses. Niche for this operator, but it's a free win to just glob wekactl-* and only disambiguate by arch if more than one match exists.

Worth a comment naming a concrete example filename so the next reader can check the convention without an image handy.

@rugggger
rugggger force-pushed the 09-02-fix_run_the_staged_weka_cli_in_the_drivers-builder_container branch from 679e69e to f40c1f2 Compare September 2, 2026 11:25
@rugggger
rugggger force-pushed the 09-02-fix_stage_the_cluster_image_weka_cli_for_drivers-builder branch from f4ae7fe to 7f22ad8 Compare September 2, 2026 11:25
copy-cli resolved the CLI through PATH, which in the cluster image points
at the release binary rather than the wekactl one, and staging it was
inert anyway: the builder invokes a bare `weka`, and the operator wrapper
at /usr/local/bin/weka execs /usr/bin/weka, so the staged copy was never
reached. Glob the wekactl binary by arch, make it executable (the source
is 0644), and shadow /usr/bin/weka with a subPath mount so the container
runs it without weka_runtime.py having to name the path.

Fall back to the previous PATH resolution for images with no wekactl-*,
and fail loudly if neither exists.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@rugggger
rugggger force-pushed the 09-02-fix_stage_the_cluster_image_weka_cli_for_drivers-builder branch from 7f22ad8 to f6d58f8 Compare September 2, 2026 11:47
@rugggger
rugggger force-pushed the 09-02-fix_run_the_staged_weka_cli_in_the_drivers-builder_container branch from f40c1f2 to ded1b12 Compare September 2, 2026 11:47
@rugggger
rugggger marked this pull request as ready for review September 2, 2026 14:31
@rugggger
rugggger requested a review from a team as a code owner September 2, 2026 14:31
@graphite-app

graphite-app Bot commented Sep 2, 2026

Copy link
Copy Markdown

Graphite Automations

"Add anton/matt/sergey/kristina as reviwers on operator PRs" took an action on this PR • (09/02/26)

3 reviewers were added to this PR based on Anton Bykov's automation.

@graphite-app

graphite-app Bot commented Sep 3, 2026

Copy link
Copy Markdown

Merge activity

  • Sep 3, 10:50 AM UTC: rugggger added this pull request to the Graphite merge queue.
  • Sep 3, 10:51 AM UTC: CI is running for this pull request on a draft pull request (#2793) due to your merge queue CI optimization settings.
  • Sep 3, 11:22 AM UTC: The Graphite merge queue removed this pull request due to downstack failures on PR #2788.
  • Sep 3, 11:22 AM UTC: The Graphite merge queue removed this pull request due to downstack failures on PR #2788.
  • Sep 3, 3:15 PM UTC: rugggger added this pull request to the Graphite merge queue.
  • Sep 3, 3:15 PM UTC: CI is running for this pull request on a draft pull request (#2795) due to your merge queue CI optimization settings.
  • Sep 3, 4:11 PM UTC: Merged by the Graphite merge queue via draft PR: #2795.

@graphite-app graphite-app Bot closed this Sep 3, 2026
Base automatically changed from 09-02-fix_stage_the_cluster_image_weka_cli_for_drivers-builder to main September 3, 2026 16:11
@graphite-app
graphite-app Bot merged commit ded1b12 into main Sep 3, 2026
93 of 113 checks passed
@graphite-app
graphite-app Bot deleted the 09-02-fix_run_the_staged_weka_cli_in_the_drivers-builder_container branch September 3, 2026 16:11
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