Skip to content

fix(alluxio): skip short lines when parsing the mount table - #6285

Open
bhavishyajain545 wants to merge 1 commit into
fluid-cloudnative:masterfrom
bhavishyajain545:fix/alluxio-mount-output-bounds
Open

bhavishyajain545 wants to merge 1 commit into
fluid-cloudnative:masterfrom
bhavishyajain545:fix/alluxio-mount-output-bounds

Conversation

@bhavishyajain545

Copy link
Copy Markdown

Ⅰ. Describe what this PR does

Follow-up to #6284, as suggested in its review (#6284 (review)).

IsMounted and GetMountedAlluxioPaths read fields[2] of every line of the alluxio fs mount output without checking how many fields the line has. An empty output, or a line with fewer than three fields such as a blank line, makes them panic with index out of range [2]. Both functions now skip those lines.

The output is trimmed in kubeclient.ExecWithOptions, so a normal mount table that ends with a newline does not hit this. It needs an empty output or a short line inside the output.

Ⅱ. 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.

TestAlluxioFileUtils_MountOutputWithShortLines covers, for both functions, an empty output, a blank line between two entries, and a line with fewer than three fields.

Ⅳ. Describe how to verify it

go test -gcflags=all=-l ./pkg/ddc/alluxio/operations/ passes. Without the change to base.go the new test panics at base.go:323 with index out of range [2] with length 0.

Ⅴ. Special notes for reviews

IsMounted and GetMountedAlluxioPaths read the third field of every line
of the 'alluxio fs mount' output without checking that the line has one.
An empty output or a line with fewer than three fields, such as a blank
line, made them panic with an index out of range error.

Skip the lines that have no Alluxio path field.

Signed-off-by: Bhavishya Jain <65864699+bhavishyajain545@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant