From e523bde976be45ce70b504a32a156a4f9d8d2c8c Mon Sep 17 00:00:00 2001 From: nesterfifa Date: Wed, 13 Sep 2023 18:24:57 +0200 Subject: [PATCH] [#xxx] client: add error node maintenance Signed-off-by: Viktor Nesterenko --- client/errors.go | 7 +++++++ client/errors_test.go | 3 +++ 2 files changed, 10 insertions(+) diff --git a/client/errors.go b/client/errors.go index 64144b6e..fbd70aee 100644 --- a/client/errors.go +++ b/client/errors.go @@ -61,6 +61,13 @@ func IsErrSessionNotFound(err error) bool { return wrapsErrType[*apistatus.SessionTokenNotFound](err) } +// IsErrMaintenance checks if err corresponds to FrostFS status return +// which tells that node is currently under maintenance. Supports wrapped +// errors. +func IsErrMaintenance(err error) bool { + return wrapsErrType[*apistatus.NodeUnderMaintenance](err) +} + // returns error describing missing field with the given name. func newErrMissingResponseField(name string) error { return fmt.Errorf("missing %s field in the response", name) diff --git a/client/errors_test.go b/client/errors_test.go index 90114d74..9fa07a3b 100644 --- a/client/errors_test.go +++ b/client/errors_test.go @@ -36,6 +36,9 @@ func TestErrors(t *testing.T) { }, { check: client.IsErrSessionNotFound, err: new(apistatus.SessionTokenNotFound), + }, { + check: client.IsErrMaintenance, + err: new(apistatus.NodeUnderMaintenance), }, }