Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing 0 rack-id to correct rack id in rackConfig namespaces #288

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/v1/aerospikecluster_mutating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,13 @@ func setDefaultNsConf(asLog logr.Logger, configSpec AerospikeConfigSpec,
if rackID != nil {
// Add rack-id only in rack specific config, not in global config
defaultConfs := map[string]interface{}{"rack-id": *rackID}

// Delete rack-id from namespace in rack specific config if set to 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a bit of detailed comment.

// This could happen in operator below 3.3.0
if id, ok := nsMap["rack-id"]; ok && id == float64(0) && *rackID != 0 {
delete(nsMap, "rack-id")
}

if err := setDefaultsInConfigMap(
asLog, nsMap, defaultConfs,
); err != nil {
Expand All @@ -411,6 +418,8 @@ func setDefaultNsConf(asLog logr.Logger, configSpec AerospikeConfigSpec,
err,
)
}
} else {
delete(nsMap, "rack-id")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an explanation of this delete.

}
} else {
// User may have added this key or may have patched object with new smaller rackEnabledNamespace list
Expand Down
9 changes: 9 additions & 0 deletions controllers/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io/fs"
"path/filepath"
"regexp"
"strings"
"text/template"

Expand Down Expand Up @@ -106,6 +107,14 @@ func (r *SingleClusterReconciler) createConfigMapData(rack *asdbv1.Rack) (

confData[aerospikeTemplateConfFileName] = confTemp

// This field value is rectified in 3.3.0.
Copy link
Collaborator

@sud82 sud82 May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the comment

rack-id was historically set to 0 for all namespaces, but since the AKO 3.3.0, it reflects actual values. This change led to hash mismatches during the AKO 3.3.0 upgrade, triggering unnecessary warm restarts. Solution: Replace real rack-id with 0 in hash calculations to avoid this issue.

// Ignore rack-id change from hash computation so that on upgrade clusters are
// not rolling restarted.
re := regexp.MustCompile(`rack-id.*\d+`)
if rackStr := re.FindString(confTemp); rackStr != "" {
confTemp = strings.ReplaceAll(confTemp, rackStr, "rack-id 0")
}

// Add conf hash
confHash, err := utils.GetHash(confTemp)
if err != nil {
Expand Down
Loading