fix(filer): apply -filer.disk default to metadata log assigns (#10080)

* fix(filer): apply -filer.disk default to metadata log assigns

Metadata event log writes call operation.Assign directly and used only
FilerConf path rule DiskType. When filer.conf rules were missing or
unmatched, the master received an empty DiskType and grew volumes on the
built-in hdd layout.

Mirror resolveAssignStorageOption: wire FilerOption.DiskType into the
Filer, fall back when the matched path rule has no disk type, and return
the matched rule from resolveMetadataLogAssignDiskType to avoid duplicate
MatchStorageRule lookups.

Co-authored-by: Cursor <cursoragent@cursor.com>

* mini: fall back to -volume.disk for filer default disk type

weed server copies -volume.disk into the filer disk default when
-filer.disk is unset; weed mini did not, so metadata-log assigns sent
an empty disk type on clusters that only tag volumes (e.g. hot/warm).

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
jk2lx
2026-06-24 10:47:11 -07:00
committed by GitHub
co-authored by Cursor Chris Lu
parent d29e6ed98a
commit e1f89f85f2
5 changed files with 77 additions and 2 deletions
+6
View File
@@ -1305,6 +1305,12 @@ func runMini(cmd *Command, args []string) bool {
// on the default 10s waiting for background subscription streams.
miniFilerOptions.gracefulStopTimeout = 1 * time.Second
// Mirror weed server: fall back to -volume.disk so the filer's default
// disk type still tags metadata-log assigns when only -volume.disk is set.
if *miniFilerOptions.diskType == "" && *miniOptions.v.diskType != "" {
miniFilerOptions.diskType = miniOptions.v.diskType
}
// Start all services with proper dependency coordination
// This channel will be closed when all services are fully ready
fmt.Println("\n Starting SeaweedFS Mini ...")
+1
View File
@@ -52,6 +52,7 @@ type Filer struct {
LocalMetaLogBuffer *log_buffer.LogBuffer
metaLogCollection string
metaLogReplication string
DefaultDiskType string
MetaAggregator *MetaAggregator
Signature int32
FilerConf *FilerConf
+13 -2
View File
@@ -48,14 +48,25 @@ func (f *Filer) appendToFile(targetFile string, data []byte) error {
return err
}
// resolveMetadataLogAssignDiskType returns the disk type and matched path rule for
// metadata log volume assigns. Disk type uses the rule when set, otherwise
// Filer.DefaultDiskType (from -filer.disk), mirroring resolveAssignStorageOption.
func (f *Filer) resolveMetadataLogAssignDiskType(targetFile string) (string, *filer_pb.FilerConf_PathConf) {
if f.FilerConf == nil {
return f.DefaultDiskType, &filer_pb.FilerConf_PathConf{}
}
rule := f.FilerConf.MatchStorageRule(targetFile)
return util.Nvl(rule.DiskType, f.DefaultDiskType), rule
}
func (f *Filer) assignAndUpload(targetFile string, data []byte) (*operation.AssignResult, *operation.UploadResult, error) {
// assign a volume location
rule := f.FilerConf.MatchStorageRule(targetFile)
diskType, rule := f.resolveMetadataLogAssignDiskType(targetFile)
assignRequest := &operation.VolumeAssignRequest{
Count: 1,
Collection: util.Nvl(f.metaLogCollection, rule.Collection),
Replication: util.Nvl(f.metaLogReplication, rule.Replication),
DiskType: rule.DiskType,
DiskType: diskType,
WritableVolumeCount: rule.VolumeGrowthCount,
ExpectedDataSize: uint64(len(data)),
}
+56
View File
@@ -0,0 +1,56 @@
package filer
import (
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
)
func TestResolveMetadataLogAssignDiskTypeUsesPathRule(t *testing.T) {
fc := NewFilerConf()
if err := fc.SetLocationConf(&filer_pb.FilerConf_PathConf{
LocationPrefix: "/topics/.system/log",
DiskType: "hot",
}); err != nil {
t.Fatalf("set location conf: %v", err)
}
f := &Filer{
FilerConf: fc,
DefaultDiskType: "hdd",
}
got, rule := f.resolveMetadataLogAssignDiskType("/topics/.system/log/2026-06-23/12-00.1")
if got != "hot" {
t.Fatalf("disk type = %q, want %q", got, "hot")
}
if rule.DiskType != "hot" {
t.Fatalf("rule disk type = %q, want %q", rule.DiskType, "hot")
}
}
func TestResolveMetadataLogAssignDiskTypeFallsBackToFilerDefault(t *testing.T) {
f := &Filer{
FilerConf: NewFilerConf(),
DefaultDiskType: "hot",
}
got, _ := f.resolveMetadataLogAssignDiskType("/topics/.system/log/2026-06-23/12-00.1")
if got != "hot" {
t.Fatalf("disk type = %q, want %q", got, "hot")
}
}
func TestResolveMetadataLogAssignDiskTypeNilFilerConf(t *testing.T) {
f := &Filer{
DefaultDiskType: "hot",
}
got, rule := f.resolveMetadataLogAssignDiskType("/topics/.system/log/2026-06-23/12-00.1")
if got != "hot" {
t.Fatalf("disk type = %q, want %q", got, "hot")
}
if rule == nil {
t.Fatal("expected non-nil empty rule")
}
}
+1
View File
@@ -225,6 +225,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
}
})
fs.filer.Cipher = option.Cipher
fs.filer.DefaultDiskType = option.DiskType
// we do not support IP whitelist right now https://github.com/seaweedfs/seaweedfs/issues/7094
if v.GetString("guard.white_list") != "" {
glog.Warningf("filer: guard.white_list is configured but the IP whitelist feature is currently disabled. See https://github.com/seaweedfs/seaweedfs/issues/7094")