Skip to content

Commit

Permalink
Get the logger in the grpcMDResponseToFileInfo func, log the stat out…
Browse files Browse the repository at this point in the history
…comes
  • Loading branch information
Fabrizio Furano committed Nov 2, 2023
1 parent 4ec0eb3 commit cdeb6b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/eosgrpc-stat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Get the logger in the grpcMDResponseToFileInfo func, log the stat

https://github.com/cs3org/reva/pull/4309
14 changes: 8 additions & 6 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"github.com/cs3org/reva/pkg/storage/utils/acl"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand Down Expand Up @@ -469,7 +468,7 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, auth eosclient.Authoriz

log.Debug().Uint64("inode", inode).Str("rsp:", fmt.Sprintf("%#v", rsp)).Msg("grpc response")

info, err := c.grpcMDResponseToFileInfo(rsp)
info, err := c.grpcMDResponseToFileInfo(ctx, rsp)
if err != nil {
return nil, err
}
Expand All @@ -482,7 +481,7 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, auth eosclient.Authoriz
info.Inode = inode
}

log.Debug().Str("func", "GetFileInfoByInode").Uint64("inode", inode).Msg("")
log.Debug().Str("func", "GetFileInfoByInode").Uint64("inode", inode).Uint64("info.Inode", info.Inode).Str("file", info.File).Uint64("size", info.Size).Str("etag", info.ETag).Msg("")
return c.fixupACLs(ctx, auth, info), nil
}

Expand Down Expand Up @@ -699,7 +698,7 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza

log.Debug().Str("func", "GetFileInfoByPath").Str("path", path).Str("rsp:", fmt.Sprintf("%#v", rsp)).Msg("grpc response")

info, err := c.grpcMDResponseToFileInfo(rsp)
info, err := c.grpcMDResponseToFileInfo(ctx, rsp)
if err != nil {
return nil, err
}
Expand All @@ -712,6 +711,7 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza
info.Inode = inode
}

log.Debug().Str("func", "GetFileInfoByPath").Str("path", path).Uint64("info.Inode", info.Inode).Uint64("size", info.Size).Str("etag", info.ETag).Msg("")
return c.fixupACLs(ctx, auth, info), nil
}

Expand Down Expand Up @@ -1202,7 +1202,7 @@ func (c *Client) List(ctx context.Context, auth eosclient.Authorization, dpath s

log.Debug().Str("func", "List").Str("path", dpath).Str("item resp:", fmt.Sprintf("%#v", rsp)).Msg("grpc response")

myitem, err := c.grpcMDResponseToFileInfo(rsp)
myitem, err := c.grpcMDResponseToFileInfo(ctx, rsp)
if err != nil {
log.Error().Err(err).Str("func", "List").Str("path", dpath).Str("could not convert item:", fmt.Sprintf("%#v", rsp)).Str("err", err.Error()).Msg("")

Expand Down Expand Up @@ -1572,12 +1572,14 @@ func getFileFromVersionFolder(p string) string {
return path.Join(path.Dir(p), strings.TrimPrefix(path.Base(p), versionPrefix))
}

func (c *Client) grpcMDResponseToFileInfo(st *erpc.MDResponse) (*eosclient.FileInfo, error) {
func (c *Client) grpcMDResponseToFileInfo(ctx context.Context, st *erpc.MDResponse) (*eosclient.FileInfo, error) {
if st.Cmd == nil && st.Fmd == nil {
return nil, errors.Wrap(errtypes.NotSupported(""), "Invalid response (st.Cmd and st.Fmd are nil)")
}
fi := new(eosclient.FileInfo)

log := appctx.GetLogger(ctx)

if st.Type == erpc.TYPE_CONTAINER {
fi.IsDir = true
fi.Inode = st.Cmd.Inode
Expand Down

0 comments on commit cdeb6b7

Please sign in to comment.