Skip to content

Commit

Permalink
KO-364: Handle special bool fields (#333)
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 <tjain@aerospike.com>
  • Loading branch information
abhishekdwivedi3060 and tanmayja authored Jan 6, 2025
1 parent 50692f9 commit 385c3d2
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ClusterServiceVersion
metadata:
annotations:
alm-examples: '[]'
capabilities: Seamless Upgrades
capabilities: Deep Insights
categories: Database
containerImage: controller:latest
createdAt: dateplaceholder
Expand Down
3 changes: 3 additions & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Append samples you want in your CSV to this file as resources ##
resources:
- dim_nostorage_cluster_skip_validation_cr.yaml
- aerospikebackupservice.yaml
- aerospikebackup.yaml
- aerospikerestore.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
require (
github.com/aerospike/aerospike-backup-service v0.0.0-20240822110128-dc2b4811b9d3
github.com/aerospike/aerospike-client-go/v7 v7.6.1
github.com/aerospike/aerospike-management-lib v1.5.0
github.com/aerospike/aerospike-management-lib v1.5.1-0.20250106091653-f0c86baa6cd7
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/deckarep/golang-set/v2 v2.3.1
github.com/evanphx/json-patch v4.12.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/aerospike/aerospike-backup-service v0.0.0-20240822110128-dc2b4811b9d3
github.com/aerospike/aerospike-backup-service v0.0.0-20240822110128-dc2b4811b9d3/go.mod h1:PFWhqxcMsEEyoOZtQ70b+X8xWbbemDYuitT24EPBizk=
github.com/aerospike/aerospike-client-go/v7 v7.6.1 h1:VZK6S9YKq2w6ptTk3kXXjTxG2U9M9Y7Oi3YQ+3T7wQQ=
github.com/aerospike/aerospike-client-go/v7 v7.6.1/go.mod h1:uCbSYMpjlRcH/9f26VSF/luzDDXrcDaV8c6/WIcKtT4=
github.com/aerospike/aerospike-management-lib v1.5.0 h1:uAEaBU+PkzbtwsSrPVokLIUeJaDrFSMtwqeCKba3xIs=
github.com/aerospike/aerospike-management-lib v1.5.0/go.mod h1:hsEptY/AmTmHoJnItJNmfJ4yCMG8LIB8YPnIpIyvGXI=
github.com/aerospike/aerospike-management-lib v1.5.1-0.20250106091653-f0c86baa6cd7 h1:lhccxfqnvqdSNnpxdM4xjUnp8AzHsUKKqJPXRKIgfsw=
github.com/aerospike/aerospike-management-lib v1.5.1-0.20250106091653-f0c86baa6cd7/go.mod h1:hsEptY/AmTmHoJnItJNmfJ4yCMG8LIB8YPnIpIyvGXI=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
Expand Down
16 changes: 16 additions & 0 deletions internal/controller/cluster/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ func (r *SingleClusterReconciler) createConfigMapData(rack *asdbv1.Rack) (
confTemp = strings.ReplaceAll(confTemp, rackStr, "rack-id 0")
}

// [Backward Compatibility Fix]
// Historically, all benchmark configurations were represented as single literal fields in the configuration.
// The presence of these fields indicated that the corresponding benchmark was enabled.
// However, AER-6767(https://aerospike.atlassian.net/browse/AER-6767) restricted a two-literal benchmark
// configuration format (e.g., "enable-benchmarks-read true").
// Handling this change leads to hash mismatches during AKO upgrades, leading to unnecessary warm restarts.
// Solution: For hash calculations, replace the new benchmark configuration format with the old format
// to maintain compatibility and prevent these issues.
// Example: Convert "enable-benchmarks-read true" to "enable-benchmarks-read".
for _, benchmarkConfig := range asconfig.BenchmarkConfigs {
re := regexp.MustCompile(fmt.Sprintf(`%s.*true`, benchmarkConfig))
if benchmarkStr := re.FindString(confTemp); benchmarkStr != "" {
confTemp = strings.ReplaceAll(confTemp, benchmarkStr, benchmarkConfig)
}
}

// Add conf hash
confHash, err := utils.GetHash(confTemp)
if err != nil {
Expand Down
105 changes: 105 additions & 0 deletions test/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1"
"github.com/aerospike/aerospike-kubernetes-operator/pkg/utils"
"github.com/aerospike/aerospike-kubernetes-operator/test"
lib "github.com/aerospike/aerospike-management-lib"
)

var _ = Describe(
Expand Down Expand Up @@ -85,6 +86,11 @@ var _ = Describe(
PauseReconcileTest(ctx)
},
)
Context(
"ValidateAerospikeBenchmarkConfigs", func() {
ValidateAerospikeBenchmarkConfigs(ctx)
},
)
},
)

Expand Down Expand Up @@ -193,6 +199,105 @@ func setPauseFlag(ctx goctx.Context, clusterNamespacedName types.NamespacedName,
return k8sClient.Update(ctx, aeroCluster)
}

// Historically, all benchmark configurations were represented as single literal fields in the configuration.
// The presence of these fields indicated that the corresponding benchmark was enabled.
// However, AER-6767(https://aerospike.atlassian.net/browse/AER-6767) restricted a two-literal benchmark
// configuration format (e.g., "enable-benchmarks-read true")
// Here validating that benchmark configurations are working as expected with all server versions.
func ValidateAerospikeBenchmarkConfigs(ctx goctx.Context) {
Context(
"ValidateAerospikeBenchmarkConfigs", func() {
clusterNamespacedName := getNamespacedName(
"deploy-cluster-benchmark", namespace,
)

AfterEach(
func() {
aeroCluster, err := getCluster(
k8sClient, ctx, clusterNamespacedName,
)
Expect(err).ToNot(HaveOccurred())

_ = deleteCluster(k8sClient, ctx, aeroCluster)
},
)

It(
"benchmarking should work in all aerospike server version", func() {
By("Deploying cluster which does not have the fix for AER-6767")

imageBeforeFix := fmt.Sprintf("%s:%s", baseImage, "7.1.0.2")
aeroCluster := createAerospikeClusterPost640(clusterNamespacedName, 2, imageBeforeFix)
namespaceConfig :=
aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0].(map[string]interface{})
namespaceConfig["enable-benchmarks-read"] = false
aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0] = namespaceConfig
err := deployCluster(k8sClient, ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())

By("Validating benchmarking is disabled")

aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName)
Expect(err).ToNot(HaveOccurred())

pod := aeroCluster.Status.Pods["deploy-cluster-benchmark-0-0"]
nsConfs, err := getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName, "namespaces", &pod)
Expect(err).ToNot(HaveOccurred())
Expect(nsConfs["test"].(lib.Stats)["enable-benchmarks-read"]).To(Equal(false))

By("Updating cluster to enable benchmarking")

namespaceConfig =
aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0].(map[string]interface{})
namespaceConfig["enable-benchmarks-read"] = true
aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0] = namespaceConfig

err = updateCluster(k8sClient, ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())

nsConfs, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName, "namespaces", &pod)
Expect(err).ToNot(HaveOccurred())
Expect(nsConfs["test"].(lib.Stats)["enable-benchmarks-read"]).To(Equal(true))

By("Updating cluster server to version which has the fix for AER-6767")

imageAfterFix := fmt.Sprintf("%s:%s", baseImage, "7.1.0.10")

aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName)
Expect(err).ToNot(HaveOccurred())

aeroCluster.Spec.Image = imageAfterFix

err = updateCluster(k8sClient, ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())

aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName)
Expect(err).ToNot(HaveOccurred())

nsConfs, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName, "namespaces", &pod)
Expect(err).ToNot(HaveOccurred())
Expect(nsConfs["test"].(lib.Stats)["enable-benchmarks-read"]).To(Equal(true))

By("Updating cluster to disable benchmarking")

namespaceConfig =
aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0].(map[string]interface{})

namespaceConfig["enable-benchmarks-read"] = false
aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{})[0] = namespaceConfig

err = updateCluster(k8sClient, ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())

nsConfs, err = getAerospikeConfigFromNode(logger, k8sClient, ctx, clusterNamespacedName, "namespaces", &pod)
Expect(err).ToNot(HaveOccurred())
Expect(nsConfs["test"].(lib.Stats)["enable-benchmarks-read"]).To(Equal(false))
},
)
},
)
}

func UpdateClusterPre600(ctx goctx.Context) {
Context(
"UpdateClusterPre600", func() {
Expand Down

0 comments on commit 385c3d2

Please sign in to comment.