fix: storageClass shouldn't set the value upon failure (#10271)

master
Harshavardhana 4 years ago committed by GitHub
parent 83a82d818e
commit a4463dd40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      cmd/config/storageclass/storage-class.go

@ -226,7 +226,7 @@ func LookupConfig(kvs config.KVS, drivesPerSet int) (cfg Config, err error) {
cfg.RRS.Parity = defaultRRSParity cfg.RRS.Parity = defaultRRSParity
if err = config.CheckValidKeys(config.StorageClassSubSys, kvs, DefaultKVS); err != nil { if err = config.CheckValidKeys(config.StorageClassSubSys, kvs, DefaultKVS); err != nil {
return cfg, err return Config{}, err
} }
ssc := env.Get(StandardEnv, kvs.Get(ClassStandard)) ssc := env.Get(StandardEnv, kvs.Get(ClassStandard))
@ -235,7 +235,7 @@ func LookupConfig(kvs config.KVS, drivesPerSet int) (cfg Config, err error) {
if ssc != "" { if ssc != "" {
cfg.Standard, err = parseStorageClass(ssc) cfg.Standard, err = parseStorageClass(ssc)
if err != nil { if err != nil {
return cfg, err return Config{}, err
} }
} }
if cfg.Standard.Parity == 0 { if cfg.Standard.Parity == 0 {
@ -245,7 +245,7 @@ func LookupConfig(kvs config.KVS, drivesPerSet int) (cfg Config, err error) {
if rrsc != "" { if rrsc != "" {
cfg.RRS, err = parseStorageClass(rrsc) cfg.RRS, err = parseStorageClass(rrsc)
if err != nil { if err != nil {
return cfg, err return Config{}, err
} }
} }
if cfg.RRS.Parity == 0 { if cfg.RRS.Parity == 0 {
@ -255,7 +255,7 @@ func LookupConfig(kvs config.KVS, drivesPerSet int) (cfg Config, err error) {
// Validation is done after parsing both the storage classes. This is needed because we need one // Validation is done after parsing both the storage classes. This is needed because we need one
// storage class value to deduce the correct value of the other storage class. // storage class value to deduce the correct value of the other storage class.
if err = validateParity(cfg.Standard.Parity, cfg.RRS.Parity, drivesPerSet); err != nil { if err = validateParity(cfg.Standard.Parity, cfg.RRS.Parity, drivesPerSet); err != nil {
return cfg, err return Config{}, err
} }
return cfg, nil return cfg, nil

Loading…
Cancel
Save