rename: report a missing source as ENOENT

A rename whose source is absent fails with the store's "no entry is found"
error, which neither the filer's errno mapping nor the mount's message
mapping recognized, so the client got EIO instead of ENOENT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-11-27 12:35:20 -08:00
1 parent bbacaa231e
commit 4f3d262984
3 files changed
+21 -2

No files matched your search

+1 -1
View File
@@ -462,7 +462,7 @@ func (wfs *WFS) Rename(cancel <-chan struct{}, in *fuse.RenameIn, oldName string
// instead of raw errno to stay portable across platforms (errno
// numeric values differ between Linux and macOS).
msg := err.Error()
if strings.Contains(msg, "not found") {
if strings.Contains(msg, "not found") || strings.Contains(msg, filer_pb.ErrNotFound.Error()) {
return fuse.Status(syscall.ENOENT)
} else if strings.Contains(msg, "not empty") {
return fuse.Status(syscall.ENOTEMPTY)
@@ -3,11 +3,13 @@ package weed_server
import (
"context"
"strings"
"syscall"
"testing"
"time"
"github.com/seaweedfs/seaweedfs/weed/pb"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
)
// A file created with IF_NOT_EXISTS lands on the write owner. A rename sent
@@ -92,6 +94,23 @@ func TestStreamRenameEntryMissOnOwnerNotFound(t *testing.T) {
}
}
// A missing source is ENOENT to the client, whether the miss is this
// filer's or the owner's relayed over gRPC.
func TestRenameErrnoMissingSource(t *testing.T) {
c := newTwoFilers(t)
separateStores(c)
sharedWriteRing(c)
for _, p := range []string{string(c.keyOwnedBy(t, c.addrA, c.addrA)), string(c.keyOwnedBy(t, c.addrB, c.addrB))} {
dir, name := util.FullPath(p).DirAndName()
err := c.fsA.StreamRenameEntry(&filer_pb.StreamRenameEntryRequest{
OldDirectory: dir, OldName: name, NewDirectory: dir, NewName: name + ".renamed",
}, &renameTestStream{})
if got := renameErrno(err); got != int32(syscall.ENOENT) {
t.Fatalf("rename of absent %s: errno %d for %v, want ENOENT", p, got, err)
}
}
}
// While B's ring still gives the path to A, B refuses the rename A forwards
// rather than answer for a store the creates may not have reached.
func TestForwardedStreamRenameEntryRefusedByNonOwner(t *testing.T) {
@@ -248,7 +248,7 @@ func (p *renameStreamProxy) SetTrailer(md metadata.MD) { p.parent.stream.S
func renameErrno(err error) int32 {
msg := err.Error()
switch {
case strings.Contains(msg, "not found"):
case strings.Contains(msg, "not found"), strings.Contains(msg, filer_pb.ErrNotFound.Error()):
return int32(syscall.ENOENT)
case strings.Contains(msg, "not empty"):
return int32(syscall.ENOTEMPTY)