fix(filer): apply default disk type after location-prefix resolution in gRPC AssignVolume (#8836)
* fix(filer): apply default disk type after location-prefix resolution in gRPC AssignVolume The gRPC AssignVolume path was applying the filer's default DiskType to the request before calling detectStorageOption. This caused the default to shadow any disk type configured via a filer location-prefix rule, diverging from the HTTP write path which applies the default only when no rule matches. Extract resolveAssignStorageOption to apply the filer default disk type after detectStorageOption, so location-prefix rules take precedence. * fix(filer): apply default disk type after location-prefix resolution in TUS upload path Same class of bug as the gRPC AssignVolume fix: the TUS tusWriteData handler called detectStorageOption0 but never applied the filer's default DiskType when no location-prefix rule matched. This made TUS uploads ignore the -disk flag entirely.
This commit is contained in:
68
weed/server/filer_grpc_server_test.go
Normal file
68
weed/server/filer_grpc_server_test.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package weed_server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/filer"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||
)
|
||||
|
||||
func TestResolveAssignStorageOptionUsesBucketRuleBeforeFilerDiskDefault(t *testing.T) {
|
||||
fc := filer.NewFilerConf()
|
||||
if err := fc.SetLocationConf(&filer_pb.FilerConf_PathConf{
|
||||
LocationPrefix: "/buckets/zot",
|
||||
DiskType: "disk",
|
||||
}); err != nil {
|
||||
t.Fatalf("set location conf: %v", err)
|
||||
}
|
||||
|
||||
fs := &FilerServer{
|
||||
option: &FilerOption{
|
||||
DiskType: "hdd",
|
||||
},
|
||||
filer: &filer.Filer{
|
||||
DirBucketsPath: "/buckets",
|
||||
FilerConf: fc,
|
||||
MaxFilenameLength: 255,
|
||||
},
|
||||
}
|
||||
|
||||
so, err := fs.resolveAssignStorageOption(context.Background(), &filer_pb.AssignVolumeRequest{
|
||||
Path: "/buckets/zot/.uploads/upload-id/0001_part.part",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("resolve assign storage option: %v", err)
|
||||
}
|
||||
|
||||
if got, want := so.Collection, "zot"; got != want {
|
||||
t.Fatalf("collection = %q, want %q", got, want)
|
||||
}
|
||||
if got, want := so.DiskType, "disk"; got != want {
|
||||
t.Fatalf("disk type = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveAssignStorageOptionFallsBackToFilerDiskDefault(t *testing.T) {
|
||||
fs := &FilerServer{
|
||||
option: &FilerOption{
|
||||
DiskType: "hdd",
|
||||
},
|
||||
filer: &filer.Filer{
|
||||
DirBucketsPath: "/buckets",
|
||||
FilerConf: filer.NewFilerConf(),
|
||||
MaxFilenameLength: 255,
|
||||
},
|
||||
}
|
||||
|
||||
so, err := fs.resolveAssignStorageOption(context.Background(), &filer_pb.AssignVolumeRequest{
|
||||
Path: "/tmp/unmatched/file.bin",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("resolve assign storage option: %v", err)
|
||||
}
|
||||
|
||||
if got, want := so.DiskType, "hdd"; got != want {
|
||||
t.Fatalf("disk type = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user