Skip to content

Extract file open mode from OpenFileOp #3259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

anushka567
Copy link
Member

@anushka567 anushka567 commented Apr 30, 2025

Description

This PR introduces the method for determining the access mode for the file being opened. This was necessary to support appends to existing files by extending the streaming writes support for files opened via a/a+ mode.

Note: Required changes merged. Blocked on this PR in jacobsa/fuse

Link to the issue in case of a bug fix.

b/414135351

Testing details

  1. Manual - Manually tested the flows. No breakage.
  2. Unit tests - NA
  3. Integration tests - NA

Any backward incompatible change? If so, please explain.

@anushka567 anushka567 added the execute-integration-tests Run only integration tests label Apr 30, 2025
@kislaykishore kislaykishore requested review from a team and abhishek10004 and removed request for a team April 30, 2025 08:56
@anushka567 anushka567 force-pushed the file-open-method branch 2 times, most recently from 94c1fa1 to 2c2f09f Compare May 5, 2025 08:09
Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.84%. Comparing base (6ff9f5f) to head (8e7ff58).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3259      +/-   ##
==========================================
+ Coverage   78.60%   78.84%   +0.23%     
==========================================
  Files         128      130       +2     
  Lines       17657    17781     +124     
==========================================
+ Hits        13880    14019     +139     
+ Misses       3317     3296      -21     
- Partials      460      466       +6     
Flag Coverage Δ
unittests 78.84% <100.00%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anushka567 anushka567 changed the title [Do not review] Extract file open mode from OpenFileOp Extract file open mode from OpenFileOp May 6, 2025
@anushka567 anushka567 marked this pull request as ready for review May 6, 2025 10:17
@anushka567 anushka567 requested a review from a team as a code owner May 6, 2025 10:17
switch {
case op.OpenFlags.IsAppend():
return Append
case op.OpenFlags.IsWriteOnly():
Copy link
Collaborator

Choose a reason for hiding this comment

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

IsWriteOnly is true only for w mode. what about w+ and r+ modes?
Have you tested all the file open modes manually. is this function returning data correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

There was confusion earlier, Updated the code so that,

  • a/a+ fall under append.
  • r under read
  • w/w+/r+ fall under write mode.

I have checked manually to validate that correct mode is being propagated.

// Append mode is returned for both 'a' and 'a+' flags as the kernel handles the distinction.
// Similarly, read/write ('r+') mode is implicitly handled by the kernel, so this function
// focuses on read-only, write-only, and append modes.
func DetermineFileOpenMode(op *fuseops.OpenFileOp) OpenMode {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add unit tests to this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding unit tests is infeasible as the function takes the OpenFileOp argument, and the method's functionality is tested based on the openflags which is of the type fusekernel.OpenFlags which is private and cannot be accessed or initialized directly in GCSFuse.

// It returns Read, Write, or Append.
//
// Append mode is returned for both 'a' and 'a+' flags as the kernel handles the distinction.
// Similarly, read/write ('r+') mode is implicitly handled by the kernel, so this function
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is not clear.
r+/w/w+ will return as write mode. Wherther reads should be supported or not is implicitly handled by the kernel. So we need not differentiate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted. I have updated the comment, was confused earlier.

)

// OpenMode represents the file access mode.
type OpenMode int
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we call it FileOpenMode so that aliasing the import with different name is not required.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have moved the util file to internal/util so we do not have to care about aliasing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
execute-integration-tests Run only integration tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants