Guard pause/resume against disabled backends; clean up CLI errors

- PauseBackend and ResumeBackend return an error (not bool) when the
  backend is disabled, preventing an inconsistent state where the
  health state says "paused" but enabled=false.
- DisableBackend and EnableBackend now log uniform backend-transition
  lines with from/to instead of separate backend-disable/backend-enable
  messages.
- CLI errors strip gRPC boilerplate ("rpc error: code = ... desc = ")
  and display the server message in red (when color is enabled). Both
  the interactive shell and one-shot mode use the same formatError path.
This commit is contained in:
2026-04-11 21:19:05 +02:00
parent 1815675fb6
commit 74448cf6d0
6 changed files with 68 additions and 23 deletions

View File

@@ -64,18 +64,18 @@ func (s *Server) GetBackend(_ context.Context, req *GetBackendRequest) (*Backend
// PauseBackend pauses health checking for a backend by name.
func (s *Server) PauseBackend(_ context.Context, req *BackendRequest) (*BackendInfo, error) {
b, ok := s.checker.PauseBackend(req.Name)
if !ok {
return nil, status.Errorf(codes.NotFound, "backend %q not found", req.Name)
b, err := s.checker.PauseBackend(req.Name)
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition, "%v", err)
}
return backendToProto(b), nil
}
// ResumeBackend resumes health checking for a backend by name.
func (s *Server) ResumeBackend(_ context.Context, req *BackendRequest) (*BackendInfo, error) {
b, ok := s.checker.ResumeBackend(req.Name)
if !ok {
return nil, status.Errorf(codes.NotFound, "backend %q not found", req.Name)
b, err := s.checker.ResumeBackend(req.Name)
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition, "%v", err)
}
return backendToProto(b), nil
}