@@ -118,7 +118,7 @@ var _ = Describe("ApplicationDisruptionBudget controller", func() {
118
118
return createdADB .Status .WatchedNodes
119
119
}, timeout , interval ).Should (Equal ([]string {"node1" }))
120
120
121
- By ("Adding Pods" )
121
+ By ("Adding more Pods" )
122
122
pod2 := newPod ("podadb2" , ADBNamespace , "node2" , podLabels )
123
123
Expect (k8sClient .Create (ctx , & pod2 )).Should (Succeed ())
124
124
@@ -129,9 +129,10 @@ var _ = Describe("ApplicationDisruptionBudget controller", func() {
129
129
return createdADB .Status .WatchedNodes
130
130
}, timeout , interval ).Should (Equal ([]string {"node1" , "node2" }))
131
131
132
- By ("Adding PVCs " )
132
+ By ("Adding a new PVC " )
133
133
pvc3 := newPVC ("pvc3" , ADBNamespace , "node3-pv-local" , podLabels )
134
- Expect (k8sClient .Create (ctx , & pvc3 )).Should (Succeed ())
134
+ Expect (k8sClient .Create (ctx , pvc3 .DeepCopy ())).Should (Succeed ())
135
+ Expect (k8sClient .Status ().Update (ctx , pvc3 .DeepCopy ())).Should (Succeed ())
135
136
136
137
By ("checking the ApplicationDisruptionBudget updated the status" )
137
138
Eventually (func () []string {
@@ -153,7 +154,8 @@ var _ = Describe("ApplicationDisruptionBudget controller", func() {
153
154
pod3 := newPod ("podadb3" , ADBNamespace , "" , podLabels )
154
155
Expect (k8sClient .Create (ctx , & pod3 )).Should (Succeed ())
155
156
pvc3 := newPVC ("pvc3" , ADBNamespace , "node3-pv-local" , podLabels )
156
- Expect (k8sClient .Create (ctx , & pvc3 )).Should (Succeed ())
157
+ Expect (k8sClient .Create (ctx , pvc3 .DeepCopy ())).Should (Succeed ())
158
+ Expect (k8sClient .Status ().Update (ctx , pvc3 .DeepCopy ())).Should (Succeed ())
157
159
158
160
By ("creating a budget that accepts one disruption" )
159
161
ndb := & nodedisruptionv1alpha1.ApplicationDisruptionBudget {
@@ -232,7 +234,8 @@ var _ = Describe("ApplicationDisruptionBudget controller", func() {
232
234
233
235
By ("Adding PVC" )
234
236
pvc := newPVC ("pvc" , ADBNamespace , "remote-pv" , podLabels )
235
- Expect (k8sClient .Create (ctx , & pvc )).Should (Succeed ())
237
+ Expect (k8sClient .Create (ctx , pvc .DeepCopy ())).Should (Succeed ())
238
+ Expect (k8sClient .Status ().Update (ctx , pvc .DeepCopy ())).Should (Succeed ())
236
239
237
240
By ("creating a budget that accepts one disruption" )
238
241
adb := & nodedisruptionv1alpha1.ApplicationDisruptionBudget {
@@ -265,6 +268,45 @@ var _ = Describe("ApplicationDisruptionBudget controller", func() {
265
268
Expect (adb .Status .WatchedNodes ).Should (BeEmpty ())
266
269
})
267
270
})
268
- })
269
271
272
+ When ("PVC is pending" , func () {
273
+ It ("is ignored by ADB" , func () {
274
+ By ("Adding PVC" )
275
+ pvc := newPVC ("pvc" , ADBNamespace , "remote-pv" , podLabels )
276
+ pvc .Status .Phase = corev1 .ClaimPending
277
+ Expect (k8sClient .Create (ctx , pvc .DeepCopy ())).Should (Succeed ())
278
+ Expect (k8sClient .Status ().Update (ctx , pvc .DeepCopy ())).Should (Succeed ())
279
+
280
+ By ("creating a budget that accepts one disruption" )
281
+ adb := & nodedisruptionv1alpha1.ApplicationDisruptionBudget {
282
+ TypeMeta : metav1.TypeMeta {
283
+ APIVersion : "nodedisruption.criteo.com/v1alpha1" ,
284
+ Kind : "ApplicationDisruptionBudget" ,
285
+ },
286
+ ObjectMeta : metav1.ObjectMeta {
287
+ Name : ADBname ,
288
+ Namespace : ADBNamespace ,
289
+ },
290
+ Spec : nodedisruptionv1alpha1.ApplicationDisruptionBudgetSpec {
291
+ PodSelector : metav1.LabelSelector {MatchLabels : podLabels },
292
+ PVCSelector : metav1.LabelSelector {MatchLabels : podLabels },
293
+ MaxDisruptions : 1 ,
294
+ },
295
+ }
296
+ Expect (k8sClient .Create (ctx , adb )).Should (Succeed ())
297
+
298
+ By ("checking the ApplicationDisruptionBudget updated the status and has seen no nodes" )
299
+ Eventually (func () int {
300
+ err := k8sClient .Get (ctx , types.NamespacedName {
301
+ Namespace : ADBNamespace ,
302
+ Name : ADBname ,
303
+ }, adb )
304
+ Expect (err ).Should (Succeed ())
305
+ return adb .Status .DisruptionsAllowed
306
+ }, timeout , interval ).Should (Equal (1 ))
307
+
308
+ Expect (adb .Status .WatchedNodes ).Should (BeEmpty ())
309
+ })
310
+ })
311
+ })
270
312
})
0 commit comments