@@ -425,13 +425,24 @@ var _ = Describe("Upgrade scenarios", func() {
425
425
mockUpgrader .EXPECT ().GetCurrentVersion (gomock .Any ()).Return (desiredVersion , nil )
426
426
mockUpgrader .EXPECT ().IsDesiredVersionUpdated (gomock .Any (), desiredVersion ).Return (true , nil )
427
427
428
+ // Make sure upgrade is in progress: once we reconcile it should be marked as complete
429
+ conditions .MarkFalse (
430
+ openshiftAssistedControlPlane ,
431
+ controlplanev1alpha2 .UpgradeCompletedCondition ,
432
+ controlplanev1alpha2 .UpgradeInProgressReason ,
433
+ clusterv1 .ConditionSeverityWarning ,
434
+ "upgrade in progress" ,
435
+ )
436
+ Expect (k8sClient .Status ().Update (ctx , openshiftAssistedControlPlane )).To (Succeed ())
437
+
428
438
result , err := controllerReconciler .Reconcile (ctx , reconcile.Request {NamespacedName : typeNamespacedName })
429
439
Expect (err ).NotTo (HaveOccurred ())
430
440
Expect (result ).To (Equal (ctrlruntime.Result {}))
431
441
432
442
err = k8sClient .Get (ctx , typeNamespacedName , openshiftAssistedControlPlane )
433
443
Expect (err ).NotTo (HaveOccurred ())
434
444
Expect (openshiftAssistedControlPlane .Status .DistributionVersion ).To (Equal (desiredVersion ))
445
+
435
446
condition := conditions .Get (openshiftAssistedControlPlane , controlplanev1alpha2 .UpgradeCompletedCondition )
436
447
Expect (condition ).NotTo (BeNil ())
437
448
Expect (condition .Status ).To (Equal (corev1 .ConditionTrue ))
@@ -445,9 +456,23 @@ var _ = Describe("Upgrade scenarios", func() {
445
456
mockUpgrader .EXPECT ().IsDesiredVersionUpdated (gomock .Any (), desiredVersion ).Return (false , nil )
446
457
mockUpgrader .EXPECT ().UpdateClusterVersionDesiredUpdate (gomock .Any (), desiredVersion , gomock .Any ()).Return (expectedError )
447
458
459
+ // Make sure upgrade is in progress(not completed): even if we get no current version, now the upgrade is over
460
+ conditions .MarkFalse (
461
+ openshiftAssistedControlPlane ,
462
+ controlplanev1alpha2 .UpgradeCompletedCondition ,
463
+ controlplanev1alpha2 .UpgradeInProgressReason ,
464
+ clusterv1 .ConditionSeverityWarning ,
465
+ "upgrade in progress" ,
466
+ )
467
+
448
468
_ , err := controllerReconciler .Reconcile (ctx , reconcile.Request {NamespacedName : typeNamespacedName })
449
469
Expect (err ).To (HaveOccurred ())
450
470
Expect (err ).To (Equal (expectedError ))
471
+
472
+ // Upgrade is in progres: spec.distributionVersion is 4.15 and status.distributionVersion is 4.14
473
+ condition := conditions .Get (openshiftAssistedControlPlane , controlplanev1alpha2 .UpgradeCompletedCondition )
474
+ Expect (condition ).NotTo (BeNil ())
475
+ Expect (condition .Status ).To (Equal (corev1 .ConditionFalse ))
451
476
})
452
477
453
478
It ("should handle errors getting current version" , func () {
@@ -463,6 +488,10 @@ var _ = Describe("Upgrade scenarios", func() {
463
488
err = k8sClient .Get (ctx , typeNamespacedName , openshiftAssistedControlPlane )
464
489
Expect (err ).NotTo (HaveOccurred ())
465
490
Expect (openshiftAssistedControlPlane .Status .DistributionVersion ).To (Equal ("" ))
491
+
492
+ // upgrade never requested, condition should still be nil
493
+ condition := conditions .Get (openshiftAssistedControlPlane , controlplanev1alpha2 .UpgradeCompletedCondition )
494
+ Expect (condition ).To (BeNil ())
466
495
})
467
496
468
497
It ("should handle upgrade with repository override" , func () {
@@ -488,6 +517,12 @@ var _ = Describe("Upgrade scenarios", func() {
488
517
489
518
_ , err := controllerReconciler .Reconcile (ctx , reconcile.Request {NamespacedName : typeNamespacedName })
490
519
Expect (err ).NotTo (HaveOccurred ())
520
+
521
+ err = k8sClient .Get (ctx , typeNamespacedName , openshiftAssistedControlPlane )
522
+ Expect (err ).NotTo (HaveOccurred ())
523
+ condition := conditions .Get (openshiftAssistedControlPlane , controlplanev1alpha2 .UpgradeCompletedCondition )
524
+ Expect (condition ).NotTo (BeNil ())
525
+ Expect (condition .Status ).To (Equal (corev1 .ConditionFalse ))
491
526
})
492
527
})
493
528
0 commit comments