Skip to content

fix(csi): propagate mount error in recoverBrokenMount#5753

Open
Sanchit2662 wants to merge 1 commit intofluid-cloudnative:masterfrom
Sanchit2662:fix/csi-recover-broken-mount-error-shadowing
Open

fix(csi): propagate mount error in recoverBrokenMount#5753
Sanchit2662 wants to merge 1 commit intofluid-cloudnative:masterfrom
Sanchit2662:fix/csi-recover-broken-mount-error-shadowing

Conversation

@Sanchit2662
Copy link
Copy Markdown

Ⅰ. Describe what this PR does

so i was digging through the fuse recovery code and found something pretty embarrassing honestly. recoverBrokenMount has a named return err but then inside the function does if err := r.Mount(...) with a short variable declaration. that inner err is a completely new variable scoped to the if block, it never touches the named return. so the function literally always returns nil no matter what.
the caller doRecover checks the return value to decide whether to emit FuseRecoverFailed or FuseRecoverSucceed. since it always gets nil back, it always records FuseRecoverSucceed on the dataset. even when the mount actually failed. so operators see green events while pods are sitting on broken mounts getting I/O errors. not great.

fix is just changing := to = on that one line so the error actually propagates.

Ⅱ. Does this pull request fix one issue?

NONE

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Signed-off-by: Sanchit2662 <sanchit2662@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

@Sanchit2662
Copy link
Copy Markdown
Author

hey @cheyang @TrafalgarZZZ , please review the fix.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a variable shadowing bug in the recoverBrokenMount function by switching from a short variable declaration to a direct assignment for the error variable. Feedback suggests further improving the code by removing named return parameters from the function signature to prevent similar shadowing issues and enhance maintainability.

// Info: Attempting recovery action
glog.V(3).Infof("FuseRecovery: attempting bind mount, source=%s mountPath=%s options=%v", point.SourcePath, point.MountPath, mountOption)
if err := r.Mount(point.SourcePath, point.MountPath, "none", mountOption); err != nil {
if err = r.Mount(point.SourcePath, point.MountPath, "none", mountOption); err != nil {
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.

medium

While this change correctly fixes the shadowing issue by using assignment (=) instead of a short variable declaration (:=), the use of named return parameters (like err in this function signature) is generally discouraged in Go unless they provide significant documentation value. In this case, the named return directly contributed to the bug. For better maintainability and to prevent similar shadowing issues in the future, consider removing the named return parameter from the function signature and using explicit return err or return nil statements.

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot bot commented Apr 3, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign cheyang for approval by writing /assign @cheyang in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot bot commented Apr 3, 2026

Hi @Sanchit2662. Thanks for your PR.

I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant