Skip to content
This repository was archived by the owner on Mar 26, 2020. It is now read-only.

Commit ebb281e

Browse files
committed
Add validation to setting cluster.brick-multiplex cluster option.
Discard all garbage strings and allow only "on", "yes", "true", "enable", "1" OR "off", "no", "false", "disable", "0" Signed-off-by: Vishal Pandey <vpandey@redhat.com>
1 parent 5814720 commit ebb281e

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

e2e/brickmux_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ func TestBrickMux(t *testing.T) {
2727
r.Nil(err)
2828
r.NotNil(client)
2929

30-
// Turn on brick mux cluster option
3130
optReq := api.ClusterOptionReq{
32-
Options: map[string]string{"cluster.brick-multiplex": "on"},
31+
Options: map[string]string{"cluster.brick-multiplex": "invalidValue"},
3332
}
3433
err = client.ClusterOptionSet(optReq)
35-
r.Nil(err)
34+
r.NotNil(err)
3635

3736
// Create a 1 x 3 volume
3837
var brickPaths []string

e2e/glustershd_test.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func testSelfHeal(t *testing.T, tc *testCluster) {
3030
//glustershd pid file path
3131
pidpath := path.Join(tc.gds[0].Rundir, "glustershd.pid")
3232

33-
for i := 1; i <= 2; i++ {
33+
for i := 1; i <= 4; i++ {
3434
brickPath := testTempDir(t, "brick")
3535
brickPaths = append(brickPaths, brickPath)
3636
}
@@ -39,11 +39,12 @@ func testSelfHeal(t *testing.T, tc *testCluster) {
3939
Name: volname,
4040
Subvols: []api.SubvolReq{
4141
{
42-
ReplicaCount: 2,
42+
ReplicaCount: 3,
4343
Type: "replicate",
4444
Bricks: []api.BrickReq{
4545
{PeerID: tc.gds[0].PeerID(), Path: brickPaths[0]},
46-
{PeerID: tc.gds[0].PeerID(), Path: brickPaths[1]},
46+
{PeerID: tc.gds[1].PeerID(), Path: brickPaths[1]},
47+
{PeerID: tc.gds[2].PeerID(), Path: brickPaths[2]},
4748
},
4849
},
4950
},
@@ -72,14 +73,6 @@ func testSelfHeal(t *testing.T, tc *testCluster) {
7273
getBricksStatus, err := client.BricksStatus(volname)
7374
r.Nil(err, fmt.Sprintf("brick status operation failed: %s", err))
7475
count := 0
75-
for brick := range getBricksStatus {
76-
if getBricksStatus[brick].Info.PeerID.String() == tc.gds[0].PeerID() {
77-
count++
78-
}
79-
}
80-
81-
r.Equal(count, 2)
82-
8376
for brick := range getBricksStatus {
8477
if getBricksStatus[brick].Info.PeerID.String() == tc.gds[0].PeerID() {
8578
process, err := os.FindProcess(getBricksStatus[brick].Pid)

e2e/volume_ops_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestVolume(t *testing.T) {
3838

3939
r := require.New(t)
4040

41-
tc, err := setupCluster(t, "./config/1.toml", "./config/2.toml")
41+
tc, err := setupCluster(t, "./config/1.toml", "./config/2.toml", "./config/3.toml")
4242
r.Nil(err)
4343
defer teardownCluster(tc)
4444

glusterd2/brickmux/option.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ func getMaxBricksPerProcess() (int, error) {
4545

4646
// validateOption validates brick mux options
4747
func validateOption(option, value string) error {
48+
if option == "cluster.brick-multiplex" {
49+
_, err := options.StringToBoolean(value)
50+
if err != nil {
51+
return err
52+
}
53+
}
4854
if option == "cluster.max-bricks-per-process" {
4955
_, err := strconv.Atoi(value)
5056
if err != nil {
5157
return errors.ErrInvalidIntValue
5258
}
5359
}
54-
5560
return nil
5661
}
5762

glusterd2/options/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var ClusterOptMap = map[string]*ClusterOption{
3030
"cluster.shared-storage": {"cluster.shared-storage", "off", OptionTypeBool, nil},
3131
"cluster.op-version": {"cluster.op-version", strconv.Itoa(gdctx.OpVersion), OptionTypeInt, nil},
3232
"cluster.max-op-version": {"cluster.max-op-version", strconv.Itoa(gdctx.OpVersion), OptionTypeInt, nil},
33-
"cluster.brick-multiplex": {"cluster.brick-multiplex", "off", OptionTypeBool, nil},
33+
"cluster.brick-multiplex": {"cluster.brick-multiplex", "on", OptionTypeBool, nil},
3434
"cluster.max-bricks-per-process": {"cluster.max-bricks-per-process", "250", OptionTypeInt, nil},
3535
"cluster.localtime-logging": {"cluster.localtime-logging", "off", OptionTypeBool, nil},
3636
}

0 commit comments

Comments
 (0)