From f0c86baa6cd7314f3a562bbc7c1535bd81269d70 Mon Sep 17 00:00:00 2001 From: Abhisek Dwivedi Date: Mon, 6 Jan 2025 14:46:53 +0530 Subject: [PATCH] KO-364: Handle special bool fields (#65) * Updating the enable-benchmarks-* fields to align with changes in server version 6.1, as they are no longer treated as special boolean fields. --------- Co-authored-by: Tanmay Jain --- asconfig/conffilewriter.go | 18 ++++++++---------- asconfig/utils.go | 17 ++++++++--------- deployment/strong_consistency.go | 14 ++------------ utils.go | 11 +++++++++++ 4 files changed, 29 insertions(+), 31 deletions(-) diff --git a/asconfig/conffilewriter.go b/asconfig/conffilewriter.go index 6df0b37..196b0bc 100644 --- a/asconfig/conffilewriter.go +++ b/asconfig/conffilewriter.go @@ -197,24 +197,22 @@ func writeListField( } } -func writeSpecialBoolField(buf *bytes.Buffer, key string, indent int) { - buf.WriteString(indentString(indent) + key + "\n") -} - func writeField(buf *bytes.Buffer, key, value string, indent int) { switch { case isFormField(key): return - case isEmptyField(key, value): return - + // Skipping the writing of benchmark configurations when their corresponding value is false. + // In server versions without the fix for AER-6767 (https://aerospike.atlassian.net/browse/AER-6767), + // the presence of these fields implied that the corresponding benchmark was enabled, + // even if the value was explicitly set to false. + // To prevent such configurations from being misinterpreted as enabled, + // benchmark configurations with a value of false are now omitted entirely. case isSpecialBoolField(key): - if strings.EqualFold(value, "true") { - writeSpecialBoolField(buf, key, indent) + if strings.EqualFold(value, "false") { + return } - - return } buf.WriteString(indentString(indent) + key + " " + value + "\n") diff --git a/asconfig/utils.go b/asconfig/utils.go index 47ed576..6111960 100644 --- a/asconfig/utils.go +++ b/asconfig/utils.go @@ -29,6 +29,13 @@ const ( NONE sysproptype = "NONE" ) +var BenchmarkConfigs = []string{ + "enable-benchmarks-batch-sub", "enable-benchmarks-read", + "enable-benchmarks-udf", "enable-benchmarks-write", + "enable-benchmarks-udf-sub", "enable-benchmarks-storage", + "enable-benchmarks-fabric", "enable-benchmarks-ops-sub", +} + var portRegex = regexp.MustCompile("port") type humanize func(string) (uint64, error) @@ -683,15 +690,7 @@ func isSpecialOrNormalBoolField(key string) bool { // config file is true/false. // e.g. namespace and storage level benchmark fields func isSpecialBoolField(key string) bool { - switch key { - case "enable-benchmarks-batch-sub", "enable-benchmarks-read", - "enable-benchmarks-udf", "enable-benchmarks-write", - "enable-benchmarks-udf-sub", "enable-benchmarks-storage": - return true - - default: - return false - } + return lib.ContainsString(BenchmarkConfigs, key) } // isSpecialStringField returns true if the passed key diff --git a/deployment/strong_consistency.go b/deployment/strong_consistency.go index 52a7570..02b93cf 100644 --- a/deployment/strong_consistency.go +++ b/deployment/strong_consistency.go @@ -9,6 +9,7 @@ import ( "github.com/go-logr/logr" as "github.com/aerospike/aerospike-client-go/v7" + lib "github.com/aerospike/aerospike-management-lib" ) const ( @@ -92,7 +93,7 @@ func setFilteredRosterNodes(clHost *host, scNs string, rosterNodes map[string]st for _, obn := range observedNodesList { // nodeRoster: nodeID + "@" + rackID obnNodeID := strings.Split(obn, "@")[0] - if !containsString(rosterNodeBlockList, obnNodeID) { + if !lib.ContainsString(rosterNodeBlockList, obnNodeID) { newObservedNodesList = append(newObservedNodesList, obn) } } @@ -324,17 +325,6 @@ func getNamespaces(clHost *host) ([]string, error) { return nil, nil } -// ContainsString check whether list contains given string -func containsString(list []string, ele string) bool { - for _, listEle := range list { - if strings.EqualFold(ele, listEle) { - return true - } - } - - return false -} - func isNodeInRoster(clHost *host, ns string) (bool, error) { nodeID, err := getNodeID(clHost) if err != nil { diff --git a/utils.go b/utils.go index fb3c415..b9fbd3c 100644 --- a/utils.go +++ b/utils.go @@ -119,3 +119,14 @@ func CompareVersionsIgnoreRevision(version1, version2 string) (int, error) { return 0, nil } + +// ContainsString check whether list contains given string +func ContainsString(list []string, ele string) bool { + for _, listEle := range list { + if strings.EqualFold(ele, listEle) { + return true + } + } + + return false +}