Block RPC write operations on volume servers when maintenance mode is enabled (#8115)

* Boostrap persistent state for volume servers.

This PR implements logic load/save persistent state information for storages
associated with volume servers, and reporting state changes back to masters
via heartbeat messages.

More work ensues!

See https://github.com/seaweedfs/seaweedfs/issues/7977 for details.

* Block RPC operations writing to volume servers when maintenance mode is on.
This commit is contained in:
Lisandro Pin
2026-02-02 22:21:02 +01:00
committed by GitHub
parent fca1216f6d
commit 9638d37fe2
12 changed files with 169 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
package weed_server
import (
"fmt"
"net/http"
"sync"
"time"
@@ -171,3 +172,19 @@ func (vs *VolumeServer) Reload() {
v := util.GetViper()
vs.guard.UpdateWhiteList(append(vs.whiteList, util.StringSplit(v.GetString("guard.white_list"), ",")...))
}
// Returns whether a volume server is in maintenance (i.e. read-only) mode.
func (vs *VolumeServer) MaintenanceMode() bool {
if vs.store == nil {
return false
}
return vs.store.State.Pb.GetMaintenance()
}
// Checks if a volume server is in maintenance mode, and returns an error explaining why.
func (vs *VolumeServer) CheckMaintenanceMode() error {
if !vs.MaintenanceMode() {
return nil
}
return fmt.Errorf("volume server %s is in maintenance mode", vs.store.Id)
}