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

Pass logger #4951

Merged
merged 5 commits into from
Nov 18, 2024
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
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def posixfsIntegrationTests(parallelRuns, skipExceptParts = []):
"environment": {
"TEST_SERVER_URL": "http://revad-services:20080",
"OCIS_REVA_DATA_ROOT": "/drone/src/tmp/reva/data/",
"DELETE_USER_DATA_CMD": "bash -cx 'for i in {1..30}; do rm -rf /drone/src/tmp/reva/data/users/* /drone/src/tmp/reva/data/indexes/by-type/* && break || sleep 5; done; sleep 0.1'",
"DELETE_USER_DATA_CMD": "bash -cx 'for i in {1..30}; do rm -rf /drone/src/tmp/reva/data/users/* /drone/src/tmp/reva/data/indexes/by-type/* && break || sleep 5; done; sleep 1'",
"STORAGE_DRIVER": "ocis",
"SKELETON_DIR": "/drone/src/tmp/testing/data/apiSkeleton",
"TEST_WITH_LDAP": "true",
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/pass-initialized-loggers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Pass the initialized logger down the stack

We now make the initialized logger available to grpc services and storage drivers, which allows for easier and more uniform logging.

https://github.com/cs3org/reva/pull/4951
3 changes: 2 additions & 1 deletion internal/grpc/services/applicationauth/applicationauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -73,7 +74,7 @@ func parseConfig(m map[string]interface{}) (*config, error) {
}

// New creates a app auth provider svc
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {

c, err := parseConfig(m)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/juliangruber/go-intersect"
"github.com/mitchellh/mapstructure"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -84,7 +85,7 @@ func parseConfig(m map[string]interface{}) (*config, error) {
}

// New creates a new AppProviderService
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/appregistry/appregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc"
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/rs/zerolog"
)

func init() {
Expand Down Expand Up @@ -64,7 +65,7 @@ func (c *config) init() {
}

// New creates a new StorageRegistryService
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {

c, err := parseConfig(m)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/grpc/services/appregistry/appregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func TestNew(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := New(tt.m, nil)
got, err := New(tt.m, nil, nil)
if err != nil {
assert.Equal(t, tt.wantErr, err.Error())
assert.Nil(t, got)
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/authprovider/authprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -95,7 +96,7 @@ func getAuthManager(manager string, m map[string]map[string]interface{}) (auth.M
}

// New returns a new AuthProviderServiceServer.
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/authregistry/authregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc"
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -66,7 +67,7 @@ func (c *config) init() {
}

// New creates a new AuthRegistry
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/datatx/datatx.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -117,7 +118,7 @@ func parseConfig(m map[string]interface{}) (*config, error) {
}

// New creates a new datatx svc
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {

c, err := parseConfig(m)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/cs3org/reva/v2/pkg/token/manager/registry"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -150,7 +151,7 @@ type svc struct {
// New creates a new gateway svc that acts as a proxy for any grpc operation.
// The gateway is responsible for high-level controls: rate-limiting, coordination between svcs
// like sharing and storage acls, asynchronous transactions, ...
func New(m map[string]interface{}, _ *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, _ *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/groupprovider/groupprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -68,7 +69,7 @@ func getDriver(c *config) (group.Manager, error) {
}

// New returns a new GroupProviderServiceServer.
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/helloworld/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand All @@ -43,7 +44,7 @@ type service struct {
// New returns a new PreferencesServiceServer
// It can be tested like this:
// prototool grpc --address 0.0.0.0:9999 --method 'revad.helloworld.HelloWorldService/Hello' --data '{"name": "Alice"}'
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c := &conf{}
if err := mapstructure.Decode(m, c); err != nil {
err = errors.Wrap(err, "helloworld: error decoding conf")
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/ocmcore/ocmcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc"
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/cs3org/reva/v2/pkg/utils/cfg"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -68,7 +69,7 @@ func getShareRepository(c *config) (share.Repository, error) {
}

// New creates a new ocm core svc.
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/cs3org/reva/v2/pkg/utils/cfg"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -89,7 +90,7 @@ func getInviteRepository(c *config) (invite.Repository, error) {
}

// New creates a new OCM invite manager svc.
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -73,7 +74,7 @@ func parseConfig(m map[string]interface{}) (*config, error) {
}

// New creates a new OCM provider authorizer svc
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {

c, err := parseConfig(m)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/cs3org/reva/v2/pkg/utils/cfg"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -102,7 +103,7 @@ func getShareRepository(c *config) (share.Repository, error) {
}

// New creates a new ocm share provider svc.
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/permissions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand All @@ -55,7 +56,7 @@ type service struct {
}

// New returns a new PermissionsServiceServer
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/preferences/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
)

func init() {
Expand Down Expand Up @@ -70,7 +71,7 @@ func parseConfig(m map[string]interface{}) (*config, error) {
}

// New returns a new PreferencesServiceServer
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"

"github.com/cs3org/reva/v2/pkg/appctx"
Expand Down Expand Up @@ -128,7 +129,7 @@ func parsePasswordPolicy(m map[string]interface{}) (*passwordPolicy, error) {
}

// New creates a new public share provider svc initialized from defaults
func NewDefault(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func NewDefault(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/attribute"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -88,7 +89,7 @@ func parseConfig(m map[string]interface{}) (*config, error) {
}

// New creates a new publicstorageprovider service.
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"

"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/rs/zerolog"
"golang.org/x/sync/errgroup"
"google.golang.org/genproto/protobuf/field_mask"
"google.golang.org/grpc"
Expand Down Expand Up @@ -84,7 +85,7 @@ func (s *service) Register(ss *grpc.Server) {
}

// NewDefault returns a new instance of the SharesStorageProvider service with default dependencies
func NewDefault(m map[string]interface{}, _ *grpc.Server) (rgrpc.Service, error) {
func NewDefault(m map[string]interface{}, _ *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c := &config{}
if err := mapstructure.Decode(m, c); err != nil {
err = errors.Wrap(err, "error decoding conf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ var _ = Describe("Sharesstorageprovider", func() {
"mount_id": "shareprovidermountid",
},
}
s, err := provider.NewDefault(config, nil)
s, err := provider.NewDefault(config, nil, nil)
Expect(err).ToNot(HaveOccurred())
Expect(s).ToNot(BeNil())
})
Expand Down
9 changes: 5 additions & 4 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/attribute"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -165,7 +166,7 @@ func registerMimeTypes(mappingFile string) error {
}

// New creates a new storage provider svc
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, log *zerolog.Logger) (rgrpc.Service, error) {

c, err := parseConfig(m)
if err != nil {
Expand All @@ -174,7 +175,7 @@ func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {

c.init()

fs, err := getFS(c)
fs, err := getFS(c, log)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1276,7 +1277,7 @@ func (s *Service) addMissingStorageProviderID(resourceID *provider.ResourceId, s
}
}

func getFS(c *config) (storage.FS, error) {
func getFS(c *config, log *zerolog.Logger) (storage.FS, error) {
evstream, err := estreamFromConfig(c.Events)
if err != nil {
return nil, err
Expand All @@ -1286,7 +1287,7 @@ func getFS(c *config) (storage.FS, error) {
driverConf := c.Drivers[c.Driver]
driverConf["mount_id"] = c.MountID // pass the mount id to the driver

return f(driverConf, evstream)
return f(driverConf, evstream, log)
}

return nil, errtypes.NotFound("driver not found: " + c.Driver)
Expand Down
3 changes: 2 additions & 1 deletion internal/grpc/services/storageregistry/storageregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storage"
"github.com/cs3org/reva/v2/pkg/storage/registry/registry"
"github.com/mitchellh/mapstructure"
"github.com/rs/zerolog"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -70,7 +71,7 @@ func (c *config) init() {
}

// New creates a new StorageBrokerService
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {
func New(m map[string]interface{}, ss *grpc.Server, _ *zerolog.Logger) (rgrpc.Service, error) {
c, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
Loading
Loading