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

Ocmd error messages #3369

Closed
wants to merge 6 commits into from
Closed
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
4 changes: 4 additions & 0 deletions changelog/unreleased/improve-ocmd-error-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Enhancement: Improve error logging in ocmd flow

https://github.com/cs3org/reva/issues/3365
https://github.com/cs3org/reva/pull/3369
5 changes: 3 additions & 2 deletions internal/grpc/services/ocminvitemanager/ocminvitemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ func (s *service) GenerateInviteToken(ctx context.Context, req *invitepb.Generat
func (s *service) ForwardInvite(ctx context.Context, req *invitepb.ForwardInviteRequest) (*invitepb.ForwardInviteResponse, error) {
err := s.im.ForwardInvite(ctx, req.InviteToken, req.OriginSystemProvider)
if err != nil {
message := err.Error()
return &invitepb.ForwardInviteResponse{
Status: status.NewInternal(ctx, "error forwarding invite"),
Status: status.NewInternal(ctx, "error forwarding invite:"+message),
}, nil
}

Expand Down Expand Up @@ -159,7 +160,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, "error finding remote users"),
Status: status.NewInternal(ctx, "error finding remote users: "+err.Error()),
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (s *service) IsProviderAllowed(ctx context.Context, req *ocmprovider.IsProv
err := s.pa.IsProviderAllowed(ctx, req.Provider)
if err != nil {
return &ocmprovider.IsProviderAllowedResponse{
Status: status.NewInternal(ctx, "error verifying mesh provider"),
Status: status.NewInternal(ctx, "error verifying mesh provider"+err.Error()),
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions internal/http/services/ocmd/invites.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ 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
4 changes: 2 additions & 2 deletions internal/http/services/ocmd/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ func (h *sendHandler) Handler() http.Handler {
req := &provider.StatRequest{Ref: ref}
res2, err := gatewayClient.Stat(authCtx, req)
if err != nil {
log.Error().Msg("error sending: stat file/folder to share")
log.Error().Msg("gatewayClient.Stat operation failed; is the storage backend reachable?")
w.WriteHeader(http.StatusInternalServerError)
return
}

if res2.Status.Code != rpc.Code_CODE_OK {
log.Error().Msg("error returned: stat file/folder to share")
log.Error().Msgf("sourcePath %s does not exist on the storage backend", sourcePath)
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/ocm/provider/authorizer/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"sync"

ocmprovider "github.com/cs3org/go-cs3apis/cs3/ocm/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/appctx"
"github.com/cs3org/reva/v2/pkg/errtypes"
"github.com/cs3org/reva/v2/pkg/ocm/provider"
"github.com/cs3org/reva/v2/pkg/ocm/provider/authorizer/registry"
Expand Down Expand Up @@ -115,13 +116,17 @@ func (a *authorizer) GetInfoByDomain(ctx context.Context, domain string) (*ocmpr

func (a *authorizer) IsProviderAllowed(ctx context.Context, provider *ocmprovider.ProviderInfo) error {
var err error
log := appctx.GetLogger(ctx)

normalizedDomain, err := normalizeDomain(provider.Domain)
log.Info().Msgf("Checking if provider is allowed: %s", normalizedDomain)
if err != nil {
return err
}
var providerAuthorized bool
if normalizedDomain != "" {
for _, p := range a.providers {
log.Info().Msgf("Trying %s", p.Domain)
if p.Domain == normalizedDomain {
providerAuthorized = true
break
Expand Down
5 changes: 4 additions & 1 deletion pkg/storage/fs/nextcloud/nextcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"strings"

user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
Expand Down Expand Up @@ -229,7 +230,9 @@ func (nc *StorageDriver) do(ctx context.Context, a Action) (int, []byte, error)
return 0, nil, err
}
log.Info().Msgf("nc.do res %s %s", url, string(body))

if resp.StatusCode != http.StatusOK {
return 0, nil, fmt.Errorf("Unexpected response code from EFSS API: " + strconv.Itoa(resp.StatusCode))
}
return resp.StatusCode, body, nil
}

Expand Down