Skip to content

Commit

Permalink
Incorporated review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekdwivedi3060 committed Jan 23, 2025
1 parent fbd6fc8 commit b392601
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 34 deletions.
24 changes: 9 additions & 15 deletions api/v1/aerospikecluster_validating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1
import (
"crypto/x509"
"encoding/pem"
"errors"
"fmt"
"os"
"path/filepath"
Expand All @@ -37,7 +36,6 @@ import (
"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"
)
Expand Down Expand Up @@ -680,12 +678,12 @@ func getNsConfForNamespaces(rackConfig RackConfig) map[string]nsConf {

// TODO: This should be version specific and part of management lib.
// max cluster size for 5.0+ cluster
const maxEnterpriseClusterSzGt5_0 = 256
const maxEnterpriseClusterSize = 256

func validateClusterSize(_ logr.Logger, sz int) error {
if sz > maxEnterpriseClusterSzGt5_0 {
if sz > maxEnterpriseClusterSize {
return fmt.Errorf(
"cluster size cannot be more than %d", maxEnterpriseClusterSzGt5_0,
"cluster size cannot be more than %d", maxEnterpriseClusterSize,
)
}

Expand Down Expand Up @@ -1274,20 +1272,16 @@ func validateSecurityConfigUpdate(newSpec, oldSpec, currentStatus *AerospikeConf
func validateSecurityContext(newSpec, oldSpec *AerospikeConfigSpec) error {
ovflag, err := IsSecurityEnabled(oldSpec)
if err != nil {
if !errors.Is(err, internalerrors.ErrNotFound) {
return fmt.Errorf(
"failed to validate Security context of old aerospike conf: %w", err,
)
}
return fmt.Errorf(
"failed to validate Security context of old aerospike conf: %w", err,
)
}

ivflag, err := IsSecurityEnabled(newSpec)
if err != nil {
if !errors.Is(err, internalerrors.ErrNotFound) {
return fmt.Errorf(
"failed to validate Security context of new aerospike conf: %w", err,
)
}
return fmt.Errorf(
"failed to validate Security context of new aerospike conf: %w", err,
)
}

if !ivflag && ovflag {
Expand Down
28 changes: 9 additions & 19 deletions internal/controller/cluster/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,16 @@ func (r *SingleClusterReconciler) getRollingRestartTypeMap(rackState *RackState,
return nil, nil, err
}

v, err := lib.CompareVersions(version, "6.0.0")
if err != nil {
return nil, nil, err
}

// If version >= 6.0.0, then we can update config dynamically.
if v >= 0 {
// If EnableDynamicConfigUpdate is set and dynamic config command exec partially failed in previous try
// then skip dynamic config update and fall back to rolling restart.
// Continue with dynamic config update in case of Failed DynamicConfigUpdateStatus
if asdbv1.GetBool(r.aeroCluster.Spec.EnableDynamicConfigUpdate) &&
podStatus.DynamicConfigUpdateStatus != asdbv1.PartiallyFailed {
// Fetching all dynamic config change.
dynamicConfDiffPerPod[pods[idx].Name], err = r.handleDynamicConfigChange(rackState, pods[idx], version)
if err != nil {
return nil, nil, err
}
// If EnableDynamicConfigUpdate is set and dynamic config command exec partially failed in previous try
// then skip dynamic config update and fall back to rolling restart.
// Continue with dynamic config update in case of Failed DynamicConfigUpdateStatus
if asdbv1.GetBool(r.aeroCluster.Spec.EnableDynamicConfigUpdate) &&
podStatus.DynamicConfigUpdateStatus != asdbv1.PartiallyFailed {
// Fetching all dynamic config change.
dynamicConfDiffPerPod[pods[idx].Name], err = r.handleDynamicConfigChange(rackState, pods[idx], version)
if err != nil {
return nil, nil, err
}
} else {
r.Log.Info("Dynamic config change not supported for version < 6.0.0", "currentVersion", version)
}
}

Expand Down

0 comments on commit b392601

Please sign in to comment.