Skip to content
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

eos: fixed error reporting for too large recycle bin listing #4591

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/recycle-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: eos: fixed error reporting for too large recycle bin listing

EOS returns E2BIG, which internally gets converted to PermissionDenied
and has to be properly handled in this case.

https://github.com/cs3org/reva/pull/4591
14 changes: 12 additions & 2 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ func (c *Client) executeEOS(ctx context.Context, cmdArgs []string, auth eosclien
// eos reports back error code 1 (EPERM) when ?
// eos reports back error code 7 (E2BIG) when the user is not allowed to read the directory
// eos reports back error code 22 (EINVAL) when the user is not allowed to enter the instance
err = errtypes.PermissionDenied(errBuf.String())
errString := errBuf.String()
if errString == "" {
errString = fmt.Sprintf("rc = %d", exitStatus)
}
err = errtypes.PermissionDenied(errString)
}
}
}
Expand Down Expand Up @@ -794,7 +798,13 @@ func (c *Client) ListDeletedEntries(ctx context.Context, auth eosclient.Authoriz
args := []string{"recycle", "ls", "-m", d.Format("2006/01/02"), fmt.Sprintf("%d", maxentries+1)}
stdout, _, err := c.executeEOS(ctx, args, auth)
if err != nil {
return nil, err
switch err.(type) {
case errtypes.IsPermissionDenied:
// in this context, this is an E2BIG that gets converted to PermissionDenied by executeEOS()
return nil, errtypes.BadRequest("list too long")
default:
return nil, err
}
}

list, err := parseRecycleList(stdout)
Expand Down
Loading