Skip to content

Commit

Permalink
More logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Nov 28, 2023
1 parent 98250c7 commit f7416df
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/storage/utils/metadata/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net"
"github.com/cs3org/reva/v2/pkg/appctx"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/errtypes"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
Expand Down Expand Up @@ -134,11 +135,13 @@ func (cs3 *CS3) SimpleUpload(ctx context.Context, uploadpath string, content []b
Path: uploadpath,
Content: content,
})
appctx.GetLogger(ctx).Info().Msg("returning from cs3.SimpleUpload")
return err
}

// Upload uploads a file to the metadata storage
func (cs3 *CS3) Upload(ctx context.Context, req UploadRequest) (*UploadResponse, error) {
log := appctx.GetLogger(ctx).With().Logger()
ctx, span := tracer.Start(ctx, "Upload")
defer span.End()

Expand Down Expand Up @@ -186,7 +189,9 @@ func (cs3 *CS3) Upload(ctx context.Context, req UploadRequest) (*UploadResponse,
ifuReq.Opaque = utils.AppendPlainToOpaque(ifuReq.Opaque, net.HeaderUploadLength, strconv.FormatInt(int64(len(req.Content)), 10))

fmt.Println("client.InitiateFileUpload")
log.Info().Str("path", req.Path).Msg("cs3.Upload InitiateFileUpload...")
res, err := client.InitiateFileUpload(ctx, ifuReq)
log.Info().Str("path", req.Path).Msg("cs3.Upload InitiateFileUpload done")
fmt.Printf("client.InitiateFileUpload err=%v\n", err)
if err != nil {
return nil, err
Expand Down Expand Up @@ -218,19 +223,28 @@ func (cs3 *CS3) Upload(ctx context.Context, req UploadRequest) (*UploadResponse,
md, _ := metadata.FromOutgoingContext(ctx)
httpReq.Header.Add(ctxpkg.TokenHeader, md.Get(ctxpkg.TokenHeader)[0])
fmt.Println("cs3.dataGatewayClient.Do")
log.Info().Str("path", req.Path).Msg("cs3.Upload dataGatewayClient.Do...")
resp, err := cs3.dataGatewayClient.Do(httpReq)
log.Info().Str("path", req.Path).Interface("err", err).Interface("resp", resp).Msg("cs3.Upload dataGatewayClient.Do done")
fmt.Printf("cs3.dataGatewayClient.Do err=%v\n", err)
if err != nil {
log.Info().Str("path", req.Path).Msg("0")
return nil, err
}
log.Info().Str("path", req.Path).Msg("1")
defer resp.Body.Close()
log.Info().Str("path", req.Path).Msg("2")
if err := errtypes.NewErrtypeFromHTTPStatusCode(resp.StatusCode, httpReq.URL.Path); err != nil {
log.Info().Str("path", req.Path).Msg("2b")
return nil, err
}
log.Info().Str("path", req.Path).Msg("3")
etag := resp.Header.Get("Etag")
log.Info().Str("path", req.Path).Msg("4")
if ocEtag := resp.Header.Get("OC-ETag"); ocEtag != "" {
etag = ocEtag
}
log.Info().Str("path", req.Path).Err(err).Msg("returning from cs3.Upload")
return &UploadResponse{
Etag: etag,
}, nil
Expand Down

0 comments on commit f7416df

Please sign in to comment.