master: make volume capacity reservation timeout configurable (#11426) (#11497)

* master: make volume capacity reservation timeout configurable (#11426)

* master: expire reservations on reads, fix int timeout units

- AvailableSpaceForReservation now expires reservations too: a node that
  is full of reservations is filtered out before TryReserveCapacity can
  clean them, which stranded expired capacity indefinitely.
- Drop TryReserveCapacityWithTimeout: a per-call timeout lets one caller
  expire another's live reservations, and the Node interface stays
  stable for implementations outside this tree.
- parseReservationTimeout no longer routes integer values through
  GetDuration, which read them as nanoseconds; bare numbers are
  seconds. The 5m fallback is now the shared DefaultReservationTimeout.

---------

Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
This commit is contained in:
yi111andChris Lu authored and GitHub committed 2026-09-28 18:40:11 +08:00
1 parent 4fec65d949
commit 150a69fe11
6 files changed
+235 -14

No files matched your search

+15
View File
@@ -119,6 +119,7 @@ func NewMasterServer(r *mux.Router, option *MasterOption, peers map[string]pb.Se
v.SetDefault("master.volume_growth.copy_3", topology.VolumeGrowStrategy.Copy3Count)
v.SetDefault("master.volume_growth.copy_other", topology.VolumeGrowStrategy.CopyOtherCount)
v.SetDefault("master.volume_growth.threshold", topology.VolumeGrowStrategy.Threshold)
v.SetDefault("master.volume_growth.reservation_timeout", "5m")
v.SetDefault("master.volume_growth.disable", false)
option.VolumeGrowthDisabled = v.GetBool("master.volume_growth.disable")
@@ -127,6 +128,7 @@ func NewMasterServer(r *mux.Router, option *MasterOption, peers map[string]pb.Se
topology.VolumeGrowStrategy.Copy3Count = v.GetUint32("master.volume_growth.copy_3")
topology.VolumeGrowStrategy.CopyOtherCount = v.GetUint32("master.volume_growth.copy_other")
topology.VolumeGrowStrategy.Threshold = v.GetFloat64("master.volume_growth.threshold")
topology.VolumeGrowStrategy.ReservationTimeout = parseReservationTimeout(v)
whiteList := util.StringSplit(v.GetString("guard.white_list"), ",")
var preallocateSize int64
@@ -663,3 +665,16 @@ func (ms *MasterServer) Reload() {
v.GetInt("jwt.signing.read.expires_after_seconds"),
)
}
func parseReservationTimeout(v *util.ViperProxy) time.Duration {
if str := strings.TrimSpace(v.GetString("master.volume_growth.reservation_timeout")); str != "" {
if d, err := time.ParseDuration(str); err == nil && d > 0 {
return d
}
}
// A bare number in the config means seconds; GetDuration would read it as nanoseconds.
if sec := v.GetInt("master.volume_growth.reservation_timeout"); sec > 0 {
return time.Duration(sec) * time.Second
}
return topology.DefaultReservationTimeout
}