Skip to content

fix(juicefs): parse mount options after the standalone -o argument - #6283

Open
BahaaMattar wants to merge 1 commit into
fluid-cloudnative:masterfrom
BahaaMattar:fix-juicefs-command-option-diff
Open

BahaaMattar wants to merge 1 commit into
fluid-cloudnative:masterfrom
BahaaMattar:fix-juicefs-command-option-diff

Conversation

@BahaaMattar

Copy link
Copy Markdown

Ⅰ. Describe what this PR does

JuiceFSEngine.isCommandChanged compares the mount options of the running fuse/worker command with the freshly generated one, so that an edited JuiceFSRuntime (for example a new cache-size) updates the mount script ConfigMap and the worker StatefulSet template.

To get the options it split the command on the bare substring -o and read the second piece. The generated command is exec /bin/mount.juicefs <source> <mountPath> -o <options>, and <mountPath> contains the dataset name, so a dataset such as demo-output splits the command in the wrong place. Option names such as cache-partial-only contain -o too. In those cases the second piece is not the option list, the old and new options look identical and the change is never detected.

This PR cuts the command at the -o argument (with the surrounding spaces) and reads everything after it as the option list. The rest of the comparison is unchanged.

Ⅱ. Does this pull request fix one issue?

Fixes #6282

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

Three cases added to TestJuiceFSEngine_isCommandChanged in pkg/ddc/juicefs/sync_runtime_test.go:

  • test-true-dataset-name-contains-dash-o: dataset demo-output, only cache-size differs, expects "changed".
  • test-false-dataset-name-contains-dash-o: same dataset, same options in a different order, expects "not changed".
  • test-true-option-name-contains-dash-o: option cache-partial-only, only cache-size differs, expects "changed".

The two "changed" cases fail on master and pass with this change. The "not changed" case passes on both and guards against over-reporting.

Ⅳ. Describe how to verify it

go test -p 2 -gcflags=all=-l ./pkg/ddc/juicefs/ -run TestJuiceFSEngine_isCommandChanged -v

Ⅴ. Special notes for reviews

Only the way the option string is located changes; how each option is split into key and value, and the ignoring of the metrics option, are untouched. A command that has no -o still yields an empty option set, as before.

isCommandChanged compared the mount options of the current and the new
fuse/worker command by splitting the command on the substring "-o" and
reading the second piece. The substring also appears in the mount path
(which contains the dataset name, e.g. demo-output) and in option names
such as cache-partial-only, so the second piece was not the option list
and a changed option (e.g. cache-size) was never detected: the
configmap holding the mount script was left stale.

Cut the command at the " -o " argument instead and read everything after
it as the option list.

Signed-off-by: Bahaa Mattar <bahaa.kmattar@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues are reported for the JuiceFS mount-option change-detection fix.

No open issues 🎉

What changed in this PR

Fixes JuiceFS mount-option change detection for dataset and option names containing -o, addressing #6282 so runtime option edits can update mount scripts and worker templates.

Changes:

  • Extracts options after the space-delimited -o argument instead of splitting on every -o substring.
  • Adds three regression cases covering affected dataset names, reordered options, and option names containing -o.
  • Preserves the existing option comparison and metrics-ignore behavior.
File Description
pkg/​ddc/​juicefs/​sync_runtime.go Locates mount options using the standalone -o delimiter.
pkg/​ddc/​juicefs/​sync_runtime_test.go Adds regression coverage for embedded -o and order-independent comparison.

Review effort: Balanced

@cheyang cheyang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Both reviewers independently reproduced issue #6282 on the merge base — with dataset demo-output or option cache-partial-only, a cache-size change yields isCommandChanged=false, so the script ConfigMap and the worker restart annotation are never updated — and both verified the fix through the real genFuseMount/genWorkerMount generators (CE and EE, fuse and worker), not hand-written strings. The " -o " cut is correct for every command the generators can emit: everything before the standalone separator is space-free, so the first occurrence is always the real one; the comparison stays order-insensitive (checked against 20 random map-iteration orders), metrics is still ignored, option removal is detected, and a controller-level test confirms the ConfigMap is rewritten and the restart annotation set. Full ./pkg/ddc/juicefs/... suite is green on the head, and there is no migration concern — the stored command format is unchanged, so the first post-upgrade reconcile compares like with like.

No blockers. The one meaningful disagreement in the debate: Claude's claim that the syncWorkerSpec command-sync lifecycle has zero test coverage was rebutted by Codex with the existing Ginkgo only command changed spec (which pins exactly the ConfigMap rewrite + restart annotation, green on base and head); only a narrow residue survives. Copilot (Reviewer C) reviewed this head and raised no findings — no third-opinion flags either way.

Next round

[MUST] (none — merge is not gated on any finding)
[SHOULD] Consider uplifting a generator round-trip test and a dash--o variant of the syncWorkerSpec lifecycle spec (templates on both verification branches); optionally switch the metrics exclusion to a parsed-key comparison (pre-existing, latent) and confirm source/mountPath-only changes are intentionally handled elsewhere (pre-existing question).
[Filed] none

Non-blocking observations (4) — not part of this round's ask; fix now, follow up, or file an issue as you see fit
  • pkg/ddc/juicefs/sync_runtime.go:616 [minor] — pre-existing, not introduced by this PR — metrics exclusion matches by substring, not by option key (pre-existing)
    F-metrics-substring-filter (consensus, pre-existing): strings.Contains(option, "metrics") skips any option whose key=value text merely contains the substring metrics, not just the metrics option itself — the same failure class this PR fixes. Latent today (no colliding option in use); worth a small follow-up comparing the parsed key (k == "metrics") instead of the raw substring. Not introduced by this PR; does not block it.
  • pkg/ddc/juicefs/sync_runtime.go:604 [minor] — pre-existing, not introduced by this PR — Comparison covers only the option list; source/mountPath-only changes are not detected (pre-existing question)
    F-options-only-comparison (pre-existing question): the comparison covers only the option list, so a changed source or mountPath alone produces no script update. Since both derive from the runtime's immutable namespace/name identity, realistic exposure is near-nil — could a maintainer confirm source changes are intentionally handled by another sync path?
  • pkg/ddc/juicefs/sync_runtime_test.go:1269 [minor] — New isCommandChanged tests hardcode command strings; a generator round-trip (and a dash-o lifecycle case) would guard against format drift
    F-generator-roundtrip-tests (consensus, PR-introduced, non-blocking): the three new test cases hardcode the command line. If genFuseMount/genWorkerMount ever change shape (options relocated, a second -o flag, config-file-based options), these tests keep passing while comparison silently breaks again. A round-trip through the real generators for a dash--o dataset — plus a dash--o variant of the syncWorkerSpec lifecycle spec — would pin the contract end to end; both patterns are demonstrated on the verification branches (verify/pr6283-juicefs-cmd-options-claude, verify/juicefs-iscommandchanged-dash-o-codex). Suggestion only.
  • pkg/ddc/juicefs/sync_runtime.go:607 [nit] — Token-based -o lookup would tolerate future spacing changes (optional hardening)
    F-token-parse-hardening (nit, PR-introduced, optional): splitting the command into whitespace fields and locating the exact -o token would make the parser immune to a future generator change that varies spacing. Correctly proven unnecessary for anything the current code emits; optional hardening only.
Verified review delta
  • F-metrics-substring-filter: open (preexisting)
  • F-options-only-comparison: open (preexisting)
  • F1-syncworker-lifecycle-coverage: refuted (preexisting)
  • F-generator-roundtrip-tests: open (initial-pr)
  • F-token-parse-hardening: open (initial-pr)

Code: clear. CI: success; attribution: unknown. Required CI checks still apply.

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.

[BUG] JuiceFSRuntime: changed mount options are ignored when the dataset name or an option name contains "-o"

3 participants