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

Init time logger for eosgrpc storage driver #4311

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions changelog/unreleased/init-logger-eosgrpc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Init time logger for eosgrpc storage driver

Before the `eosgrpc` driver was using a custom logger.
Now that the reva logger is available at init time,
the driver will use this.

https://github.com/cs3org/reva/pull/4311
15 changes: 7 additions & 8 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import (
"github.com/cs3org/reva/pkg/eosclient"
erpc "github.com/cs3org/reva/pkg/eosclient/eosgrpc/eos_grpc"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/logger"
"github.com/cs3org/reva/pkg/storage/utils/acl"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand Down Expand Up @@ -138,8 +138,7 @@ type Client struct {
}

// Create and connect a grpc eos Client.
func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) {
log := appctx.GetLogger(ctx)
func newgrpc(ctx context.Context, log *zerolog.Logger, opt *Options) (erpc.EosClient, error) {
log.Info().Str("Setting up GRPC towards ", "'"+opt.GrpcURI+"'").Msg("")

conn, err := grpc.Dial(opt.GrpcURI, grpc.WithTransportCredentials(insecure.NewCredentials()))
Expand Down Expand Up @@ -168,18 +167,18 @@ func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) {
}

// New creates a new client with the given options.
func New(opt *Options, httpOpts *HTTPOptions) (*Client, error) {
tlog := logger.New().With().Int("pid", os.Getpid()).Logger()
tlog.Debug().Str("Creating new eosgrpc client. opt: ", "'"+fmt.Sprintf("%#v", opt)+"' ").Msg("")
func New(ctx context.Context, opt *Options, httpOpts *HTTPOptions) (*Client, error) {
log := appctx.GetLogger(ctx)

log.Debug().Str("Creating new eosgrpc client. opt: ", "'"+fmt.Sprintf("%#v", opt)+"' ").Msg("")

opt.init()
httpcl, err := NewEOSHTTPClient(httpOpts)
if err != nil {
return nil, err
}

tctx := appctx.WithLogger(context.Background(), &tlog)
cl, err := newgrpc(tctx, opt)
cl, err := newgrpc(ctx, log, opt)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func NewEOSFS(ctx context.Context, c *Config) (storage.FS, error) {
ClientCAFiles: c.ClientCAFiles,
Authkey: c.HTTPSAuthkey,
}
eosClient, err = eosgrpc.New(eosClientOpts, eosHTTPOpts)
eosClient, err = eosgrpc.New(ctx, eosClientOpts, eosHTTPOpts)
} else {
eosClientOpts := &eosbinary.Options{
XrdcopyBinary: c.XrdcopyBinary,
Expand Down