Skip to content

Commit

Permalink
Pass an initialized logger to the async propagator
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Dec 4, 2024
1 parent 17f3395 commit 0662c5e
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/storage/fs/posix/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func New(lu node.PathLookup, bs Blobstore, um usermapper.Mapper, trashbin *trash
trashbin: trashbin,
options: o,
idCache: cache,
propagator: propagator.New(lu, &o.Options),
propagator: propagator.New(lu, &o.Options, log),
scanQueue: scanQueue,
scanDebouncer: NewScanDebouncer(o.ScanDebounceDelay, func(item scanItem) {
scanQueue <- item
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream, l
microstore.Table(o.IDCache.Table),
store.DisablePersistence(o.IDCache.DisablePersistence),
store.Authentication(o.IDCache.AuthUsername, o.IDCache.AuthPassword),
))
), log)

permissionsSelector, err := pool.PermissionsSelector(o.PermissionsSVC, pool.WithTLSMode(o.PermTLSMode))
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/storage/utils/decomposedfs/testhelpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,16 @@ func NewTestEnv(config map[string]interface{}) (*TestEnv, error) {
},
)

log := &zerolog.Logger{}
bs := &treemocks.Blobstore{}
tree := tree.New(lu, bs, o, store.Create())
tree := tree.New(lu, bs, o, store.Create(), log)
aspects := aspects.Aspects{
Lookup: lu,
Tree: tree,
Permissions: permissions.NewPermissions(pmock, permissionsSelector),
Trashbin: &decomposedfs.DecomposedfsTrashbin{},
}
fs, err := decomposedfs.New(o, aspects, &zerolog.Logger{})
fs, err := decomposedfs.New(o, aspects, log)
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/storage/utils/decomposedfs/tree/propagator/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"time"

"github.com/cs3org/reva/v2/pkg/appctx"
"github.com/cs3org/reva/v2/pkg/logger"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/lookup"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata/prefixes"
Expand All @@ -49,6 +48,7 @@ type AsyncPropagator struct {
treeTimeAccounting bool
propagationDelay time.Duration
lookup node.PathLookup
log *zerolog.Logger
}

// Change represents a change to the tree
Expand All @@ -58,16 +58,15 @@ type Change struct {
}

// NewAsyncPropagator returns a new AsyncPropagator instance
func NewAsyncPropagator(treeSizeAccounting, treeTimeAccounting bool, o options.AsyncPropagatorOptions, lookup node.PathLookup) AsyncPropagator {
func NewAsyncPropagator(treeSizeAccounting, treeTimeAccounting bool, o options.AsyncPropagatorOptions, lookup node.PathLookup, log *zerolog.Logger) AsyncPropagator {
p := AsyncPropagator{
treeSizeAccounting: treeSizeAccounting,
treeTimeAccounting: treeTimeAccounting,
propagationDelay: o.PropagationDelay,
lookup: lookup,
log: log,
}

log := logger.New()

log.Info().Msg("async propagator starting up...")

// spawn a goroutine that watches for stale .processing dirs and fixes them
Expand Down
5 changes: 3 additions & 2 deletions pkg/storage/utils/decomposedfs/tree/propagator/propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/options"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)
Expand All @@ -44,10 +45,10 @@ type Propagator interface {
Propagate(ctx context.Context, node *node.Node, sizediff int64) error
}

func New(lookup node.PathLookup, o *options.Options) Propagator {
func New(lookup node.PathLookup, o *options.Options, log *zerolog.Logger) Propagator {
switch o.Propagator {
case "async":
return NewAsyncPropagator(o.TreeSizeAccounting, o.TreeTimeAccounting, o.AsyncPropagatorOptions, lookup)
return NewAsyncPropagator(o.TreeSizeAccounting, o.TreeTimeAccounting, o.AsyncPropagatorOptions, lookup, log)
default:
return NewSyncPropagator(o.TreeSizeAccounting, o.TreeTimeAccounting, lookup)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/storage/utils/decomposedfs/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"go-micro.dev/v4/store"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -76,13 +77,13 @@ type Tree struct {
type PermissionCheckFunc func(rp *provider.ResourcePermissions) bool

// New returns a new instance of Tree
func New(lu node.PathLookup, bs Blobstore, o *options.Options, cache store.Store) *Tree {
func New(lu node.PathLookup, bs Blobstore, o *options.Options, cache store.Store, log *zerolog.Logger) *Tree {
return &Tree{
lookup: lu,
blobstore: bs,
options: o,
idCache: cache,
propagator: propagator.New(lu, o),
propagator: propagator.New(lu, o, log),
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/utils/decomposedfs/upload/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/options"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/timemanager"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree"
"github.com/rs/zerolog"
)

// TestInitNewNode calls greetings.initNewNode
Expand All @@ -24,7 +25,7 @@ func TestInitNewNode(t *testing.T) {
root := t.TempDir()

lookup := lookup.New(metadata.NewMessagePackBackend(root, cache.Config{}), &options.Options{Root: root}, &timemanager.Manager{})
tp := tree.New(lookup, nil, &options.Options{}, nil)
tp := tree.New(lookup, nil, &options.Options{}, nil, &zerolog.Logger{})

aspects := aspects.Aspects{
Lookup: lookup,
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/upload_async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ var _ = Describe("Async file uploads", Ordered, func() {

// setup fs
pub, con = make(chan interface{}), make(chan interface{})
tree := tree.New(lu, bs, o, store.Create())
tree := tree.New(lu, bs, o, store.Create(), &zerolog.Logger{})

aspects := aspects.Aspects{
Lookup: lu,
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ var _ = Describe("File uploads", func() {
AddGrant: true,
}, nil).Times(1)
var err error
tree := tree.New(lu, bs, o, store.Create())
tree := tree.New(lu, bs, o, store.Create(), &zerolog.Logger{})

aspects := aspects.Aspects{
Lookup: lu,
Expand Down

0 comments on commit 0662c5e

Please sign in to comment.