From 46052c61de17484163363979e21b0b150d4c370f Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 17 Nov 2025 21:39:22 -0800 Subject: [PATCH] add ctx to logs, error handling --- weed/filer/cassandra/cassandra_store.go | 6 +++--- weed/filer/cassandra2/cassandra_store.go | 6 +++--- weed/filer/mongodb/mongodb_store.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/weed/filer/cassandra/cassandra_store.go b/weed/filer/cassandra/cassandra_store.go index dfc15b5ac..968a2b3c3 100644 --- a/weed/filer/cassandra/cassandra_store.go +++ b/weed/filer/cassandra/cassandra_store.go @@ -209,8 +209,8 @@ func (store *CassandraStore) ListDirectoryEntries(ctx context.Context, dirPath u resEachEntryFunc, resEachEntryFuncErr := eachEntryFunc(entry) if resEachEntryFuncErr != nil { - err = resEachEntryFuncErr - glog.V(0).Infof("Failed in process eachEntryFnc: %v", err) + err = fmt.Errorf("failed to process eachEntryFunc for entry %q: %w", entry.FullPath, resEachEntryFuncErr) + glog.V(0).InfofCtx(ctx, "failed to process eachEntryFunc for entry %q: %v", entry.FullPath, resEachEntryFuncErr) break } @@ -219,7 +219,7 @@ func (store *CassandraStore) ListDirectoryEntries(ctx context.Context, dirPath u } } if errClose := iter.Close(); errClose != nil { - glog.V(0).Infof("list iterator close: %v", errClose) + glog.V(0).InfofCtx(ctx, "list iterator close: %v", errClose) if err == nil { return lastFileName, errClose } diff --git a/weed/filer/cassandra2/cassandra_store.go b/weed/filer/cassandra2/cassandra_store.go index 8f59f7907..7ce3d32c1 100644 --- a/weed/filer/cassandra2/cassandra_store.go +++ b/weed/filer/cassandra2/cassandra_store.go @@ -209,8 +209,8 @@ func (store *Cassandra2Store) ListDirectoryEntries(ctx context.Context, dirPath resEachEntryFunc, resEachEntryFuncErr := eachEntryFunc(entry) if resEachEntryFuncErr != nil { - err = resEachEntryFuncErr - glog.V(0).Infof("Failed in process eachEntryFnc: %v", err) + err = fmt.Errorf("failed to process eachEntryFunc for entry %q: %w", entry.FullPath, resEachEntryFuncErr) + glog.V(0).InfofCtx(ctx, "failed to process eachEntryFunc for entry %q: %v", entry.FullPath, resEachEntryFuncErr) break } @@ -220,7 +220,7 @@ func (store *Cassandra2Store) ListDirectoryEntries(ctx context.Context, dirPath } if errClose := iter.Close(); errClose != nil { - glog.V(0).Infof("list iterator close: %v", errClose) + glog.V(0).InfofCtx(ctx, "list iterator close: %v", errClose) if err == nil { return lastFileName, errClose } diff --git a/weed/filer/mongodb/mongodb_store.go b/weed/filer/mongodb/mongodb_store.go index 2aa8bf91a..f87878f08 100644 --- a/weed/filer/mongodb/mongodb_store.go +++ b/weed/filer/mongodb/mongodb_store.go @@ -331,7 +331,7 @@ func (store *MongodbStore) ListDirectoryPrefixedEntries(ctx context.Context, dir } if errClose := cur.Close(ctx); errClose != nil { - glog.V(0).InfofCtx(ctx, "list iterator close: %v", err) + glog.V(0).InfofCtx(ctx, "list iterator close: %v", errClose) if err == nil { return lastFileName, errClose }