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

Ensure stray shares get ignored #1064

Merged
merged 21 commits into from
Aug 12, 2020
Merged

Ensure stray shares get ignored #1064

merged 21 commits into from
Aug 12, 2020

Conversation

refs
Copy link
Member

@refs refs commented Aug 6, 2020

Scope

JSON Shares Manager.

When using the json shares manager, it can be the case we found a share with a resource_id that no longer exists. This PR aims to address his case by changing the contract of getPath and return the result of the STAT call instead of a generic error, so we can check the cause.

This is by no means a perfect solution, but starts addressing the inconsistencies of the error handling across the code base.

@refs refs requested a review from labkode as a code owner August 6, 2020 14:51
@update-docs
Copy link

update-docs bot commented Aug 6, 2020

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@refs refs requested a review from PVince81 August 6, 2020 14:58
@kulmann kulmann mentioned this pull request Aug 6, 2020
63 tasks
@PVince81
Copy link
Contributor

PVince81 commented Aug 6, 2020

  • add changelog
  • follow linter

@@ -139,7 +158,8 @@ func (s *svc) InitiateFileDownload(ctx context.Context, req *provider.InitiateFi
err := errtypes.PermissionDenied("gateway: cannot download share folder or share name: path=" + p)
log.Err(err).Msg("gateway: error downloading")
return &gateway.InitiateFileDownloadResponse{
Status: status.NewInvalidArg(ctx, "path points to share folder or share name"),
// Status: status.NewInvalidArg(ctx, "path points to share folder or share name"),
Copy link
Contributor

Choose a reason for hiding this comment

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

uncomment again ?

log.Err(err).Msg("gateway: error moving")
p, st := s.getPath(ctx, req.Source)
if st.Code != rpc.Code_CODE_OK {
// log.Err(err).Msg("gateway: error moving")
Copy link
Contributor

Choose a reason for hiding this comment

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

stray comment

@PVince81
Copy link
Contributor

PVince81 commented Aug 6, 2020

  • recheck commented out code
  • check inline TODOs and fix or raise ticket for later

Copy link
Contributor

@ishank011 ishank011 left a comment

Choose a reason for hiding this comment

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

@refs Really nice change! One comment though.

Also, we should have this for public shares as well, as there we support sharing single files and in EOS, the ResourceID changes every time a file is edited, so there you get a lot of such errors. We'll start working on fixing that at the fs level next week.

internal/grpc/services/gateway/storageprovider.go Outdated Show resolved Hide resolved
@refs refs mentioned this pull request Aug 7, 2020
}, nil
}

dp, err := s.getPath(ctx, req.Destination)
if err != nil {
log.Err(err).Msg("gateway: error moving")
// log.Err(err).Msg("gateway: error moving")
Copy link
Contributor

Choose a reason for hiding this comment

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

obsolete, or need to be re-enabled?

Copy link
Member Author

Choose a reason for hiding this comment

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

obsolete

@labkode labkode requested a review from ishank011 August 7, 2020 13:27
@individual-it
Copy link
Contributor

moving a file or folder via webDAV fails with:

2020-08-10 12:09:16.81 DBG home/artur/www/cs3org/reva/pkg/storage/fs/owncloud/owncloud.go:429 > ocfs: unwrap: internal=/var/tmp/reva/data/einstein/files/destination external=/destination pid=35749 pkg=rgrpc traceid=5e237fe2ce00f9b0eef4a36ea004e093
2020-08-10 12:09:16.81 DBG home/artur/www/cs3org/reva/pkg/storage/fs/owncloud/owncloud.go:429 > ocfs: unwrap: internal=/var/tmp/reva/data/einstein/files/destination external=/destination pid=35749 pkg=rgrpc traceid=5e237fe2ce00f9b0eef4a36ea004e093
2020-08-10 12:09:16.81 WRN home/artur/www/cs3org/reva/internal/grpc/services/storageprovider/storageprovider.go:468 > file not found pid=35749 pkg=rgrpc traceid=5e237fe2ce00f9b0eef4a36ea004e093
2020-08-10 12:09:16.81 INF home/artur/www/cs3org/reva/internal/grpc/interceptors/log/log.go:69 > unary code=OK end="10/Aug/2020:12:09:16 +0545" from=tcp://127.0.0.1:54054 pid=35749 pkg=rgrpc start="10/Aug/2020:12:09:16 +0545" time_ns=475855 traceid=5e237fe2ce00f9b0eef4a36ea004e093 uri=/cs3.storage.provider.v1beta1.ProviderAPI/Stat user-agent=grpc-go/1.26.0
2020-08-10 12:09:16.81 INF home/artur/www/cs3org/reva/internal/grpc/interceptors/log/log.go:69 > unary code=OK end="10/Aug/2020:12:09:16 +0545" from=tcp://127.0.0.1:51918 pid=35762 pkg=rgrpc start="10/Aug/2020:12:09:16 +0545" time_ns=1152306 traceid=5e237fe2ce00f9b0eef4a36ea004e093 uri=/cs3.gateway.v1beta1.GatewayAPI/Stat user-agent=grpc-go/1.26.0
2020-08-10 12:09:16.811 ERR home/artur/www/cs3org/reva/internal/http/interceptors/log/log.go:112 > http end="10/Aug/2020:12:09:16 +0545" host=10.4.1.204 method=MOVE pid=35775 pkg=rhttp proto=HTTP/1.1 size=0 start="10/Aug/2020:12:09:16 +0545" status=500 time_ns=20329472 traceid=5e237fe2ce00f9b0eef4a36ea004e093 uri=/remote.php/webdav/src url=/remote.php/webdav/src

@PVince81
Copy link
Contributor

indeed, Litmus failed here in #1068:


10. move_coll............. FAIL (collection MOVE `/remote.php/webdav/litmus/mvsrc/' to `/remote.php/webdav/litmus/mvdest/': 500 Internal Server Error)
--

  • fix MOVE operation

@PVince81
Copy link
Contributor

@butonic
Copy link
Contributor

butonic commented Aug 10, 2020

@refs refs changed the title Ensure stray shares get ignored (json share manager) [WIP] Ensure stray shares get ignored (json share manager) Aug 10, 2020
@PVince81
Copy link
Contributor

    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsDELETEAuth.feature:54
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsDELETEAuth.feature:64
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsDELETEAuth.feature:73
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsDELETEAuth.feature:82
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsGETAuth.feature:76
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsGETAuth.feature:137
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsGETAuth.feature:253
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsGETAuth.feature:302
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsPOSTAuth.feature:74
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsPOSTAuth.feature:89
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsPOSTAuth.feature:104
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsPUTAuth.feature:43
    /drone/src/tmp/testrunner/tests/acceptance/features/apiAuthOcs/ocsPUTAuth.feature:60
    /drone/src/tmp/testrunner/tests/acceptance/features/apiShareManagementBasic/createShare.feature:347
    /drone/src/tmp/testrunner/tests/acceptance/features/apiShareManagementBasic/createShare.feature:348

.drone.yml Outdated
@@ -342,9 +342,8 @@ steps:
image: owncloudci/php:7.2
commands:
- git clone -b master --depth=1 https://github.com/owncloud/testing.git /drone/src/tmp/testing
- git clone -b master --single-branch --no-tags https://github.com/owncloud/core.git /drone/src/tmp/testrunner
- git clone -b testFixOCISPR409 --single-branch --no-tags https://github.com/owncloud/core.git /drone/src/tmp/testrunner
Copy link
Contributor

Choose a reason for hiding this comment

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

use reva-tests, see owncloud/core#37798

@PVince81
Copy link
Contributor

proposed fix:

in owncloud.go's getPath:

  • check if we received an existing path, and then call GetMd() (or whatever method for getting the oc fileid from storage)
  • if GetMd() failed with "not found", discard the value in redis and return an error as if the key did not exist
  • if GetMd() succeeded, compare the returned file id with the expected opaque id. if different, discard the value in redis and return an error as if the key did not exist
  • otherwise, return the path

@refs
Copy link
Member Author

refs commented Aug 11, 2020

While working on this we realized we're using errors.Wrap all over the place on owncloud.go. GetMD(). I believe we should wrap on the lowest layers, in the context of this PR that would be getPath() and unwrapping on the top layers to assert on the underlying error type.

@refs refs mentioned this pull request Aug 11, 2020
@@ -84,7 +84,6 @@ Feature: sharing
| 2 | 200 |

@issue-ocis-reva-372 @issue-ocis-reva-243
# after fixing all issues delete this Scenario and use the one from oC10 core
Copy link
Contributor

Choose a reason for hiding this comment

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

why deleting this line

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, got mixed up

@@ -912,3 +912,7 @@ apiWebdavUpload2/uploadFileUsingOldChunking.feature:98
apiWebdavUpload2/uploadFileUsingOldChunking.feature:99
apiWebdavUpload2/uploadFileUsingOldChunking.feature:100
apiWebdavUpload2/uploadFileUsingOldChunking.feature:101
#
# https://github.com/owncloud/ocis-reva/issues/372 Listing shares via ocs API does not show path for parent folders
apiShareManagementBasic/createShare.feature:269
Copy link
Contributor

Choose a reason for hiding this comment

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

@toImplementOnOCIS tag removed here owncloud/core#37809 maybe the commit id must be advanced

Copy link
Member Author

Choose a reason for hiding this comment

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

but this is not the same file as core, this is the local feature for reva.

Copy link
Contributor

Choose a reason for hiding this comment

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

even if we change anything in core this PR is still green, because we are already expecting the failures.

butonic
butonic previously approved these changes Aug 12, 2020
@refs refs changed the title [WIP] Ensure stray shares get ignored (json share manager) Ensure stray shares get ignored Aug 12, 2020
Copy link
Contributor

@butonic butonic left a comment

Choose a reason for hiding this comment

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

there was some testing confusion, but this now works as intended.

Copy link
Contributor

@ishank011 ishank011 left a comment

Choose a reason for hiding this comment

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

@refs A couple of comments.

@@ -1295,7 +1295,13 @@ func (h *Handler) listUserShares(r *http.Request, filters []*collaboration.ListS
}

if statResponse.Status.Code != rpc.Code_CODE_OK {
return nil, errors.New("could not stat share target")
if statResponse.Status.Code == rpc.Code_CODE_NOT_FOUND {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add this in listPublicShares?

Copy link
Member Author

Choose a reason for hiding this comment

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

totally. I'd get hands on it tomorrow morning first thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually giving this a second thought, as this PR has been messy enough with the testing I would like to create a new one for these changes and keep changes as "atomic" as possible. This PR is blocking us from finishing http://github.com/owncloud/ocis/pull/409 and the earlier we merge it the better 🙄

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh okay. No worries then. I'll merge it

if res.Status.Code != rpc.Code_CODE_OK {
err := status.NewErrorFromCode(res.Status.Code, "gateway")
return "", err
if (res != nil && res.Status.Code != rpc.Code_CODE_OK) || err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check res != nil? There might arise cases where we might have initialized it and then run into some error but returned it anyway.

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.

5 participants