Skip to content

Commit

Permalink
KO-364: Handle special bool fields (#65)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
abhishekdwivedi3060 and tanmayja authored Jan 6, 2025
1 parent 78e1af2 commit f0c86ba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
18 changes: 8 additions & 10 deletions asconfig/conffilewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
17 changes: 8 additions & 9 deletions asconfig/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions deployment/strong_consistency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit f0c86ba

Please sign in to comment.