From 76a70ca358f087defabaa9c6342cab57c66d2224 Mon Sep 17 00:00:00 2001 From: Abhisek Dwivedi Date: Fri, 15 Mar 2024 14:08:02 +0530 Subject: [PATCH 1/2] Fixed intermittent testcase failures (#275) --- ...rnetes-operator.clusterserviceversion.yaml | 7 ++++-- test/cluster_helper.go | 20 ++++++++++++++-- test/cluster_test.go | 24 ++++++++++++------- test/large_reconcile_test.go | 9 ++++--- test/sample_files_test.go | 2 +- test/utils.go | 18 ++++++++------ 6 files changed, 57 insertions(+), 23 deletions(-) diff --git a/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml b/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml index e9cec80a0..64dcdffae 100644 --- a/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/aerospike-kubernetes-operator.clusterserviceversion.yaml @@ -51,12 +51,15 @@ spec: displayName: Server Image path: image - description: K8sNodeBlockList is a list of Kubernetes nodes which are not - used for Aerospike pods. + used for Aerospike pods. Pods are not scheduled on these nodes. Pods are + migrated from these nodes if already present. This is useful for the maintenance + of Kubernetes nodes. displayName: Kubernetes Node BlockList path: k8sNodeBlockList - description: MaxUnavailable is the percentage/number of pods that can be allowed to go down or unavailable before application disruption. This value is used - to create PodDisruptionBudget. Defaults to 1. + to create PodDisruptionBudget. Defaults to 1. Refer Aerospike documentation + for more details. displayName: Max Unavailable path: maxUnavailable - description: Certificates to connect to Aerospike. diff --git a/test/cluster_helper.go b/test/cluster_helper.go index c9199ae79..97a04a351 100644 --- a/test/cluster_helper.go +++ b/test/cluster_helper.go @@ -761,7 +761,7 @@ func deployClusterWithTO( // Wait for aerocluster to reach the desired cluster size. return waitForAerospikeCluster( k8sClient, ctx, aeroCluster, int(aeroCluster.Spec.Size), retryInterval, - timeout, + timeout, []asdbv1.AerospikeClusterPhase{asdbv1.AerospikeClusterCompleted}, ) } @@ -780,6 +780,21 @@ func updateCluster( return updateClusterWithTO(k8sClient, ctx, aeroCluster, getTimeout(aeroCluster.Spec.Size)) } +func updateClusterWithExpectedPhases( + k8sClient client.Client, ctx goctx.Context, + aeroCluster *asdbv1.AerospikeCluster, expectedPhases []asdbv1.AerospikeClusterPhase, +) error { + err := k8sClient.Update(ctx, aeroCluster) + if err != nil { + return err + } + + return waitForAerospikeCluster( + k8sClient, ctx, aeroCluster, int(aeroCluster.Spec.Size), retryInterval, + getTimeout(aeroCluster.Spec.Size), expectedPhases, + ) +} + func updateClusterWithTO( k8sClient client.Client, ctx goctx.Context, aeroCluster *asdbv1.AerospikeCluster, timeout time.Duration, @@ -791,7 +806,7 @@ func updateClusterWithTO( return waitForAerospikeCluster( k8sClient, ctx, aeroCluster, int(aeroCluster.Spec.Size), retryInterval, - timeout, + timeout, []asdbv1.AerospikeClusterPhase{asdbv1.AerospikeClusterCompleted}, ) } @@ -1442,6 +1457,7 @@ func aerospikeClusterCreateUpdateWithTO( return waitForAerospikeCluster( k8sClient, ctx, desired, int(desired.Spec.Size), retryInterval, timeout, + []asdbv1.AerospikeClusterPhase{asdbv1.AerospikeClusterCompleted}, ) } diff --git a/test/cluster_test.go b/test/cluster_test.go index f28ec7709..fc02970bd 100644 --- a/test/cluster_test.go +++ b/test/cluster_test.go @@ -119,7 +119,7 @@ func ScaleDownWithMigrateFillDelay(ctx goctx.Context) { err = waitForAerospikeCluster( k8sClient, ctx, aeroCluster, int(aeroCluster.Spec.Size), retryInterval, - getTimeout(2), + getTimeout(2), []asdbv1.AerospikeClusterPhase{asdbv1.AerospikeClusterCompleted}, ) Expect(err).ToNot(HaveOccurred()) @@ -134,10 +134,12 @@ func ScaleDownWithMigrateFillDelay(ctx goctx.Context) { func clusterWithMaxIgnorablePod(ctx goctx.Context) { var ( - aeroCluster *asdbv1.AerospikeCluster - err error - nodeList = &v1.NodeList{} - podList = &v1.PodList{} + aeroCluster *asdbv1.AerospikeCluster + err error + nodeList = &v1.NodeList{} + podList = &v1.PodList{} + expectedPhases = []asdbv1.AerospikeClusterPhase{ + asdbv1.AerospikeClusterInProgress, asdbv1.AerospikeClusterCompleted} ) clusterNamespacedName := getNamespacedName( @@ -184,7 +186,9 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) { aeroCluster.Spec.AerospikeConfig.Value["service"].(map[string]interface{})["proto-fd-max"] = int64(18000) - return updateCluster(k8sClient, ctx, aeroCluster) + // As pod is in pending state, CR object will be won't reach the final phase. + // So expectedPhases can be InProgress or Completed + return updateClusterWithExpectedPhases(k8sClient, ctx, aeroCluster, expectedPhases) }, 1*time.Minute).ShouldNot(HaveOccurred()) By("Upgrade version") @@ -192,7 +196,9 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) { Expect(err).ToNot(HaveOccurred()) newImage := baseImage + ":7.0.0.0_2" aeroCluster.Spec.Image = newImage - err = updateCluster(k8sClient, ctx, aeroCluster) + // As pod is in pending state, CR object will be won't reach the final phase. + // So expectedPhases can be InProgress or Completed + err = updateClusterWithExpectedPhases(k8sClient, ctx, aeroCluster, expectedPhases) Expect(err).ToNot(HaveOccurred()) By("Verify pending pod") @@ -212,7 +218,9 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) { aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName) Expect(err).ToNot(HaveOccurred()) aeroCluster.Spec.Size-- - err = updateCluster(k8sClient, ctx, aeroCluster) + // As pod is in pending state, CR object will be won't reach the final phase. + // So expectedPhases can be InProgress or Completed + err = updateClusterWithExpectedPhases(k8sClient, ctx, aeroCluster, expectedPhases) Expect(err).ToNot(HaveOccurred()) By("Verify if all pods are running") diff --git a/test/large_reconcile_test.go b/test/large_reconcile_test.go index 6e59732b0..0e8272fe4 100644 --- a/test/large_reconcile_test.go +++ b/test/large_reconcile_test.go @@ -319,7 +319,8 @@ func waitForClusterScaleDown( return false, err } - return isClusterStateValid(aeroCluster, newCluster, replicas), nil + return isClusterStateValid(aeroCluster, newCluster, replicas, + []asdbv1.AerospikeClusterPhase{asdbv1.AerospikeClusterCompleted}), nil }, ) if err != nil { @@ -360,7 +361,8 @@ func waitForClusterRollingRestart( return false, err } - return isClusterStateValid(aeroCluster, newCluster, replicas), nil + return isClusterStateValid(aeroCluster, newCluster, replicas, + []asdbv1.AerospikeClusterPhase{asdbv1.AerospikeClusterCompleted}), nil }, ) if err != nil { @@ -401,7 +403,8 @@ func waitForClusterUpgrade( return false, err } - return isClusterStateValid(aeroCluster, newCluster, replicas), nil + return isClusterStateValid(aeroCluster, newCluster, replicas, + []asdbv1.AerospikeClusterPhase{asdbv1.AerospikeClusterCompleted}), nil }, ) if err != nil { diff --git a/test/sample_files_test.go b/test/sample_files_test.go index 18f638fdd..d7d7827d9 100644 --- a/test/sample_files_test.go +++ b/test/sample_files_test.go @@ -179,7 +179,7 @@ func deployClusterUsingFile(ctx context.Context, filePath string) (*asdbv1.Aeros if err := waitForAerospikeCluster( k8sClient, ctx, aeroCluster, int(aeroCluster.Spec.Size), retryInterval, - getTimeout(aeroCluster.Spec.Size), + getTimeout(aeroCluster.Spec.Size), []asdbv1.AerospikeClusterPhase{asdbv1.AerospikeClusterCompleted}, ); err != nil { return aeroCluster, err } diff --git a/test/utils.go b/test/utils.go index 78207c235..c7ee3982b 100644 --- a/test/utils.go +++ b/test/utils.go @@ -14,6 +14,7 @@ import ( "strings" "time" + set "github.com/deckarep/golang-set/v2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" @@ -236,7 +237,7 @@ func getLabels() map[string]string { func waitForAerospikeCluster( k8sClient client.Client, ctx goctx.Context, aeroCluster *asdbv1.AerospikeCluster, replicas int, - retryInterval, timeout time.Duration, + retryInterval, timeout time.Duration, expectedPhases []asdbv1.AerospikeClusterPhase, ) error { var isValid bool @@ -260,7 +261,7 @@ func waitForAerospikeCluster( return false, err } - isValid = isClusterStateValid(aeroCluster, newCluster, replicas) + isValid = isClusterStateValid(aeroCluster, newCluster, replicas, expectedPhases) return isValid, nil }, ) @@ -277,7 +278,7 @@ func waitForAerospikeCluster( func isClusterStateValid( aeroCluster *asdbv1.AerospikeCluster, - newCluster *asdbv1.AerospikeCluster, replicas int, + newCluster *asdbv1.AerospikeCluster, replicas int, expectedPhases []asdbv1.AerospikeClusterPhase, ) bool { if int(newCluster.Status.Size) != replicas { pkgLog.Info("Cluster size is not correct") @@ -315,8 +316,9 @@ func isClusterStateValid( } pkgLog.Info( - "Cluster pod's image %s not same as spec %s", newCluster.Status.Pods[podName].Image, - aeroCluster.Spec.Image, + fmt.Sprintf("Cluster pod's image %s not same as spec %s", newCluster.Status.Pods[podName].Image, + aeroCluster.Spec.Image, + ), ) } @@ -325,8 +327,10 @@ func isClusterStateValid( return false } - if newCluster.Status.Phase != asdbv1.AerospikeClusterCompleted { - pkgLog.Info("Cluster phase is not set to Completed") + // Validate phase + phaseSet := set.NewSet(expectedPhases...) + if !phaseSet.Contains(newCluster.Status.Phase) { + pkgLog.Info("Cluster phase is not correct") return false } From cb7271212f538cb30891393c1cdbb325684e1f70 Mon Sep 17 00:00:00 2001 From: Tanmay Jain <103629776+tanmayja@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:11:21 +0530 Subject: [PATCH 2/2] [KO-295] Changing MultiPodPerHost from bool to bool pointer (#274) * [KO-295] Changing MultiPodPerHost from bool to bool pointer * Golang version bump to 1.21 --- .github/workflows/golangci-lint.yaml | 4 +-- .golangci.yml | 3 +-- Dockerfile | 2 +- Jenkinsfile | 2 +- Makefile | 2 +- api/v1/aerospikecluster_types.go | 4 +-- api/v1/aerospikecluster_validating_webhook.go | 9 ++++--- api/v1/utils.go | 6 +++++ api/v1/zz_generated.deepcopy.go | 10 ++++++++ controllers/client_policy.go | 2 +- controllers/configmap.go | 2 +- controllers/pod.go | 2 +- controllers/rack.go | 2 +- controllers/service.go | 4 +-- controllers/statefulset.go | 6 ++--- go.mod | 16 ++++++------ go.sum | 25 +++++++++++-------- test/access_control_test.go | 3 ++- test/aero_info.go | 2 +- test/cluster_helper.go | 19 +++++++------- test/cluster_test.go | 12 +++++---- test/host_network_test.go | 5 ++-- test/k8snode_block_list_test.go | 4 ++- test/ldap_auth_test.go | 5 ++-- test/network_policy_test.go | 7 +++--- test/rack_management_test.go | 3 ++- test/storage_init_test.go | 3 ++- test/storage_wipe_test.go | 7 +++--- 28 files changed, 103 insertions(+), 68 deletions(-) diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index ac45bb49a..d8b3b9eb9 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -17,7 +17,7 @@ jobs: - name: Setup-go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Checkout sources uses: actions/checkout@v3 with: @@ -25,5 +25,5 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.52 + version: v1.54 args: --timeout=5m \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 3f8d5ff5e..48e7e986f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -23,7 +23,6 @@ linters: enable: - bodyclose - unused - - depguard - dogsled - dupl - errcheck @@ -57,7 +56,7 @@ linters: run: issues-exit-code: 1 - go: '1.19' + go: '1.21' # skip-dirs: # - sample # skip-files: diff --git a/Dockerfile b/Dockerfile index 4584d1492..615a0e4d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.19 as builder +FROM --platform=$BUILDPLATFORM golang:1.21 as builder # OS and Arch args ARG TARGETOS diff --git a/Jenkinsfile b/Jenkinsfile index 8b5a6df7b..246df9754 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent any tools { - go 'go-1.19' + go 'go-1.21' } environment { diff --git a/Makefile b/Makefile index 552a45c81..471d5bcc9 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,7 @@ vet: ## Run go vet against code. go vet ./... GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.52.2 +GOLANGCI_LINT_VERSION ?= v1.54.0 .PHONY: golanci-lint golanci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. diff --git a/api/v1/aerospikecluster_types.go b/api/v1/aerospikecluster_types.go index 08f4f95fd..3a8187a08 100644 --- a/api/v1/aerospikecluster_types.go +++ b/api/v1/aerospikecluster_types.go @@ -233,7 +233,7 @@ type AerospikePodSpec struct { //nolint:govet // for readability // The container port will be exposed to the external network at :, // where the hostIP is the IP address of the Kubernetes Node where the container is running and // the hostPort is the port requested by the user. - MultiPodPerHost bool `json:"multiPodPerHost,omitempty"` + MultiPodPerHost *bool `json:"multiPodPerHost,omitempty"` // HostNetwork enables host networking for the pod. // To enable hostNetwork multiPodPerHost must be false. @@ -632,7 +632,7 @@ type AerospikeClusterStatusSpec struct { //nolint:govet // for readability // where the hostIP is the IP address of the Kubernetes Node where the container is running and // the hostPort is the port requested by the user. // Deprecated: MultiPodPerHost is now part of podSpec - MultiPodPerHost bool `json:"multiPodPerHost,omitempty"` + MultiPodPerHost *bool `json:"multiPodPerHost,omitempty"` // Storage specify persistent storage to use for the Aerospike pods. Storage AerospikeStorageSpec `json:"storage,omitempty"` // AerospikeAccessControl has the Aerospike roles and users definitions. diff --git a/api/v1/aerospikecluster_validating_webhook.go b/api/v1/aerospikecluster_validating_webhook.go index cf6c2fdf8..fe340aee2 100644 --- a/api/v1/aerospikecluster_validating_webhook.go +++ b/api/v1/aerospikecluster_validating_webhook.go @@ -1,5 +1,5 @@ /* -Copyright 2021. +Copyright 2024. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -27,18 +27,19 @@ import ( "regexp" "strings" - lib "github.com/aerospike/aerospike-management-lib" validate "github.com/asaskevich/govalidator" "github.com/go-logr/logr" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/utils/ptr" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" internalerrors "github.com/aerospike/aerospike-kubernetes-operator/errors" + lib "github.com/aerospike/aerospike-management-lib" "github.com/aerospike/aerospike-management-lib/asconfig" "github.com/aerospike/aerospike-management-lib/deployment" ) @@ -104,7 +105,7 @@ func (c *AerospikeCluster) ValidateUpdate(oldObj runtime.Object) (admission.Warn } // MultiPodPerHost cannot be updated - if c.Spec.PodSpec.MultiPodPerHost != old.Spec.PodSpec.MultiPodPerHost { + if !ptr.Equal(c.Spec.PodSpec.MultiPodPerHost, old.Spec.PodSpec.MultiPodPerHost) { return nil, fmt.Errorf("cannot update MultiPodPerHost setting") } @@ -1998,7 +1999,7 @@ func isPathParentOrSame(dir1, dir2 string) bool { } func (c *AerospikeCluster) validatePodSpec() error { - if c.Spec.PodSpec.HostNetwork && c.Spec.PodSpec.MultiPodPerHost { + if c.Spec.PodSpec.HostNetwork && GetBool(c.Spec.PodSpec.MultiPodPerHost) { return fmt.Errorf("host networking cannot be enabled with multi pod per host") } diff --git a/api/v1/utils.go b/api/v1/utils.go index ff11d8281..786d392ef 100644 --- a/api/v1/utils.go +++ b/api/v1/utils.go @@ -8,6 +8,7 @@ import ( "strings" v1 "k8s.io/api/core/v1" + "k8s.io/utils/ptr" internalerrors "github.com/aerospike/aerospike-kubernetes-operator/errors" lib "github.com/aerospike/aerospike-management-lib" @@ -494,3 +495,8 @@ func getContainerNames(containers []v1.Container) []string { return containerNames } + +// GetBool returns the value of the given bool pointer. If the pointer is nil, it returns false. +func GetBool(boolPtr *bool) bool { + return ptr.Deref(boolPtr, false) +} diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 489353971..3bd576ec1 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -236,6 +236,11 @@ func (in *AerospikeClusterStatusSpec) DeepCopyInto(out *AerospikeClusterStatusSp *out = new(intstr.IntOrString) **out = **in } + if in.MultiPodPerHost != nil { + in, out := &in.MultiPodPerHost, &out.MultiPodPerHost + *out = new(bool) + **out = **in + } in.Storage.DeepCopyInto(&out.Storage) if in.AerospikeAccessControl != nil { in, out := &in.AerospikeAccessControl, &out.AerospikeAccessControl @@ -548,6 +553,11 @@ func (in *AerospikePodSpec) DeepCopyInto(out *AerospikePodSpec) { } } in.SchedulingPolicy.DeepCopyInto(&out.SchedulingPolicy) + if in.MultiPodPerHost != nil { + in, out := &in.MultiPodPerHost, &out.MultiPodPerHost + *out = new(bool) + **out = **in + } if in.InputDNSPolicy != nil { in, out := &in.InputDNSPolicy, &out.InputDNSPolicy *out = new(corev1.DNSPolicy) diff --git a/controllers/client_policy.go b/controllers/client_policy.go index c628aecdc..fe6c3039c 100644 --- a/controllers/client_policy.go +++ b/controllers/client_policy.go @@ -72,7 +72,7 @@ func (r *SingleClusterReconciler) getClientPolicy() *as.ClientPolicy { r.Log.V(1).Info("Set tls config in aerospike client policy") clientCertSpec := r.aeroCluster.Spec.OperatorClientCertSpec - //nolint:gosec // will be fixed in go 1.19 + //nolint:gosec // This is a default TLS MinVersion tlsConf := tls.Config{ RootCAs: r.getClusterServerCAPool( clientCertSpec, r.aeroCluster.Namespace, diff --git a/controllers/configmap.go b/controllers/configmap.go index 080d025c0..c4a88f9b3 100644 --- a/controllers/configmap.go +++ b/controllers/configmap.go @@ -256,7 +256,7 @@ func (r *SingleClusterReconciler) getBaseConfData(rack *asdbv1.Rack) (map[string initTemplateInput := initializeTemplateInput{ WorkDir: workDir, - MultiPodPerHost: r.aeroCluster.Spec.PodSpec.MultiPodPerHost, + MultiPodPerHost: asdbv1.GetBool(r.aeroCluster.Spec.PodSpec.MultiPodPerHost), NetworkPolicy: r.aeroCluster.Spec.AerospikeNetworkPolicy, PodPort: servicePortParam, PodTLSPort: serviceTLSPortParam, diff --git a/controllers/pod.go b/controllers/pod.go index 859bb4989..9509986b9 100644 --- a/controllers/pod.go +++ b/controllers/pod.go @@ -600,7 +600,7 @@ func (r *SingleClusterReconciler) cleanupPods( } // Try to delete corresponding pod service if it was created - if r.aeroCluster.Spec.PodSpec.MultiPodPerHost { + if asdbv1.GetBool(r.aeroCluster.Spec.PodSpec.MultiPodPerHost) { // Remove service for pod // TODO: make it more robust, what if it fails if err := r.deletePodService( diff --git a/controllers/rack.go b/controllers/rack.go index fae60b782..087b56fef 100644 --- a/controllers/rack.go +++ b/controllers/rack.go @@ -571,7 +571,7 @@ func (r *SingleClusterReconciler) reconcileRack( // Safe check to delete all dangling pod services which are no longer required // There won't be any case of dangling pod service with MultiPodPerHost false, so ignore that case - if r.aeroCluster.Spec.PodSpec.MultiPodPerHost && + if asdbv1.GetBool(r.aeroCluster.Spec.PodSpec.MultiPodPerHost) && !podServiceNeeded(r.aeroCluster.Spec.PodSpec.MultiPodPerHost, &r.aeroCluster.Spec.AerospikeNetworkPolicy) { if err := r.cleanupDanglingPodServices(rackState); err != nil { return reconcileError(err) diff --git a/controllers/service.go b/controllers/service.go index b95a68974..9d12e583e 100644 --- a/controllers/service.go +++ b/controllers/service.go @@ -400,8 +400,8 @@ func (r *SingleClusterReconciler) cleanupDanglingPodServices(rackState *RackStat return nil } -func podServiceNeeded(multiPodPerHost bool, networkPolicy *asdbv1.AerospikeNetworkPolicy) bool { - if !multiPodPerHost || networkPolicy == nil { +func podServiceNeeded(multiPodPerHost *bool, networkPolicy *asdbv1.AerospikeNetworkPolicy) bool { + if !asdbv1.GetBool(multiPodPerHost) || networkPolicy == nil { return false } diff --git a/controllers/statefulset.go b/controllers/statefulset.go index f726fe49b..58b958d70 100644 --- a/controllers/statefulset.go +++ b/controllers/statefulset.go @@ -856,7 +856,7 @@ func (r *SingleClusterReconciler) updateSTSSchedulingPolicy( // Set our rules in PodAntiAffinity // only enable in production, so it can be used in 1 node clusters while debugging (minikube) - if !r.aeroCluster.Spec.PodSpec.MultiPodPerHost { + if !asdbv1.GetBool(r.aeroCluster.Spec.PodSpec.MultiPodPerHost) { if affinity.PodAntiAffinity == nil { affinity.PodAntiAffinity = &corev1.PodAntiAffinity{} } @@ -1539,7 +1539,7 @@ func addVolumeDeviceInContainer( } func getSTSContainerPort( - multiPodPerHost bool, aeroConf *asdbv1.AerospikeConfigSpec, + multiPodPerHost *bool, aeroConf *asdbv1.AerospikeConfigSpec, ) []corev1.ContainerPort { ports := make([]corev1.ContainerPort, 0, len(defaultContainerPorts)) portNames := make([]string, 0, len(defaultContainerPorts)) @@ -1571,7 +1571,7 @@ func getSTSContainerPort( // The container port will be exposed to the external network at :, // where the hostIP is the IP address of the Kubernetes node where // the container is running and the hostPort is the port requested by the user - if (!multiPodPerHost) && portInfo.exposedOnHost { + if !asdbv1.GetBool(multiPodPerHost) && portInfo.exposedOnHost { containerPort.HostPort = containerPort.ContainerPort } diff --git a/go.mod b/go.mod index 28d7870c2..ff9b184ca 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/aerospike/aerospike-kubernetes-operator -go 1.19 +go 1.21 + +toolchain go1.21.8 require ( github.com/aerospike/aerospike-client-go/v6 v6.14.0 @@ -12,7 +14,7 @@ require ( github.com/onsi/gomega v1.29.0 github.com/stretchr/testify v1.8.4 golang.org/x/oauth2 v0.10.0 // indirect - golang.org/x/term v0.16.0 // indirect + golang.org/x/term v0.18.0 // indirect k8s.io/api v0.29.0 k8s.io/apimachinery v0.29.0 k8s.io/client-go v0.29.0 @@ -23,8 +25,9 @@ require ( require ( github.com/deckarep/golang-set/v2 v2.3.1 github.com/sirupsen/logrus v1.9.0 - golang.org/x/crypto v0.18.0 + golang.org/x/crypto v0.21.0 gomodules.xyz/jsonpatch/v2 v2.3.0 + k8s.io/utils v0.0.0-20230726121419-3b25d923346b ) require ( @@ -74,16 +77,16 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/net v0.20.0 // indirect + golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.12.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/grpc v1.58.3 // indirect - google.golang.org/protobuf v1.32.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect @@ -91,7 +94,6 @@ require ( k8s.io/component-base v0.29.0 // indirect k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect - k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/go.sum b/go.sum index e8217023d..5e03a9162 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,7 @@ github.com/aerospike/aerospike-client-go/v6 v6.14.0/go.mod h1:/0Wm81GhMqem+9flWc github.com/aerospike/aerospike-management-lib v1.2.0 h1:aBs6ZTJeVAlWZGUyxAwEBorqQG2aqQh4Ut3yxpQlV9k= github.com/aerospike/aerospike-management-lib v1.2.0/go.mod h1:NwegUX6or8xmwVMIueBmGTW7lfKlZ9XDQoCuhnQKMCA= 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= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= @@ -79,6 +80,7 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -152,7 +154,9 @@ go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= +go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= @@ -161,13 +165,14 @@ go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= @@ -175,8 +180,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -194,11 +199,11 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -228,8 +233,8 @@ google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/test/access_control_test.go b/test/access_control_test.go index 08eb10ebf..70e2a237c 100644 --- a/test/access_control_test.go +++ b/test/access_control_test.go @@ -14,6 +14,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" as "github.com/aerospike/aerospike-client-go/v6" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" @@ -2133,7 +2134,7 @@ func getAerospikeClusterSpecWithAccessControl( }, }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), }, AerospikeConfig: &asdbv1.AerospikeConfigSpec{ Value: aerospikeConfSpec.getSpec(), diff --git a/test/aero_info.go b/test/aero_info.go index 4156a99a6..1251d04d5 100644 --- a/test/aero_info.go +++ b/test/aero_info.go @@ -61,7 +61,7 @@ func newAsConn( tlsName := getServiceTLSName(aeroCluster) networkType := asdbv1.AerospikeNetworkType(*defaultNetworkType) - if aeroCluster.Spec.PodSpec.MultiPodPerHost && networkType != asdbv1.AerospikeNetworkTypePod && + if asdbv1.GetBool(aeroCluster.Spec.PodSpec.MultiPodPerHost) && networkType != asdbv1.AerospikeNetworkTypePod && networkType != asdbv1.AerospikeNetworkTypeCustomInterface { svc, err := getServiceForPod(pod, k8sClient) if err != nil { diff --git a/test/cluster_helper.go b/test/cluster_helper.go index 97a04a351..17f981c63 100644 --- a/test/cluster_helper.go +++ b/test/cluster_helper.go @@ -19,6 +19,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" @@ -856,7 +857,7 @@ func createAerospikeClusterPost460( }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), }, OperatorClientCertSpec: &asdbv1.AerospikeOperatorClientCertSpec{ AerospikeOperatorCertSource: asdbv1.AerospikeOperatorCertSource{ @@ -919,7 +920,7 @@ func createAerospikeClusterPost560( }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), }, OperatorClientCertSpec: &asdbv1.AerospikeOperatorClientCertSpec{ AerospikeOperatorCertSource: asdbv1.AerospikeOperatorCertSource{ @@ -1043,7 +1044,7 @@ func createDummyAerospikeClusterWithRFAndStorage( }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), AerospikeInitContainerSpec: &asdbv1.AerospikeInitContainerSpec{}, }, @@ -1111,7 +1112,7 @@ func createDummyAerospikeCluster( }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), AerospikeInitContainerSpec: &asdbv1.AerospikeInitContainerSpec{}, }, @@ -1302,7 +1303,7 @@ func createBasicTLSCluster( }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), }, OperatorClientCertSpec: &asdbv1.AerospikeOperatorClientCertSpec{ @@ -1336,7 +1337,7 @@ func createSSDStorageCluster( multiPodPerHost bool, ) *asdbv1.AerospikeCluster { aeroCluster := createBasicTLSCluster(clusterNamespacedName, size) - aeroCluster.Spec.PodSpec.MultiPodPerHost = multiPodPerHost + aeroCluster.Spec.PodSpec.MultiPodPerHost = &multiPodPerHost aeroCluster.Spec.Storage.Volumes = append( aeroCluster.Spec.Storage.Volumes, []asdbv1.VolumeSpec{ { @@ -1367,7 +1368,7 @@ func createHDDAndDataInMemStorageCluster( multiPodPerHost bool, ) *asdbv1.AerospikeCluster { aeroCluster := createBasicTLSCluster(clusterNamespacedName, size) - aeroCluster.Spec.PodSpec.MultiPodPerHost = multiPodPerHost + aeroCluster.Spec.PodSpec.MultiPodPerHost = &multiPodPerHost aeroCluster.Spec.Storage.Volumes = append( aeroCluster.Spec.Storage.Volumes, []asdbv1.VolumeSpec{ { @@ -1406,7 +1407,7 @@ func createDataInMemWithoutPersistentStorageCluster( multiPodPerHost bool, ) *asdbv1.AerospikeCluster { aeroCluster := createBasicTLSCluster(clusterNamespacedName, size) - aeroCluster.Spec.PodSpec.MultiPodPerHost = multiPodPerHost + aeroCluster.Spec.PodSpec.MultiPodPerHost = &multiPodPerHost aeroCluster.Spec.AerospikeConfig.Value["namespaces"] = []interface{}{ map[string]interface{}{ "name": "test", @@ -1607,7 +1608,7 @@ func getNonRootPodSpec() asdbv1.AerospikePodSpec { return asdbv1.AerospikePodSpec{ HostNetwork: false, - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), SecurityContext: &corev1.PodSecurityContext{ RunAsUser: &id, RunAsGroup: &id, diff --git a/test/cluster_test.go b/test/cluster_test.go index fc02970bd..6e29a8ee1 100644 --- a/test/cluster_test.go +++ b/test/cluster_test.go @@ -11,6 +11,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" "github.com/aerospike/aerospike-kubernetes-operator/pkg/utils" @@ -181,7 +182,7 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) { Eventually(func() error { aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName) Expect(err).ToNot(HaveOccurred()) - val := intstr.FromInt(1) + val := intstr.FromInt32(1) aeroCluster.Spec.RackConfig.MaxIgnorablePods = &val aeroCluster.Spec.AerospikeConfig.Value["service"].(map[string]interface{})["proto-fd-max"] = int64(18000) @@ -264,7 +265,7 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) { By("Delete rack with id 2") aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName) Expect(err).ToNot(HaveOccurred()) - val := intstr.FromInt(1) + val := intstr.FromInt32(1) aeroCluster.Spec.RackConfig.MaxIgnorablePods = &val aeroCluster.Spec.RackConfig.Racks = getDummyRackConf(1) err = updateCluster(k8sClient, ctx, aeroCluster) @@ -304,7 +305,7 @@ func clusterWithMaxIgnorablePod(ctx goctx.Context) { By("Set MaxIgnorablePod and Rolling restart by removing namespace") aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName) Expect(err).ToNot(HaveOccurred()) - val := intstr.FromInt(1) + val := intstr.FromInt32(1) aeroCluster.Spec.RackConfig.MaxIgnorablePods = &val nsList := aeroCluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{}) nsList = nsList[:len(nsList)-1] @@ -358,7 +359,7 @@ func deployClusterForMaxIgnorablePods(ctx goctx.Context, clusterNamespacedName t racks := getDummyRackConf(1, 2) aeroCluster.Spec.RackConfig = asdbv1.RackConfig{ Namespaces: []string{scNamespace}, Racks: racks} - aeroCluster.Spec.PodSpec.MultiPodPerHost = false + aeroCluster.Spec.PodSpec.MultiPodPerHost = ptr.To(false) err := deployCluster(k8sClient, ctx, aeroCluster) Expect(err).ToNot(HaveOccurred()) } @@ -1000,7 +1001,8 @@ func UpdateClusterTest(ctx goctx.Context) { ) Expect(err).ToNot(HaveOccurred()) - aeroCluster.Spec.PodSpec.MultiPodPerHost = !aeroCluster.Spec.PodSpec.MultiPodPerHost + multiPodPerHost := !*aeroCluster.Spec.PodSpec.MultiPodPerHost + aeroCluster.Spec.PodSpec.MultiPodPerHost = &multiPodPerHost err = k8sClient.Update(ctx, aeroCluster) Expect(err).Should(HaveOccurred()) diff --git a/test/host_network_test.go b/test/host_network_test.go index 5c1b5315d..136c74a1c 100644 --- a/test/host_network_test.go +++ b/test/host_network_test.go @@ -9,6 +9,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" + "k8s.io/utils/ptr" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" ) @@ -26,7 +27,7 @@ var _ = Describe( clusterNamespacedName, 2, latestImage, ) aeroCluster.Spec.PodSpec.HostNetwork = true - aeroCluster.Spec.PodSpec.MultiPodPerHost = true + aeroCluster.Spec.PodSpec.MultiPodPerHost = ptr.To(true) It( "Should not work with MultiPodPerHost enabled", func() { @@ -38,7 +39,7 @@ var _ = Describe( It( "Should verify hostNetwork flag updates", func() { By("Deploying cluster, Should not advertise node address when off") - aeroCluster.Spec.PodSpec.MultiPodPerHost = false + aeroCluster.Spec.PodSpec.MultiPodPerHost = ptr.To(false) aeroCluster.Spec.PodSpec.HostNetwork = false err := deployCluster(k8sClient, ctx, aeroCluster) diff --git a/test/k8snode_block_list_test.go b/test/k8snode_block_list_test.go index 9580576cb..0bee2e41c 100644 --- a/test/k8snode_block_list_test.go +++ b/test/k8snode_block_list_test.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + "k8s.io/utils/ptr" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -62,7 +64,7 @@ var _ = Describe( aeroCluster.Spec.RackConfig = rackConf - aeroCluster.Spec.PodSpec.MultiPodPerHost = false + aeroCluster.Spec.PodSpec.MultiPodPerHost = ptr.To(false) err = deployCluster(k8sClient, ctx, aeroCluster) Expect(err).ToNot(HaveOccurred()) diff --git a/test/ldap_auth_test.go b/test/ldap_auth_test.go index 52f4d16b3..f320064fd 100644 --- a/test/ldap_auth_test.go +++ b/test/ldap_auth_test.go @@ -8,14 +8,15 @@ import ( goctx "context" "time" - as "github.com/aerospike/aerospike-client-go/v6" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" + as "github.com/aerospike/aerospike-client-go/v6" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" ) @@ -146,7 +147,7 @@ func getAerospikeClusterSpecWithLDAP( }, }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), }, AerospikeConfig: &asdbv1.AerospikeConfigSpec{ Value: map[string]interface{}{ diff --git a/test/network_policy_test.go b/test/network_policy_test.go index 82f725484..3a1ba41bc 100644 --- a/test/network_policy_test.go +++ b/test/network_policy_test.go @@ -19,6 +19,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/retry" + "k8s.io/utils/ptr" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" aerospikecluster "github.com/aerospike/aerospike-kubernetes-operator/controllers" @@ -1205,8 +1206,8 @@ func getExpectedServicePortForPod( ) (int32, error) { var port int32 - if (networkType != asdbv1.AerospikeNetworkTypePod && - networkType != asdbv1.AerospikeNetworkTypeCustomInterface) && aeroCluster.Spec.PodSpec.MultiPodPerHost { + if (networkType != asdbv1.AerospikeNetworkTypePod && networkType != asdbv1.AerospikeNetworkTypeCustomInterface) && + asdbv1.GetBool(aeroCluster.Spec.PodSpec.MultiPodPerHost) { svc, err := getServiceForPod(pod, k8sClient) if err != nil { return 0, fmt.Errorf("error getting service port: %v", err) @@ -1346,7 +1347,7 @@ func getAerospikeClusterSpecWithNetworkPolicy( }, }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: multiPodPerHost, + MultiPodPerHost: ptr.To(multiPodPerHost), }, OperatorClientCertSpec: operatorClientCertSpec, AerospikeConfig: &asdbv1.AerospikeConfigSpec{ diff --git a/test/rack_management_test.go b/test/rack_management_test.go index 7edd0b93b..5d36c0dfc 100644 --- a/test/rack_management_test.go +++ b/test/rack_management_test.go @@ -8,6 +8,7 @@ import ( . "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" + "k8s.io/utils/ptr" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" ) @@ -810,7 +811,7 @@ var _ = Describe( aeroCluster := createDummyAerospikeCluster(clusterNamespacedName, int32(len(nodes.Items))) racks := getDummyRackConf(1, 2) aeroCluster.Spec.RackConfig = asdbv1.RackConfig{Racks: racks} - aeroCluster.Spec.PodSpec.MultiPodPerHost = false + aeroCluster.Spec.PodSpec.MultiPodPerHost = ptr.To(false) By("Deploying cluster") err = deployCluster(k8sClient, ctx, aeroCluster) diff --git a/test/storage_init_test.go b/test/storage_init_test.go index bc00d7a24..f5a28bc4d 100644 --- a/test/storage_init_test.go +++ b/test/storage_init_test.go @@ -15,6 +15,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" crClient "sigs.k8s.io/controller-runtime/pkg/client" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" @@ -792,7 +793,7 @@ func getStorageInitAerospikeCluster( SkipXdrDlogFileValidate: true, }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), }, AerospikeConfig: &asdbv1.AerospikeConfigSpec{ Value: map[string]interface{}{ diff --git a/test/storage_wipe_test.go b/test/storage_wipe_test.go index feef30681..dde382f23 100644 --- a/test/storage_wipe_test.go +++ b/test/storage_wipe_test.go @@ -11,6 +11,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" as "github.com/aerospike/aerospike-client-go/v6" @@ -230,8 +231,8 @@ func writeDataToCluster( } asClient, err := as.NewClientWithPolicyAndHost(policy, hostList...) - if err != nil { - return err + if asClient == nil { + return fmt.Errorf("aerospike client is nil %v", err) } defer asClient.Close() @@ -648,7 +649,7 @@ func getStorageWipeAerospikeCluster( SkipXdrDlogFileValidate: true, }, PodSpec: asdbv1.AerospikePodSpec{ - MultiPodPerHost: true, + MultiPodPerHost: ptr.To(true), }, AerospikeConfig: aerospikeConfigSpec, },