diff --git a/controllers/pod.go b/controllers/pod.go index 6be93e85f..bf5bb20f4 100644 --- a/controllers/pod.go +++ b/controllers/pod.go @@ -1341,18 +1341,13 @@ func (r *SingleClusterReconciler) handleDynamicConfigChange(rackState *RackState return nil, nil } - dynamic, _ := asconfig.GetDynamic("7.0.0") - r.Log.Info("printing dynamic values", "dynamic", dynamic) + isDynamic := asconfig.IsAllDynamicConfig(specToStatusDiffs, "7.0.0") + if !isDynamic { + r.Log.Info("Static field has been changed, cannot change config dynamically") + return nil, nil + } for diff, value := range specToStatusDiffs { - isDynamic := isFieldDynamic(dynamic, diff) - r.Log.Info("isDynamic", "isDynamic", isDynamic) - - if !isDynamic { - r.Log.Info("Static field has been changed, cannot change config dynamically", "key", diff) - return nil, nil - } - if fmt.Sprintf("%T", value) == "[]string" { if statusValue, ok := flatStatusConf[diff]; ok { statusSet := sets.NewString(statusValue.([]string)...) @@ -1369,32 +1364,3 @@ func (r *SingleClusterReconciler) handleDynamicConfigChange(rackState *RackState return specToStatusDiffs, nil } - -func isFieldDynamic(dynamic map[string]bool, diff string) bool { - var key string - - tokens := strings.Split(diff, ".") - for _, token := range tokens { - if token[0] == '{' && token[len(token)-1] == '}' { - key += "_." - } else { - key = key + token + "." - } - } - - key = strings.TrimSuffix(key, ".") - if strings.Contains(key, "replication-factor") { - return true - } - - // Marking these fields as static as corresponding set-config commands are not straight forward. - staticFields := []string{"rack-id", "report-data-op"} - - for _, field := range staticFields { - if strings.Contains(key, field) { - return false - } - } - - return dynamic[key] -} diff --git a/go.mod b/go.mod index 2c9ad1797..08aeca674 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/aerospike/aerospike-client-go/v6 v6.14.0 - github.com/aerospike/aerospike-management-lib v0.0.0-20231220090750-e26636a42694 + github.com/aerospike/aerospike-management-lib v0.0.0-20231221135621-91f78d86f1ee github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/evanphx/json-patch v4.12.0+incompatible github.com/go-logr/logr v1.2.4 diff --git a/go.sum b/go.sum index 41439000a..8c812d4c5 100644 --- a/go.sum +++ b/go.sum @@ -598,8 +598,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/aerospike/aerospike-client-go/v6 v6.14.0 h1:Z3FcGWJda1sagzdc6Akz4EJ13Pq55Uyn6qtFLrVUDd0= github.com/aerospike/aerospike-client-go/v6 v6.14.0/go.mod h1:/0Wm81GhMqem+9flWcpazPKoRfjFeG6WrQdXGiMNi0A= -github.com/aerospike/aerospike-management-lib v0.0.0-20231220090750-e26636a42694 h1:ge+2XpHQRkxjsGHwouVC3JNv2YuN93w69A85jWPsaig= -github.com/aerospike/aerospike-management-lib v0.0.0-20231220090750-e26636a42694/go.mod h1:qoBjUWFlcE7s7PBSyeEXeEJVypgr0/w5lXGKy7MvKVo= +github.com/aerospike/aerospike-management-lib v0.0.0-20231221135621-91f78d86f1ee h1:QXe1i/k2kidL/nH8h9SEbteOYVKzpvbIK94oHBAEUvk= +github.com/aerospike/aerospike-management-lib v0.0.0-20231221135621-91f78d86f1ee/go.mod h1:qoBjUWFlcE7s7PBSyeEXeEJVypgr0/w5lXGKy7MvKVo= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=