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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user