Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekdwivedi3060 committed Nov 28, 2023
1 parent 49b530c commit 572dc51
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
2 changes: 2 additions & 0 deletions api/v1/aerospikecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ type RackConfig struct { //nolint:govet // for readability
// RollingUpdateBatchSize is the percentage/number of rack pods that will be restarted simultaneously
// +optional
RollingUpdateBatchSize *intstr.IntOrString `json:"rollingUpdateBatchSize,omitempty"`

MaxUnavailable int `json:"maxUnavailable,omitempty"`
}

// Rack specifies single rack config
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4603,6 +4603,8 @@ spec:
Aerospike cluster. Pods will be deployed in given racks based on
given configuration
properties:
maxUnavailable:
type: integer
namespaces:
description: List of Aerospike namespaces for which rack feature
will be enabled
Expand Down Expand Up @@ -13350,6 +13352,8 @@ spec:
given configuration
nullable: true
properties:
maxUnavailable:
type: integer
namespaces:
description: List of Aerospike namespaces for which rack feature
will be enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ spec:
the Aerospike cluster.
displayName: Aerospike Network Policy
path: aerospikeNetworkPolicy
- description: IgnorePodList is the list of pods which are ignored by the operator
while checking the cluster stability and are not considered part of cluster.
This is only useful when there are some failed pods and operator is required
to do some operation on the cluster. If pods in running state are defined
in this list, they are not ignored.
- description: IgnorePodList is a list of pods that the operator will ignore
while assessing cluster stability. Pods specified in this list are not considered
part of the cluster. This is particularly useful when there are failed pods
and the operator needs to perform certain operations on the cluster. Note
that running pods included in this list will not be ignored.
displayName: Ignore Pod List
path: ignorePodList
- description: Aerospike server image
Expand Down
24 changes: 14 additions & 10 deletions controllers/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ func (r *SingleClusterReconciler) cleanupDanglingPodsRack(sts *appsv1.StatefulSe
// getIgnorablePods returns pods:
// 1. From racksToDelete that are currently not running and can be ignored in stability checks.
// 2. User given pods in ignorePodList that are currently not running and can be ignored from stability checks.
func (r *SingleClusterReconciler) getIgnorablePods(racksToDelete []asdbv1.Rack) (
func (r *SingleClusterReconciler) getIgnorablePods(racksToDelete []asdbv1.Rack, configureRacks []RackState) (
sets.Set[string], error,
) {
ignorablePodNames := sets.Set[string]{}
Expand All @@ -669,17 +669,21 @@ func (r *SingleClusterReconciler) getIgnorablePods(racksToDelete []asdbv1.Rack)
}
}

podList, err := r.getClusterPodList()
if err != nil {
return nil, err
}
for idx := range configureRacks {
rack := &configureRacks[idx]
failedAllowed := r.aeroCluster.Spec.RackConfig.MaxUnavailable

userIgnorePodSet := sets.NewString(r.aeroCluster.Spec.IgnorePodList...)
podList, err := r.getRackPodList(rack.Rack.ID)
if err != nil {
return nil, err
}

for podIdx := range podList.Items {
pod := &podList.Items[podIdx]
if userIgnorePodSet.Has(pod.Name) && !utils.IsPodRunningAndReady(pod) {
ignorablePodNames.Insert(pod.Name)
for podIdx := range podList.Items {
pod := &podList.Items[podIdx]
if !utils.IsPodRunningAndReady(pod) && failedAllowed > 0 {
ignorablePodNames.Insert(pod.Name)
failedAllowed--
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/rack.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (r *SingleClusterReconciler) reconcileRacks() reconcileResult {
rackIDsToDelete = append(rackIDsToDelete, racksToDelete[idx].ID)
}

ignorablePodNames, err := r.getIgnorablePods(racksToDelete)
ignorablePodNames, err := r.getIgnorablePods(racksToDelete, rackStateList)
if err != nil {
return reconcileError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *SingleClusterReconciler) Reconcile() (ctrl.Result, error) {
return reconcile.Result{}, err
}

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

Expand Down

0 comments on commit 572dc51

Please sign in to comment.