[#1143] shard: Introduce explicit Degraded mode

`Degraded` mode is set automatically after error counter is over the
threshold. `ReadOnly` mode can still be set by an administrator.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-03-17 14:55:25 +03:00 committed by fyrchik
parent 9eb70c18c3
commit 6472a170eb
21 changed files with 62 additions and 24 deletions

View file

@ -78,6 +78,7 @@ const (
shardModeReadOnly = "read-only"
shardModeReadWrite = "read-write"
shardModeDegraded = "degraded"
)
const (
@ -124,9 +125,10 @@ func initControlSetShardModeCmd() {
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
flags.StringVarP(&shardID, shardIDFlag, "", "", "ID of the shard in base58 encoding")
flags.StringVarP(&shardMode, shardModeFlag, "", "",
fmt.Sprintf("new shard mode keyword ('%s', '%s')",
fmt.Sprintf("new shard mode keyword ('%s', '%s', '%s')",
shardModeReadWrite,
shardModeReadOnly,
shardModeDegraded,
),
)
flags.Bool(shardClearErrorsFlag, false, "Set shard error count to 0")
@ -490,6 +492,8 @@ func prettyPrintShards(cmd *cobra.Command, ii []*control.ShardInfo) {
mode = "read-write"
case control.ShardMode_READ_ONLY:
mode = "read-only"
case control.ShardMode_DEGRADED:
mode = "degraded"
default:
mode = "unknown"
}
@ -526,6 +530,8 @@ func setShardMode(cmd *cobra.Command, _ []string) {
mode = control.ShardMode_READ_WRITE
case shardModeReadOnly:
mode = control.ShardMode_READ_ONLY
case shardModeDegraded:
mode = control.ShardMode_DEGRADED
}
req := new(control.SetShardModeRequest)