Skip to content

Commit

Permalink
update: enable cli tool reduce volume replicaNum count and set follow…
Browse files Browse the repository at this point in the history
…erRead automiclly

Signed-off-by: leonrayang <[email protected]>
  • Loading branch information
leonrayang committed May 18, 2023
1 parent 78e976c commit 5403f28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 13 additions & 9 deletions cli/cmd/vol.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ func newVolUpdateCmd(client *master.MasterClient) *cobra.Command {
} else {
confirmString.WriteString(fmt.Sprintf(" Capacity : %v GB\n", vv.Capacity))
}

if optReplicaNum != "" {
isChange = true
confirmString.WriteString(fmt.Sprintf(" ReplicaNum : %v -> %v \n", vv.DpReplicaNum, optReplicaNum))
replicaNum, _ := strconv.Atoi(optReplicaNum)
vv.DpReplicaNum = uint8(replicaNum)
} else {
confirmString.WriteString(fmt.Sprintf(" ReplicaNum : %v \n", vv.Description))
}

if optFollowerRead != "" {
isChange = true
var enable bool
Expand All @@ -314,6 +324,9 @@ func newVolUpdateCmd(client *master.MasterClient) *cobra.Command {
confirmString.WriteString(fmt.Sprintf(" Allow follower read : %v -> %v\n", formatEnabledDisabled(vv.FollowerRead), formatEnabledDisabled(enable)))
vv.FollowerRead = enable
} else {
if vv.DpReplicaNum == 1 || vv.DpReplicaNum == 2 {
vv.FollowerRead = true
}
confirmString.WriteString(fmt.Sprintf(" Allow follower read : %v\n", formatEnabledDisabled(vv.FollowerRead)))
}
if optEbsBlkSize > 0 {
Expand Down Expand Up @@ -455,15 +468,6 @@ func newVolUpdateCmd(client *master.MasterClient) *cobra.Command {
formatEnabledDisabled(vv.DpReadOnlyWhenVolFull)))
}

confirmString.WriteString(fmt.Sprintf(" ReplicaNum : %v\n", vv.DpReplicaNum))
if optReplicaNum != "" {
isChange = true
confirmString.WriteString(fmt.Sprintf(" ReplicaNum : %v -> %v \n", vv.DpReplicaNum, optReplicaNum))
replicaNum, _ := strconv.Atoi(optReplicaNum)
vv.DpReplicaNum = uint8(replicaNum)
} else {
confirmString.WriteString(fmt.Sprintf(" ReplicaNum : %v \n", vv.Description))
}
if err != nil {
return
}
Expand Down
6 changes: 3 additions & 3 deletions metanode/partition_fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"os"
"path"
"strconv"
"sync/atomic"
"time"
"io/ioutil"
"os"
"path"

"github.com/cubefs/cubefs/depends/tiglabs/raft"
raftproto "github.com/cubefs/cubefs/depends/tiglabs/raft/proto"
Expand Down

0 comments on commit 5403f28

Please sign in to comment.