Skip to content

Commit 58ec314

Browse files
test
1 parent efd1d72 commit 58ec314

File tree

7 files changed

+36
-12
lines changed

7 files changed

+36
-12
lines changed

api/v1/aerospikecluster_types.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ type RackConfig struct { //nolint:govet // for readability
284284
// +optional
285285
RollingUpdateBatchSize *intstr.IntOrString `json:"rollingUpdateBatchSize,omitempty"`
286286

287-
MaxUnavailable int `json:"maxUnavailable,omitempty"`
287+
// +optional
288+
MaxIgnorableFailedPods int `json:"maxIgnorableFailedPods,omitempty"`
288289
}
289290

290291
// Rack specifies single rack config

config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4603,7 +4603,7 @@ spec:
46034603
Aerospike cluster. Pods will be deployed in given racks based on
46044604
given configuration
46054605
properties:
4606-
maxUnavailable:
4606+
maxIgnorableFailedPods:
46074607
type: integer
46084608
namespaces:
46094609
description: List of Aerospike namespaces for which rack feature
@@ -13352,7 +13352,7 @@ spec:
1335213352
given configuration
1335313353
nullable: true
1335413354
properties:
13355-
maxUnavailable:
13355+
maxIgnorableFailedPods:
1335613356
type: integer
1335713357
namespaces:
1335813358
description: List of Aerospike namespaces for which rack feature

controllers/pod.go

+26-5
Original file line numberDiff line numberDiff line change
@@ -671,25 +671,46 @@ func (r *SingleClusterReconciler) getIgnorablePods(racksToDelete []asdbv1.Rack,
671671

672672
for idx := range configureRacks {
673673
rack := &configureRacks[idx]
674-
failedAllowed := r.aeroCluster.Spec.RackConfig.MaxUnavailable
674+
failedAllowed := r.aeroCluster.Spec.RackConfig.MaxIgnorableFailedPods
675675

676676
podList, err := r.getRackPodList(rack.Rack.ID)
677677
if err != nil {
678678
return nil, err
679679
}
680680

681+
var (
682+
failedPod []string
683+
pendingPod []string
684+
)
685+
681686
for podIdx := range podList.Items {
682687
pod := &podList.Items[podIdx]
683-
if !utils.IsPodRunningAndReady(pod) && failedAllowed > 0 {
684-
ignorablePodNames.Insert(pod.Name)
685-
failedAllowed--
688+
689+
if !utils.IsPodRunningAndReady(pod) {
690+
if utils.IsPodReasonUnschedulable(pod) {
691+
pendingPod = append(pendingPod, pod.Name)
692+
continue
693+
}
694+
695+
failedPod = append(failedPod, pod.Name)
686696
}
687697
}
698+
699+
// prepend pendingPod to failedPod
700+
failedPod = append(pendingPod, failedPod...)
701+
702+
for podIdx := range failedPod {
703+
if failedAllowed <= 0 {
704+
break
705+
}
706+
707+
ignorablePodNames.Insert(failedPod[podIdx])
708+
failedAllowed--
709+
}
688710
}
689711

690712
return ignorablePodNames, nil
691713
}
692-
693714
func (r *SingleClusterReconciler) getPodsPVCList(
694715
podNames []string, rackID int,
695716
) ([]corev1.PersistentVolumeClaim, error) {

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.19
44

55
require (
66
github.com/aerospike/aerospike-client-go/v6 v6.14.0
7-
github.com/aerospike/aerospike-management-lib v0.0.0-20231107182540-fef71e1f5946
7+
github.com/aerospike/aerospike-management-lib v0.0.0-20231129055344-b6aff63f1dbb
88
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
99
github.com/evanphx/json-patch v4.12.0+incompatible
1010
github.com/go-logr/logr v1.2.4

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,8 @@ github.com/aerospike/aerospike-client-go/v6 v6.14.0 h1:Z3FcGWJda1sagzdc6Akz4EJ13
600600
github.com/aerospike/aerospike-client-go/v6 v6.14.0/go.mod h1:/0Wm81GhMqem+9flWcpazPKoRfjFeG6WrQdXGiMNi0A=
601601
github.com/aerospike/aerospike-management-lib v0.0.0-20231107182540-fef71e1f5946 h1:wwCzPj4qk4EfdISK6tzNoEwSLg9vbeqBloNmhfB8mNo=
602602
github.com/aerospike/aerospike-management-lib v0.0.0-20231107182540-fef71e1f5946/go.mod h1:LPOsGG8okRSH4hN9Y8VXFzsfIpBDj2WKEsI/f6wxwaw=
603+
github.com/aerospike/aerospike-management-lib v0.0.0-20231129055344-b6aff63f1dbb h1:ykX3ElBNT/VOUhw/+5+jiFnWw3LSbPfl6eRrhQzBBFk=
604+
github.com/aerospike/aerospike-management-lib v0.0.0-20231129055344-b6aff63f1dbb/go.mod h1:LPOsGG8okRSH4hN9Y8VXFzsfIpBDj2WKEsI/f6wxwaw=
603605
github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY=
604606
github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk=
605607
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=

pkg/utils/pod.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func CheckPodFailed(pod *corev1.Pod) error {
3232
return fmt.Errorf("pod %s has failed status", pod.Name)
3333
}
3434

35-
if pod.Status.Phase == corev1.PodPending && isPodReasonUnschedulable(pod) {
35+
if pod.Status.Phase == corev1.PodPending && IsPodReasonUnschedulable(pod) {
3636
return fmt.Errorf("pod %s is in unschedulable state", pod.Name)
3737
}
3838

@@ -210,7 +210,7 @@ func isPodError(reason string) bool {
210210
return strings.HasSuffix(reason, "Error")
211211
}
212212

213-
func isPodReasonUnschedulable(pod *corev1.Pod) bool {
213+
func IsPodReasonUnschedulable(pod *corev1.Pod) bool {
214214
for _, condition := range pod.Status.Conditions {
215215
if condition.Type == corev1.PodScheduled && condition.Reason == corev1.PodReasonUnschedulable {
216216
return true

test/cluster_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func clusterWithIgnorePodList(ctx goctx.Context) {
170170
By("Upgrade version")
171171
aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName)
172172
Expect(err).ToNot(HaveOccurred())
173-
newImage := baseImage + ":6.4.0.4"
173+
newImage := baseImage + ":7.0.0.0_2"
174174
aeroCluster.Spec.Image = newImage
175175
err = updateCluster(k8sClient, ctx, aeroCluster)
176176
Expect(err).ToNot(HaveOccurred())

0 commit comments

Comments
 (0)