SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
volume server: fill in ModifiedAtSecond on the /status volume list (#10351)
Chris Lu1f8d0a9ccfa0
diff --git a/weed/storage/store.go b/weed/storage/store.goindex dfaee90080..8ef3009b98 100644--- a/weed/storage/store.go+++ b/weed/storage/store.go@@ -389,6 +389,11 @@ func collectStatForOneVolume(vid needle.VolumeId, v *Volume) (s *VolumeInfo) {s.DeleteCount = v.nm.DeletedCount()s.DeletedByteCount = v.nm.DeletedSize()s.Size = v.nm.ContentSize()+ if v.DataBackend != nil {+ if _, modTime, e := v.DataBackend.GetStat(); e == nil {+ s.ModifiedAtSecond = modTime.Unix()+ }+ }return}diff --git a/weed/storage/store_status_test.go b/weed/storage/store_status_test.gonew file mode 100644index 0000000000..54558616a9--- /dev/null+++ b/weed/storage/store_status_test.go@@ -0,0 +1,31 @@+package storage++import (+ "testing"++ "github.com/seaweedfs/seaweedfs/weed/storage/needle"+ "github.com/seaweedfs/seaweedfs/weed/storage/super_block"+ "github.com/seaweedfs/seaweedfs/weed/storage/types"+)++// The /status handler builds VolumeInfo via collectStatForOneVolume, which+// used to leave ModifiedAtSecond at 0; only the heartbeat path filled it in.+func TestCollectStatForOneVolumeModifiedAtSecond(t *testing.T) {+ dir := t.TempDir()++ v, err := NewVolume(dir, dir, "", 1, NeedleMapInMemory, &super_block.ReplicaPlacement{}, &needle.TTL{}, 0, needle.GetCurrentVersion(), 0, 0)+ if err != nil {+ t.Fatalf("create volume: %v", err)+ }+ defer v.Close()+ v.location = &DiskLocation{Directory: dir, DiskType: types.HardDriveType}++ if _, _, _, err := v.writeNeedle2(newRandomNeedle(1), true, false); err != nil {+ t.Fatalf("write: %v", err)+ }++ s := collectStatForOneVolume(v.Id, v)+ if s.ModifiedAtSecond <= 0 {+ t.Fatalf("ModifiedAtSecond = %d, want > 0", s.ModifiedAtSecond)+ }+}