From 4a31423b91e73eb618c1e8b566da104a672d91b8 Mon Sep 17 00:00:00 2001 From: Tanmay Jain Date: Wed, 27 Dec 2023 20:37:24 +0530 Subject: [PATCH] version 2, handing diff in more detailed way --- controllers/aero_info_calls.go | 2 +- controllers/pod.go | 24 +++++------------------- controllers/rack.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/controllers/aero_info_calls.go b/controllers/aero_info_calls.go index e27057ec4..aa648118a 100644 --- a/controllers/aero_info_calls.go +++ b/controllers/aero_info_calls.go @@ -299,7 +299,7 @@ func (r *SingleClusterReconciler) setMigrateFillDelay( func (r *SingleClusterReconciler) setDynamicConfig( policy *as.ClientPolicy, - diffs map[string]interface{}, pods []*corev1.Pod, ignorablePodNames sets.Set[string], + diffs map[string]map[string]interface{}, pods []*corev1.Pod, ignorablePodNames sets.Set[string], ) reconcileResult { // This doesn't make actual connection, only objects having connection info are created allHostConns, err := r.newAllHostConnWithOption(ignorablePodNames) diff --git a/controllers/pod.go b/controllers/pod.go index bf5bb20f4..e054e7dfa 100644 --- a/controllers/pod.go +++ b/controllers/pod.go @@ -60,7 +60,7 @@ func mergeRestartType(current, incoming RestartType) RestartType { // Fetching RestartType of all pods, based on the operation being performed. func (r *SingleClusterReconciler) getRollingRestartTypeMap(rackState *RackState, ignorablePodNames sets.Set[string]) ( - restartTypeMap map[string]RestartType, dynamicDiffs map[string]interface{}, err error) { + restartTypeMap map[string]RestartType, dynamicDiffs map[string]map[string]interface{}, err error) { var ( addedNSDevices []string onlyDynamicConfigChange bool @@ -1307,7 +1307,8 @@ func (r *SingleClusterReconciler) getConfigMap(rackID int) (*corev1.ConfigMap, e return confMap, nil } -func (r *SingleClusterReconciler) handleDynamicConfigChange(rackState *RackState) (map[string]interface{}, error) { +func (r *SingleClusterReconciler) handleDynamicConfigChange(rackState *RackState) ( + map[string]map[string]interface{}, error) { var rackStatus asdbv1.Rack for idx := range r.aeroCluster.Status.RackConfig.Racks { @@ -1331,7 +1332,7 @@ func (r *SingleClusterReconciler) handleDynamicConfigChange(rackState *RackState flatStatusConf := *asConfStatus.GetFlatMap() flatSpecConf := *asConfSpec.GetFlatMap() - specToStatusDiffs := asconfig.ConfDiff(r.Log, flatSpecConf, flatStatusConf, true, false, true, "7.0.0") + specToStatusDiffs := asconfig.ConfDiff(r.Log, flatSpecConf, flatStatusConf, true, "7.0.0") r.Log.Info("print diff outside", "difference", fmt.Sprintf("%v", specToStatusDiffs)) if len(specToStatusDiffs) > 1 { @@ -1343,24 +1344,9 @@ func (r *SingleClusterReconciler) handleDynamicConfigChange(rackState *RackState isDynamic := asconfig.IsAllDynamicConfig(specToStatusDiffs, "7.0.0") if !isDynamic { - r.Log.Info("Static field has been changed, cannot change config dynamically") + r.Log.Info("Static field has been modified, cannot change config dynamically") return nil, nil } - for diff, value := range specToStatusDiffs { - if fmt.Sprintf("%T", value) == "[]string" { - if statusValue, ok := flatStatusConf[diff]; ok { - statusSet := sets.NewString(statusValue.([]string)...) - diffSet := sets.NewString(value.([]string)...) - - if len(statusSet.Difference(diffSet)) > 0 { - r.Log.Info("Can not remove value from list dynamically", "key", diff, - "statusset", fmt.Sprint(statusSet.List()), "diffSet", fmt.Sprint(diffSet.List())) - return nil, nil - } - } - } - } - return specToStatusDiffs, nil } diff --git a/controllers/rack.go b/controllers/rack.go index b43aa15f5..82cb125df 100644 --- a/controllers/rack.go +++ b/controllers/rack.go @@ -452,7 +452,7 @@ func (r *SingleClusterReconciler) upgradeOrRollingRestartRack(found *appsv1.Stat func (r *SingleClusterReconciler) updateDynamicConfig(rackState *RackState, ignorablePodNames sets.Set[string], restartTypeMap map[string]RestartType, - failedPods []*corev1.Pod, dynamicDiffs map[string]interface{}) reconcileResult { + failedPods []*corev1.Pod, dynamicDiffs map[string]map[string]interface{}) reconcileResult { r.Log.Info("Update dynamic config in Aerospike pods") r.Recorder.Eventf( @@ -1148,7 +1148,7 @@ func (r *SingleClusterReconciler) rollingRestartRack(found *appsv1.StatefulSet, func (r *SingleClusterReconciler) needRollingRestartRack(rackState *RackState, ignorablePodNames sets.Set[string]) ( needRestart, needUpdateConf bool, restartTypeMap map[string]RestartType, - dynamicDiffs map[string]interface{}, err error, + dynamicDiffs map[string]map[string]interface{}, err error, ) { restartTypeMap, dynamicDiffs, err = r.getRollingRestartTypeMap(rackState, ignorablePodNames) if err != nil { diff --git a/go.mod b/go.mod index 08aeca674..093b9b386 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-20231221135621-91f78d86f1ee + github.com/aerospike/aerospike-management-lib v0.0.0-20231227142907-e308f15df328 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 8c812d4c5..2560947ac 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-20231221135621-91f78d86f1ee h1:QXe1i/k2kidL/nH8h9SEbteOYVKzpvbIK94oHBAEUvk= -github.com/aerospike/aerospike-management-lib v0.0.0-20231221135621-91f78d86f1ee/go.mod h1:qoBjUWFlcE7s7PBSyeEXeEJVypgr0/w5lXGKy7MvKVo= +github.com/aerospike/aerospike-management-lib v0.0.0-20231227142907-e308f15df328 h1:caUEqo6A/BZzPuobq++veNUynPpmum6FRlGgrW6Q2ZE= +github.com/aerospike/aerospike-management-lib v0.0.0-20231227142907-e308f15df328/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=