@@ -170,7 +170,7 @@ var _ = Describe("Drift", func() {
170
170
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
171
171
172
172
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
173
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
173
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
174
174
})
175
175
It ("should remove the status condition from the nodeClaim when the nodeClaim launch condition is false" , func () {
176
176
cp .Drifted = "drifted"
@@ -182,15 +182,15 @@ var _ = Describe("Drift", func() {
182
182
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
183
183
184
184
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
185
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
185
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
186
186
})
187
187
It ("should not detect drift if the nodePool does not exist" , func () {
188
188
cp .Drifted = "drifted"
189
189
ExpectApplied (ctx , env .Client , nodeClaim )
190
190
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
191
191
192
192
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
193
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
193
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
194
194
})
195
195
It ("should remove the status condition from the nodeClaim if the nodeClaim is no longer drifted" , func () {
196
196
nodeClaim .StatusConditions ().SetTrue (v1 .ConditionTypeDrifted )
@@ -199,7 +199,17 @@ var _ = Describe("Drift", func() {
199
199
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
200
200
201
201
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
202
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )).To (BeNil ())
202
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ).IsTrue ()).To (BeFalse ())
203
+ })
204
+ It ("should set the drifted condition to false if unset after reconcile" , func () {
205
+ cp .Drifted = ""
206
+ _ = nodeClaim .StatusConditions ().Clear (v1 .ConditionTypeDrifted )
207
+ ExpectApplied (ctx , env .Client , nodePool , nodeClaim )
208
+
209
+ ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
210
+
211
+ nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
212
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ).IsTrue ()).To (BeFalse ())
203
213
})
204
214
Context ("NodeRequirement Drift" , func () {
205
215
DescribeTable ("" ,
@@ -210,7 +220,7 @@ var _ = Describe("Drift", func() {
210
220
ExpectApplied (ctx , env .Client , nodePool , nodeClaim )
211
221
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
212
222
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
213
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
223
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
214
224
215
225
nodePool .Spec .Template .Spec .Requirements = newNodePoolReq
216
226
ExpectApplied (ctx , env .Client , nodePool )
@@ -219,7 +229,7 @@ var _ = Describe("Drift", func() {
219
229
if drifted {
220
230
Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ).IsTrue ()).To (BeTrue ())
221
231
} else {
222
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
232
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
223
233
}
224
234
},
225
235
Entry (
@@ -384,8 +394,8 @@ var _ = Describe("Drift", func() {
384
394
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaimTwo )
385
395
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
386
396
nodeClaimTwo = ExpectExists (ctx , env .Client , nodeClaimTwo )
387
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
388
- Expect (nodeClaimTwo .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
397
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
398
+ Expect (nodeClaimTwo .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
389
399
390
400
// Removed Windows OS
391
401
nodePool .Spec .Template .Spec .Requirements = []v1.NodeSelectorRequirementWithMinValues {
@@ -396,7 +406,7 @@ var _ = Describe("Drift", func() {
396
406
397
407
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
398
408
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
399
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
409
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
400
410
401
411
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaimTwo )
402
412
nodeClaimTwo = ExpectExists (ctx , env .Client , nodeClaimTwo )
@@ -457,7 +467,7 @@ var _ = Describe("Drift", func() {
457
467
ExpectObjectReconciled (ctx , env .Client , nodePoolController , nodePool )
458
468
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
459
469
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
460
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
470
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
461
471
462
472
nodePool = ExpectExists (ctx , env .Client , nodePool )
463
473
Expect (mergo .Merge (nodePool , changes , mergo .WithOverride )).To (Succeed ())
@@ -481,7 +491,7 @@ var _ = Describe("Drift", func() {
481
491
ExpectApplied (ctx , env .Client , nodePool , nodeClaim )
482
492
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
483
493
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
484
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
494
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
485
495
})
486
496
It ("should not return drifted if karpenter.sh/nodepool-hash annotation is not present on the NodeClaim" , func () {
487
497
nodeClaim .ObjectMeta .Annotations = map [string ]string {
@@ -490,7 +500,7 @@ var _ = Describe("Drift", func() {
490
500
ExpectApplied (ctx , env .Client , nodePool , nodeClaim )
491
501
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
492
502
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
493
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
503
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
494
504
})
495
505
It ("should not return drifted if the NodeClaim's karpenter.sh/nodepool-hash-version annotation does not match the NodePool's" , func () {
496
506
nodePool .ObjectMeta .Annotations = map [string ]string {
@@ -504,7 +514,7 @@ var _ = Describe("Drift", func() {
504
514
ExpectApplied (ctx , env .Client , nodePool , nodeClaim )
505
515
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
506
516
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
507
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
517
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
508
518
})
509
519
It ("should not return drifted if karpenter.sh/nodepool-hash-version annotation is not present on the NodeClaim" , func () {
510
520
nodeClaim .ObjectMeta .Annotations = map [string ]string {
@@ -513,7 +523,7 @@ var _ = Describe("Drift", func() {
513
523
ExpectApplied (ctx , env .Client , nodePool , nodeClaim )
514
524
ExpectObjectReconciled (ctx , env .Client , nodeClaimDisruptionController , nodeClaim )
515
525
nodeClaim = ExpectExists (ctx , env .Client , nodeClaim )
516
- Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted )) .To (BeNil ())
526
+ Expect (nodeClaim .StatusConditions ().Get (v1 .ConditionTypeDrifted ). IsTrue ()) .To (BeFalse ())
517
527
})
518
528
})
519
529
})
0 commit comments