Skip to content

Commit

Permalink
Revert "remove unused gateway config "commit_share_to_storage_ref" (c…
Browse files Browse the repository at this point in the history
…s3org#3017)"

This reverts commit fedad9c.
  • Loading branch information
kobergj committed Jul 14, 2022
1 parent f8f6ad6 commit 122764d
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 9 deletions.

This file was deleted.

1 change: 1 addition & 0 deletions examples/ocmd/ocmd-server-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ocmproviderauthorizersvc = "localhost:19000"
datagateway = "http://localhost:19001/data"
transfer_expires = 6 # give it a moment
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.authregistry]
driver = "static"
Expand Down
1 change: 1 addition & 0 deletions examples/ocmd/ocmd-server-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ocmproviderauthorizersvc = "localhost:17000"
datagateway = "http://localhost:17001/data"
transfer_expires = 6 # give it a moment
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.authregistry]
driver = "static"
Expand Down
1 change: 1 addition & 0 deletions examples/oidc-mapping-tpc/server-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gatewaysvc = "localhost:19000"
# services to enable
[grpc.services.gateway]
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.authprovider]
[grpc.services.authprovider.auth_managers.json]
Expand Down
1 change: 1 addition & 0 deletions examples/oidc-mapping-tpc/server-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gatewaysvc = "localhost:17000"
# services to enable
[grpc.services.gateway]
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.authprovider]
[grpc.services.authprovider.auth_managers.json]
Expand Down
1 change: 1 addition & 0 deletions examples/storage-references/gateway.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# services to enable
[grpc.services.gateway]
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.storageregistry]
[grpc.services.storageregistry.drivers.static]
Expand Down
1 change: 1 addition & 0 deletions examples/two-server-setup/gateway-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ address = "0.0.0.0:19000"
# services to enable
[grpc.services.gateway]
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.storageregistry]
[grpc.services.storageregistry.drivers.static]
Expand Down
1 change: 1 addition & 0 deletions examples/two-server-setup/gateway-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ocmshareprovidersvc = "localhost:29000"
ocminvitemanagersvc = "localhost:29000"
ocmproviderauthorizersvc = "localhost:29000"
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true

[grpc.services.storageregistry]
[grpc.services.storageregistry.drivers.static]
Expand Down
1 change: 1 addition & 0 deletions internal/grpc/services/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type config struct {
DataGatewayEndpoint string `mapstructure:"datagateway"`
PermissionsEndpoint string `mapstructure:"permissionssvc"`
CommitShareToStorageGrant bool `mapstructure:"commit_share_to_storage_grant"`
CommitShareToStorageRef bool `mapstructure:"commit_share_to_storage_ref"`
DisableHomeCreationOnLogin bool `mapstructure:"disable_home_creation_on_login"`
TransferSharedSecret string `mapstructure:"transfer_shared_secret"`
TransferExpires int64 `mapstructure:"transfer_expires"`
Expand Down
14 changes: 13 additions & 1 deletion internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ func (s *svc) CreateOCMShare(ctx context.Context, req *ocm.CreateOCMShareRequest
return nil, errors.Wrap(err, "gateway: error calling CreateShare")
}

// if we don't need to commit we return earlier
if !s.c.CommitShareToStorageGrant && !s.c.CommitShareToStorageRef {
return res, nil
}

// TODO(labkode): if both commits are enabled they could be done concurrently.
if s.c.CommitShareToStorageGrant {
addGrantStatus, err := s.addGrant(ctx, req.ResourceId, req.Grant.Grantee, req.Grant.Permissions.Permissions, nil)
if err != nil {
Expand Down Expand Up @@ -102,6 +108,12 @@ func (s *svc) RemoveOCMShare(ctx context.Context, req *ocm.RemoveOCMShareRequest
return nil, errors.Wrap(err, "gateway: error calling RemoveShare")
}

// if we don't need to commit we return earlier
if !s.c.CommitShareToStorageGrant && !s.c.CommitShareToStorageRef {
return res, nil
}

// TODO(labkode): if both commits are enabled they could be done concurrently.
if s.c.CommitShareToStorageGrant {
removeGrantStatus, err := s.removeGrant(ctx, share.ResourceId, share.Grantee, share.Permissions.Permissions)
if err != nil {
Expand Down Expand Up @@ -209,7 +221,7 @@ func (s *svc) UpdateReceivedOCMShare(ctx context.Context, req *ocm.UpdateReceive
}

// if we don't need to create/delete references then we return early.
if !s.c.CommitShareToStorageGrant {
if !s.c.CommitShareToStorageGrant && !s.c.CommitShareToStorageRef {
return res, nil
}

Expand Down
20 changes: 19 additions & 1 deletion internal/grpc/services/gateway/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ func (s *svc) UpdateShare(ctx context.Context, req *collaboration.UpdateShareReq
return nil, errors.Wrap(err, "gateway: error calling UpdateShare")
}

// if we don't need to commit we return earlier
if !s.c.CommitShareToStorageGrant && !s.c.CommitShareToStorageRef {
return res, nil
}

// TODO(labkode): if both commits are enabled they could be done concurrently.

if s.c.CommitShareToStorageGrant {
updateGrantStatus, err := s.updateGrant(ctx, res.GetShare().GetResourceId(),
res.GetShare().GetGrantee(),
Expand Down Expand Up @@ -552,7 +559,12 @@ func (s *svc) addShare(ctx context.Context, req *collaboration.CreateShareReques
if res.Status.Code != rpc.Code_CODE_OK {
return res, nil
}
// if we don't need to commit we return earlier
if !s.c.CommitShareToStorageGrant && !s.c.CommitShareToStorageRef {
return res, nil
}

// TODO(labkode): if both commits are enabled they could be done concurrently.
if s.c.CommitShareToStorageGrant {
// If the share is a denial we call denyGrant instead.
var status *rpc.Status
Expand Down Expand Up @@ -640,7 +652,7 @@ func (s *svc) removeShare(ctx context.Context, req *collaboration.RemoveShareReq
// if we need to commit the share, we need the resource it points to.
var share *collaboration.Share
// FIXME: I will cause a panic as share will be nil when I'm false
if s.c.CommitShareToStorageGrant {
if s.c.CommitShareToStorageGrant || s.c.CommitShareToStorageRef {
getShareReq := &collaboration.GetShareRequest{
Ref: req.Ref,
}
Expand Down Expand Up @@ -669,6 +681,12 @@ func (s *svc) removeShare(ctx context.Context, req *collaboration.RemoveShareReq
s.removeReference(ctx, share.ResourceId)
}

// if we don't need to commit we return earlier
if !s.c.CommitShareToStorageGrant && !s.c.CommitShareToStorageRef {
return res, nil
}

// TODO(labkode): if both commits are enabled they could be done concurrently.
if s.c.CommitShareToStorageGrant {
removeGrantStatus, err := s.removeGrant(ctx, share.ResourceId, share.Grantee, share.Permissions.Permissions)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions tests/oc-integration-tests/drone/gateway-virtual.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ocminvitemanagersvc = "localhost:14000"
ocmproviderauthorizersvc = "localhost:14000"
# other
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true
share_folder = "Shares"
datagateway = "http://localhost:19001/data"
transfer_shared_secret = "replace-me-with-a-transfer-secret" # for direct uploads
Expand Down
1 change: 1 addition & 0 deletions tests/oc-integration-tests/drone/gateway.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ocmproviderauthorizersvc = "localhost:14000"
permissionssvc = "localhost:10000"
# other
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true
share_folder = "Shares"
datagateway = "http://localhost:19001/data"
transfer_shared_secret = "replace-me-with-a-transfer-secret" # for direct uploads
Expand Down
1 change: 1 addition & 0 deletions tests/oc-integration-tests/local-mesh/gateway.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ocminvitemanagersvc = "localhost:34000"
ocmproviderauthorizersvc = "localhost:34000"
# other
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true
share_folder = "Shares"
datagateway = "http://localhost:39001/data"
transfer_shared_secret = "replace-me-with-a-transfer-secret" # for direct uploads
Expand Down
5 changes: 3 additions & 2 deletions tests/oc-integration-tests/local/combined.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jwt_secret = "Pive-Fumkiu4"
#groupprovidersvc = "localhost:18000"
# other
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true
#share_folder = "Shares"
transfer_expires = 6 # give it a moment
#disable_home_creation_on_login = true
Expand Down Expand Up @@ -74,7 +75,7 @@ users = "users.demo.json"
[grpc.services.sharesstorageprovider]
usershareprovidersvc = "0.0.0.0:19000"

# FIXME start as a separate service ... collides with the storageprovider:
# FIXME start as a separate service ... collides with the storageprovider:
# Server.RegisterService found duplicate service registration for "cs3.storage.provider.v1beta1.ProviderAPI"
#[grpc.services.sharesstorageprovider]

Expand Down Expand Up @@ -185,4 +186,4 @@ temp_folder = "/var/tmp/reva/tmp"
root = "/var/tmp/reva/data"
enable_home = false
treetime_accounting = true
treesize_accounting = true
treesize_accounting = true
1 change: 1 addition & 0 deletions tests/oc-integration-tests/local/gateway-virtual.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ocminvitemanagersvc = "localhost:14000"
ocmproviderauthorizersvc = "localhost:14000"
# other
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true
share_folder = "Shares"
datagateway = "http://localhost:19001/data"
transfer_shared_secret = "replace-me-with-a-transfer-secret" # for direct uploads
Expand Down
1 change: 1 addition & 0 deletions tests/oc-integration-tests/local/gateway.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ocmproviderauthorizersvc = "localhost:14000"
permissionssvc = "localhost:10000"
# other
commit_share_to_storage_grant = true
commit_share_to_storage_ref = true
share_folder = "Shares"
datagateway = "http://localhost:19001/data"
transfer_shared_secret = "replace-me-with-a-transfer-secret" # for direct uploads
Expand Down

0 comments on commit 122764d

Please sign in to comment.