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 a67cecd97..3674b0c78 100644 Binary files a/pkg/services/control/types.pb.go and b/pkg/services/control/types.pb.go differ diff --git a/pkg/services/control/types.proto b/pkg/services/control/types.proto index 4fc3c6069..bbc34c179 100644 --- a/pkg/services/control/types.proto +++ b/pkg/services/control/types.proto @@ -136,6 +136,9 @@ message ShardInfo { // Work mode of the shard. ShardMode mode = 5; + + // Amount of errors occured. + uint32 errorCount = 6; } // Work mode of the shard.