Skip to content

Commit

Permalink
fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Mar 4, 2024
1 parent e9a798d commit f26f3f0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
60 changes: 34 additions & 26 deletions controllers/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,8 @@ func (r *SingleClusterReconciler) Reconcile() (result ctrl.Result, recErr error)
return reconcile.Result{}, recErr
}

if r.aeroCluster.Status.Pods != nil && r.enablingSecurity() {
securityEnabledPods, err := r.getSecurityEnabledPods()
if err != nil {
return reconcile.Result{}, err
}

if len(securityEnabledPods) > 0 {
ignorablePodNames, err := r.getIgnorablePods(nil, getConfiguredRackStateList(r.aeroCluster))
if err != nil {
r.Log.Error(err, "Failed to determine pods to be ignored")

return reconcile.Result{}, err
}

// Setup access control.
if err := r.validateAndReconcileAccessControl(securityEnabledPods, ignorablePodNames); err != nil {
r.Log.Error(err, "Failed to Reconcile access control")
r.Recorder.Eventf(
r.aeroCluster, corev1.EventTypeWarning, "ACLUpdateFailed",
"Failed to setup Access Control %s/%s", r.aeroCluster.Namespace,
r.aeroCluster.Name,
)

return reconcile.Result{}, err
}
}
if err := r.handleEnableSecurity(); err != nil {
return reconcile.Result{}, err
}

// Reconcile all racks
Expand Down Expand Up @@ -1046,3 +1022,35 @@ func (r *SingleClusterReconciler) getSecurityEnabledPods() ([]corev1.Pod, error)
func (r *SingleClusterReconciler) enablingSecurity() bool {
return r.aeroCluster.Spec.AerospikeAccessControl != nil && r.aeroCluster.Status.AerospikeAccessControl == nil
}

func (r *SingleClusterReconciler) handleEnableSecurity() error {
if r.aeroCluster.Status.Pods != nil && r.enablingSecurity() {
securityEnabledPods, err := r.getSecurityEnabledPods()
if err != nil {
return err
}

if len(securityEnabledPods) > 0 {
ignorablePodNames, err := r.getIgnorablePods(nil, getConfiguredRackStateList(r.aeroCluster))
if err != nil {
r.Log.Error(err, "Failed to determine pods to be ignored")

return err
}

// Setup access control.
if err := r.validateAndReconcileAccessControl(securityEnabledPods, ignorablePodNames); err != nil {
r.Log.Error(err, "Failed to Reconcile access control")
r.Recorder.Eventf(
r.aeroCluster, corev1.EventTypeWarning, "ACLUpdateFailed",
"Failed to setup Access Control %s/%s", r.aeroCluster.Namespace,
r.aeroCluster.Name,
)

return err
}
}
}

return nil
}

0 comments on commit f26f3f0

Please sign in to comment.