@@ -2,6 +2,7 @@ package scyllacluster
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
5
6
"sort"
6
7
"strings"
7
8
@@ -59,7 +60,7 @@ func verifyPersistentVolumeClaims(ctx context.Context, coreClient corev1client.C
59
60
o .Expect (scPVCNames ).To (o .BeEquivalentTo (expectedPvcNames ))
60
61
}
61
62
62
- func verifyStatefulset (sts * appsv1.StatefulSet , sdc * scyllav1alpha1.ScyllaDBDatacenter ) {
63
+ func verifyStatefulset (ctx context. Context , client corev1client. CoreV1Interface , sts * appsv1.StatefulSet , sdc * scyllav1alpha1.ScyllaDBDatacenter ) {
63
64
o .Expect (sts .ObjectMeta .OwnerReferences ).To (o .BeEquivalentTo (
64
65
[]metav1.OwnerReference {
65
66
{
@@ -75,8 +76,22 @@ func verifyStatefulset(sts *appsv1.StatefulSet, sdc *scyllav1alpha1.ScyllaDBData
75
76
o .Expect (sts .DeletionTimestamp ).To (o .BeNil ())
76
77
o .Expect (sts .Status .ObservedGeneration ).To (o .Equal (sts .Generation ))
77
78
o .Expect (sts .Spec .Replicas ).NotTo (o .BeNil ())
79
+ o .Expect (sts .Status .Replicas ).To (o .Equal (* sts .Spec .Replicas ))
78
80
o .Expect (sts .Status .ReadyReplicas ).To (o .Equal (* sts .Spec .Replicas ))
79
81
o .Expect (sts .Status .CurrentRevision ).To (o .Equal (sts .Status .UpdateRevision ))
82
+
83
+ // Verify pod invariants.
84
+ podMap , err := utils .GetPodsForStatefulSet (ctx , client , sts )
85
+ o .Expect (err ).NotTo (o .HaveOccurred ())
86
+ o .Expect (podMap ).To (o .HaveLen (int (sts .Status .Replicas )))
87
+
88
+ // No container in the Pod should be restarted.
89
+ for _ , pod := range podMap {
90
+ o .Expect (pod .Status .ContainerStatuses ).NotTo (o .BeEmpty ())
91
+ for _ , cs := range pod .Status .ContainerStatuses {
92
+ o .Expect (cs .RestartCount ).To (o .BeZero (), fmt .Sprintf ("container %q in pod %q should not be restarted" , cs .Name , pod .Name ))
93
+ }
94
+ }
80
95
}
81
96
82
97
func verifyPodDisruptionBudget (sc * scyllav1.ScyllaCluster , pdb * policyv1.PodDisruptionBudget , sdc * scyllav1alpha1.ScyllaDBDatacenter ) {
@@ -279,7 +294,7 @@ func Verify(ctx context.Context, kubeClient kubernetes.Interface, scyllaClient s
279
294
280
295
s := statefulsets [r .Name ]
281
296
282
- verifyStatefulset (s , sdc )
297
+ verifyStatefulset (ctx , kubeClient . CoreV1 (), s , sdc )
283
298
284
299
o .Expect (sc .Status .Racks [r .Name ].Stale ).NotTo (o .BeNil ())
285
300
o .Expect (* sc .Status .Racks [r .Name ].Stale ).To (o .BeFalse ())
0 commit comments