filer: demote client-cancelled directory listing log from error (#11495) (#11496)

* filer: demote client-cancelled directory listing log from error (#11495)

* filer: quote path in canceled listing log

---------

Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
This commit is contained in:
yi111
2026-09-28 14:35:41 +08:00
committed by GitHub
co-authored by Chris Lu
parent f564918685
commit 4fec65d949
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -606,7 +606,7 @@ func (f *Filer) doListDirectoryEntries(ctx context.Context, p util.FullPath, sta
lastFileName, err = f.Store.ListDirectoryPrefixedEntries(ctx, p, startFileName, inclusive, limit, prefix, func(entry *Entry) (bool, error) {
select {
case <-ctx.Done():
glog.Errorf("Context is done.")
glog.V(1).InfofCtx(ctx, "listing %q canceled: %v", p, ctx.Err())
return false, fmt.Errorf("context canceled: %w", ctx.Err())
default:
if entry.TtlSec > 0 && !entry.IsDirectory() {
+20
View File
@@ -104,3 +104,23 @@ func TestExpiredFileIsDeletedOnRead(t *testing.T) {
require.ErrorIs(t, err, filer_pb.ErrNotFound,
"native TTL lookup should remove the expired metadata row")
}
func TestListDirectoryEntriesContextCanceled(t *testing.T) {
f, store := newTestFilerWithStubStore()
ctx := context.Background()
require.NoError(t, store.InsertEntry(ctx, &Entry{
FullPath: util.FullPath("/dir/file1.txt"),
Attr: Attr{Mode: 0o644},
}))
canceledCtx, cancel := context.WithCancel(ctx)
cancel()
_, _, err := f.doListDirectoryEntries(canceledCtx, util.FullPath("/dir"), "", false, 10, "", func(entry *Entry) (bool, error) {
return true, nil
})
require.Error(t, err)
assert.ErrorContains(t, err, "context canceled")
}