Skip to content

Commit

Permalink
Revert "Efss backend fixes (#3526)"
Browse files Browse the repository at this point in the history
This reverts commit 2c4e018.
  • Loading branch information
gmgigi96 authored Dec 7, 2022
1 parent 2c4e018 commit 8c9d669
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 175 deletions.
6 changes: 0 additions & 6 deletions changelog/unreleased/improve-ocmd-error-logs.md

This file was deleted.

4 changes: 2 additions & 2 deletions internal/grpc/services/ocminvitemanager/ocminvitemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (s *service) ForwardInvite(ctx context.Context, req *invitepb.ForwardInvite
err := s.im.ForwardInvite(ctx, req.InviteToken, req.OriginSystemProvider)
if err != nil {
return &invitepb.ForwardInviteResponse{
Status: status.NewInternal(ctx, err, "error forwarding invite:"+err.Error()),
Status: status.NewInternal(ctx, err, "error forwarding invite"),
}, nil
}

Expand Down Expand Up @@ -158,7 +158,7 @@ func (s *service) FindAcceptedUsers(ctx context.Context, req *invitepb.FindAccep
acceptedUsers, err := s.im.FindAcceptedUsers(ctx, req.Filter)
if err != nil {
return &invitepb.FindAcceptedUsersResponse{
Status: status.NewInternal(ctx, err, "error finding remote users: "+err.Error()),
Status: status.NewInternal(ctx, err, "error finding remote users"),
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *service) CreateOCMShare(ctx context.Context, req *ocm.CreateOCMShareReq

if err != nil {
return &ocm.CreateOCMShareResponse{
Status: status.NewInternal(ctx, err, "error creating share: "+err.Error()),
Status: status.NewInternal(ctx, err, "error creating share"),
}, nil
}

Expand Down
3 changes: 1 addition & 2 deletions internal/http/services/ocmd/invites.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (h *invitesHandler) forwardInvite(w http.ResponseWriter, r *http.Request) {
return
}

_, err = w.Write([]byte("{\"message\": \"Success\", \"providerDomain\":\"" + html.EscapeString(providerDomain) + "\"}"))
_, err = w.Write([]byte("Accepted invite from: " + html.EscapeString(providerDomain)))
if err != nil {
WriteError(w, r, APIErrorServerError, "error writing token data", err)
return
Expand Down Expand Up @@ -313,7 +313,6 @@ func (h *invitesHandler) findAcceptedUsers(w http.ResponseWriter, r *http.Reques
indentedResponse, _ := json.MarshalIndent(response, "", " ")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
log.Debug().Msg("findAcceptedUsers json response: " + string(indentedResponse))
if _, err := w.Write(indentedResponse); err != nil {
log.Err(err).Msg("Error writing to ResponseWriter")
}
Expand Down
3 changes: 1 addition & 2 deletions internal/http/services/ocmd/ocmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ func (s *svc) Handler() http.Handler {
return
case "send":
s.SendHandler.Handler().ServeHTTP(w, r)
return
}

log.Warn().Msgf("request not handled. Try e.g. 'ocm-provider', 'shares', 'notifications', 'invites', or 'send' instead of '%s'", head)
log.Warn().Msg("request not handled")
w.WriteHeader(http.StatusNotFound)
})
}
19 changes: 4 additions & 15 deletions internal/http/services/ocmd/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/cs3org/reva/pkg/appctx"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/utils"
"google.golang.org/grpc/metadata"
)

Expand Down Expand Up @@ -110,13 +109,13 @@ func (h *sendHandler) Handler() http.Handler {
req := &provider.StatRequest{Ref: ref}
res2, err := gatewayClient.Stat(authCtx, req)
if err != nil {
log.Error().Msg("gatewayClient.Stat operation failed; is the storage backend reachable?")
log.Error().Msg("error sending: stat file/folder to share")
w.WriteHeader(http.StatusInternalServerError)
return
}

if res2.Status.Code != rpc.Code_CODE_OK {
log.Error().Msgf("sourcePath %s does not exist on the storage backend", sourcePath)
log.Error().Msg("error returned: stat file/folder to share")
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down Expand Up @@ -184,27 +183,17 @@ func (h *sendHandler) Handler() http.Handler {

shareRes, err := gatewayClient.CreateOCMShare(authCtx, shareRequest)
if err != nil {
log.Error().Msg("error sending: CreateShare: " + err.Error())
log.Error().Msg("error sending: CreateShare")
w.WriteHeader(http.StatusInternalServerError)
return
}

if shareRes.Status.Code != rpc.Code_CODE_OK {
log.Error().Msg("error returned: CreateShare: " + err.Error())
log.Error().Msg("error returned: CreateShare")
w.WriteHeader(http.StatusInternalServerError)
return
}

responseBody, err := utils.MarshalProtoV1ToJSON(shareRes)
if err != nil {
log.Error().Msg("error encoding response: " + err.Error())
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
_, err = w.Write(responseBody)
if err != nil {
log.Error().Msg("error writing response body:" + err.Error())
}
})
}
14 changes: 4 additions & 10 deletions internal/http/services/ocmd/shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,11 @@ func (h *sharesHandler) createShare(w http.ResponseWriter, r *http.Request) {
}

if resource == "" || providerID == "" || owner == "" {
msg := fmt.Sprintf("missing details about resource to be shared (resource='%s', providerID='%s', owner='%s", resource, providerID, owner)
WriteError(w, r, APIErrorInvalidParameter, msg, nil)
WriteError(w, r, APIErrorInvalidParameter, "missing details about resource to be shared", nil)
return
}
if shareWith == "" || protocol["name"] == "" || meshProvider == "" {
msg := fmt.Sprintf("missing request parameters (shareWith='%s', protocol.name='%s', meshProvider='%s'", shareWith, protocol["name"], meshProvider)
WriteError(w, r, APIErrorInvalidParameter, msg, nil)
WriteError(w, r, APIErrorInvalidParameter, "missing request parameters", nil)
return
}

Expand Down Expand Up @@ -190,13 +188,9 @@ func (h *sharesHandler) createShare(w http.ResponseWriter, r *http.Request) {
return
}

ownerParts := strings.Split(owner, "@")
if len(ownerParts) != 2 {
WriteError(w, r, APIErrorInvalidParameter, "owner should be opaqueId@webDAVHost", nil)
}
ownerID := &userpb.UserId{
OpaqueId: ownerParts[0],
Idp: ownerParts[1],
OpaqueId: owner,
Idp: meshProvider,
Type: userpb.UserType_USER_TYPE_PRIMARY,
}
createShareReq := &ocmcore.CreateOCMCoreShareRequest{
Expand Down
5 changes: 0 additions & 5 deletions pkg/auth/manager/nextcloud/nextcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ package nextcloud
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
"strings"

authpb "github.com/cs3org/go-cs3apis/cs3/auth/provider/v1beta1"
Expand Down Expand Up @@ -143,9 +141,6 @@ func (am *Manager) do(ctx context.Context, a Action) (int, []byte, error) {
}

log.Info().Msgf("am.do response %d %s", resp.StatusCode, body)
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
return 0, nil, fmt.Errorf("Unexpected response code from EFSS API: " + strconv.Itoa(resp.StatusCode))
}
return resp.StatusCode, body, nil
}

Expand Down
10 changes: 1 addition & 9 deletions pkg/ocm/invite/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
invitepb "github.com/cs3org/go-cs3apis/cs3/ocm/invite/v1beta1"
ocmprovider "github.com/cs3org/go-cs3apis/cs3/ocm/provider/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/ocm/invite"
Expand Down Expand Up @@ -236,7 +235,7 @@ func (m *manager) ForwardInvite(ctx context.Context, invite *invitepb.InviteToke
if e != nil {
return errors.Wrap(e, "json: error reading request body")
}
return errors.Wrap(fmt.Errorf("%s: %s", resp.Status, string(respBody)), fmt.Sprintf("json: error sending accept post request to %s", recipientURL))
return errors.Wrap(fmt.Errorf("%s: %s", resp.Status, string(respBody)), "json: error sending accept post request")
}

return nil
Expand Down Expand Up @@ -273,14 +272,7 @@ func (m *manager) AcceptInvite(ctx context.Context, invite *invitepb.InviteToken

func (m *manager) GetAcceptedUser(ctx context.Context, remoteUserID *userpb.UserId) (*userpb.User, error) {
userKey := ctxpkg.ContextMustGetUser(ctx).GetId().GetOpaqueId()
log := appctx.GetLogger(ctx)
for _, acceptedUser := range m.model.AcceptedUsers[userKey] {
log.Info().Msgf("looking for '%s' at '%s' - considering '%s' at '%s'",
remoteUserID.OpaqueId,
remoteUserID.Idp,
acceptedUser.Id.GetOpaqueId(),
acceptedUser.Id.GetIdp(),
)
if (acceptedUser.Id.GetOpaqueId() == remoteUserID.OpaqueId) && (remoteUserID.Idp == "" || acceptedUser.Id.GetIdp() == remoteUserID.Idp) {
return acceptedUser, nil
}
Expand Down
12 changes: 1 addition & 11 deletions pkg/ocm/share/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/ocm/share"
Expand Down Expand Up @@ -265,15 +264,6 @@ func (m *mgr) Share(ctx context.Context, md *provider.ResourceId, g *ocm.ShareGr
protocol["name"] = "datatx"
}

log := appctx.GetLogger(ctx)
log.Info().Msg("pkg/ocm/share/manager/json calls sender.Send")
log.Info().Msgf("pkg/ocm/share/manager/json shareWith: %s", g.Grantee.GetUserId().OpaqueId)
log.Info().Msgf("pkg/ocm/share/manager/json name: %s", name)
log.Info().Msgf("pkg/ocm/share/manager/json providerId: %s", fmt.Sprintf("%s:%s", md.StorageId, md.OpaqueId))
log.Info().Msgf("pkg/ocm/share/manager/json owner: %s", userID.OpaqueId)
log.Info().Msgf("pkg/ocm/share/manager/json protocol: %s", protocol)
log.Info().Msgf("pkg/ocm/share/manager/json meshProvider: %s", userID.Idp)

requestBodyMap := map[string]interface{}{
"shareWith": g.Grantee.GetUserId().OpaqueId,
"name": name,
Expand All @@ -282,7 +272,7 @@ func (m *mgr) Share(ctx context.Context, md *provider.ResourceId, g *ocm.ShareGr
"protocol": protocol,
"meshProvider": userID.Idp, // FIXME: move this into the 'owner' string?
}
err = sender.Send(ctx, requestBodyMap, pi)
err = sender.Send(requestBodyMap, pi)
if err != nil {
err = errors.Wrap(err, "error sending OCM POST")
return nil, err
Expand Down
Loading

0 comments on commit 8c9d669

Please sign in to comment.