From ed50cf6207dc6bfdedffce87438b577cf2b4bc49 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 31 Jan 2022 18:23:19 +0300 Subject: [PATCH] [#1118] services/control: return error counter in `ListShards` Signed-off-by: Evgenii Stratonikov --- cmd/neofs-cli/modules/control.go | 3 ++- pkg/local_object_storage/engine/info.go | 4 +++- pkg/local_object_storage/shard/info.go | 3 +++ pkg/services/control/server/list_shards.go | 1 + pkg/services/control/types.go | 16 +++++++++++++++- pkg/services/control/types.pb.go | Bin 25708 -> 26126 bytes pkg/services/control/types.proto | 3 +++ 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/cmd/neofs-cli/modules/control.go b/cmd/neofs-cli/modules/control.go index 146f21b17..ff82bdd1e 100644 --- a/cmd/neofs-cli/modules/control.go +++ b/cmd/neofs-cli/modules/control.go @@ -479,7 +479,8 @@ func prettyPrintShards(cmd *cobra.Command, ii []*control.ShardInfo) { cmd.Printf("Shard %s:\nMode: %s\n"+ pathPrinter("Metabase", i.GetMetabasePath())+ pathPrinter("Blobstor", i.GetBlobstorPath())+ - pathPrinter("Write-cache", i.GetWritecachePath())+"\n", + pathPrinter("Write-cache", i.GetWritecachePath())+ + fmt.Sprintf("Error count: %d\n", i.GetErrorCount()), base58.Encode(i.Shard_ID), mode, ) diff --git a/pkg/local_object_storage/engine/info.go b/pkg/local_object_storage/engine/info.go index 16683fb97..396663b4d 100644 --- a/pkg/local_object_storage/engine/info.go +++ b/pkg/local_object_storage/engine/info.go @@ -17,7 +17,9 @@ func (e *StorageEngine) DumpInfo() (i Info) { i.Shards = make([]shard.Info, 0, len(e.shards)) for _, sh := range e.shards { - i.Shards = append(i.Shards, sh.DumpInfo()) + info := sh.DumpInfo() + info.ErrorCount = sh.errorCount.Load() + i.Shards = append(i.Shards, info) } return diff --git a/pkg/local_object_storage/shard/info.go b/pkg/local_object_storage/shard/info.go index 962dca29b..fbc26e519 100644 --- a/pkg/local_object_storage/shard/info.go +++ b/pkg/local_object_storage/shard/info.go @@ -25,6 +25,9 @@ type Info struct { // Weight parameters of the shard. WeightValues WeightValues + + // ErrorCount contains amount of errors occurred in shard operations. + ErrorCount uint32 } // DumpInfo returns information about the Shard. diff --git a/pkg/services/control/server/list_shards.go b/pkg/services/control/server/list_shards.go index 45e39712e..b02a45633 100644 --- a/pkg/services/control/server/list_shards.go +++ b/pkg/services/control/server/list_shards.go @@ -45,6 +45,7 @@ func (s *Server) ListShards(_ context.Context, req *control.ListShardsRequest) ( } si.SetMode(mode) + si.SetErrorCount(sh.ErrorCount) shardInfos = append(shardInfos, si) } diff --git a/pkg/services/control/types.go b/pkg/services/control/types.go index af16313f2..9f3c374e0 100644 --- a/pkg/services/control/types.go +++ b/pkg/services/control/types.go @@ -342,6 +342,11 @@ func (x *ShardInfo) SetMode(v ShardMode) { x.Mode = v } +// SetErrorCount sets shard's error counter. +func (x *ShardInfo) SetErrorCount(count uint32) { + x.ErrorCount = count +} + const ( _ = iota shardInfoIDFNum @@ -349,6 +354,7 @@ const ( shardInfoBlobstorFNum shardInfoWriteCacheFNum shardInfoModeFNum + shardInfoErrorCountFNum ) // StableSize returns binary size of shard information @@ -367,6 +373,7 @@ func (x *ShardInfo) StableSize() int { size += proto.StringSize(shardInfoBlobstorFNum, x.BlobstorPath) size += proto.StringSize(shardInfoWriteCacheFNum, x.WritecachePath) size += proto.EnumSize(shardInfoModeFNum, int32(x.Mode)) + size += proto.UInt32Size(shardInfoErrorCountFNum, x.ErrorCount) return size } @@ -422,7 +429,14 @@ func (x *ShardInfo) StableMarshal(buf []byte) ([]byte, error) { offset += n - _, err = proto.EnumMarshal(shardInfoModeFNum, buf[offset:], int32(x.Mode)) + n, err = proto.EnumMarshal(shardInfoModeFNum, buf[offset:], int32(x.Mode)) + if err != nil { + return nil, err + } + + offset += n + + _, err = proto.EnumMarshal(shardInfoErrorCountFNum, buf[offset:], int32(x.ErrorCount)) if err != nil { return nil, err } diff --git a/pkg/services/control/types.pb.go b/pkg/services/control/types.pb.go index a67cecd97ca0d6349eae50d9183b17c5541ad536..3674b0c782ddc5bc67a01dbe9b77b4ffc3703a01 100644 GIT binary patch delta 407 zcmaEJg0b%mm>7fDP!X_7vs4`} zPM`)8kc6QHh%_(*kwyk!wjr1e5l;cJO~FRnL+m8dHn0sa>wspMn`~zC%@PLyjGKCb delta 39 vcmeA>!}#U|