From aeabb141664d88e59562c9bc32e0733e135a1398 Mon Sep 17 00:00:00 2001 From: nesterfifa Date: Wed, 13 Sep 2023 18:24:57 +0200 Subject: [PATCH] added error node maintenance --- 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 64144b6..fbd70ae 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 90114d7..9fa07a3 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), }, }