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

Commit fca2699

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 <[email protected]>
1 parent 931b7a2 commit fca2699

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
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

glusterd2/brickmux/option.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ func Enabled() (bool, error) {
2727

2828
// validateOption validates brick mux options
2929
func validateOption(option, value string) error {
30+
if option == "cluster.brick-multiplex" {
31+
_, err := options.StringToBoolean(value)
32+
if err != nil {
33+
return err
34+
}
35+
}
3036
return nil
3137
}
3238

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", "0", OptionTypeInt, nil},
3535
"cluster.localtime-logging": {"cluster.localtime-logging", "off", OptionTypeBool, nil},
3636
}

0 commit comments

Comments
 (0)