Skip to content

Commit

Permalink
version 2, handing diff in more detailed way
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Dec 27, 2023
1 parent f62c38f commit 4a31423
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
2 changes: 1 addition & 1 deletion controllers/aero_info_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 5 additions & 19 deletions controllers/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions controllers/rack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 4a31423

Please sign in to comment.