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

Get the logger in the grpcMDResponseToFileInfo func, log the stat out… #4309

Merged
merged 1 commit into from
Nov 3, 2023
Merged
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
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