forked from TrueCloudLab/frostfs-node
[#1916] control: Check maintenance allowance on Control server
In previous implementation turning to maintenance mode using NeoFS CLI required NeoFS API endpoint. This was not convenient from the user perspective. It's worth to move networks settings' check to the server side. Add `force_maintenance` field to `SetNetmapStatusRequest.Body` message of Control API. Add `force` flag to `neofs-cli control set-status` command which sets corresponding field in the requests body if status is `maintenance`. Force flag is ignored for any other status. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
This commit is contained in:
parent
c50603494b
commit
60e9de8d63
10 changed files with 346 additions and 272 deletions
|
@ -17,8 +17,23 @@ func (s *Server) SetNetmapStatus(ctx context.Context, req *control.SetNetmapStat
|
|||
return nil, status.Error(codes.PermissionDenied, err.Error())
|
||||
}
|
||||
|
||||
// set node status
|
||||
if err := s.nodeState.SetNetmapStatus(req.GetBody().GetStatus()); err != nil {
|
||||
var err error
|
||||
bodyReq := req.GetBody()
|
||||
st := bodyReq.GetStatus()
|
||||
force := bodyReq.GetForceMaintenance()
|
||||
|
||||
if force {
|
||||
if st != control.NetmapStatus_MAINTENANCE {
|
||||
return nil, status.Errorf(codes.InvalidArgument,
|
||||
"force_maintenance MUST be set for %s status only", control.NetmapStatus_MAINTENANCE)
|
||||
}
|
||||
|
||||
err = s.nodeState.ForceMaintenance()
|
||||
} else {
|
||||
err = s.nodeState.SetNetmapStatus(st)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Aborted, err.Error())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue