Browse Source

Fix update of `SeaweedFS_volumeServer_volumes` gauge metrics when EC shards are unmounted (#6776)

pull/6777/head
Lisandro Pin 3 days ago
committed by GitHub
parent
commit
dddb0f0ae5
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      weed/storage/erasure_coding/ec_shard.go
  2. 2
      weed/storage/erasure_coding/ec_volume.go

12
weed/storage/erasure_coding/ec_shard.go

@ -45,11 +45,19 @@ func NewEcVolumeShard(diskType types.DiskType, dirname string, collection string
} }
v.ecdFileSize = ecdFi.Size() v.ecdFileSize = ecdFi.Size()
stats.VolumeServerVolumeGauge.WithLabelValues(v.Collection, "ec_shards").Inc()
v.Mount()
return return
} }
func (shard *EcVolumeShard) Mount() {
stats.VolumeServerVolumeGauge.WithLabelValues(shard.Collection, "ec_shards").Inc()
}
func (shard *EcVolumeShard) Unmount() {
stats.VolumeServerVolumeGauge.WithLabelValues(shard.Collection, "ec_shards").Dec()
}
func (shard *EcVolumeShard) Size() int64 { func (shard *EcVolumeShard) Size() int64 {
return shard.ecdFileSize return shard.ecdFileSize
} }
@ -88,8 +96,8 @@ func (shard *EcVolumeShard) Close() {
} }
func (shard *EcVolumeShard) Destroy() { func (shard *EcVolumeShard) Destroy() {
shard.Unmount()
os.Remove(shard.FileName() + ToExt(int(shard.ShardId))) os.Remove(shard.FileName() + ToExt(int(shard.ShardId)))
stats.VolumeServerVolumeGauge.WithLabelValues(shard.Collection, "ec_shards").Dec()
} }
func (shard *EcVolumeShard) ReadAt(buf []byte, offset int64) (int, error) { func (shard *EcVolumeShard) ReadAt(buf []byte, offset int64) (int, error) {

2
weed/storage/erasure_coding/ec_volume.go

@ -111,7 +111,7 @@ func (ev *EcVolume) DeleteEcVolumeShard(shardId ShardId) (ecVolumeShard *EcVolum
} }
ecVolumeShard = ev.Shards[foundPosition] ecVolumeShard = ev.Shards[foundPosition]
ecVolumeShard.Unmount()
ev.Shards = append(ev.Shards[:foundPosition], ev.Shards[foundPosition+1:]...) ev.Shards = append(ev.Shards[:foundPosition], ev.Shards[foundPosition+1:]...)
return ecVolumeShard, true return ecVolumeShard, true
} }

Loading…
Cancel
Save