@@ -32,7 +32,6 @@ import (
32
32
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
33
33
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
34
34
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/projection"
35
- "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison"
36
35
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
37
36
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
38
37
registryapi "github.com/operator-framework/operator-registry/pkg/api"
@@ -485,15 +484,13 @@ var _ = Describe("Subscription", func() {
485
484
return subscription != nil && subscription .Status .InstallPlanRef .Name != fetchedInstallPlan .GetName () && subscription .Status .State == operatorsv1alpha1 .SubscriptionStateUpgradePending , err
486
485
}, 5 * time .Minute , 1 * time .Second ).Should (BeTrue (), "expected new installplan for upgraded csv" )
487
486
488
- upgradeInstallPlan , err := fetchInstallPlanWithNamespace (GinkgoT (), crc , subscription .Status .InstallPlanRef .Name , generatedNamespace .GetName (), requiresApprovalChecker )
489
- require .NoError (GinkgoT (), err )
490
-
491
- // Approve the upgrade installplan and wait for
492
- upgradeInstallPlan .Spec .Approved = true
493
- _ , err = crc .OperatorsV1alpha1 ().InstallPlans (generatedNamespace .GetName ()).Update (context .Background (), upgradeInstallPlan , metav1.UpdateOptions {})
494
- require .NoError (GinkgoT (), err )
495
-
487
+ // Approve install plan
496
488
Eventually (func () (bool , error ) {
489
+ upgradeInstallPlan , err := fetchInstallPlanWithNamespace (GinkgoT (), crc , subscription .Status .InstallPlanRef .Name , generatedNamespace .GetName (), requiresApprovalChecker )
490
+ if err != nil {
491
+ return false , nil
492
+ }
493
+
497
494
// Approve the upgrade installplan and wait for
498
495
upgradeInstallPlan .Spec .Approved = true
499
496
if _ , err = crc .OperatorsV1alpha1 ().InstallPlans (generatedNamespace .GetName ()).Update (context .Background (), upgradeInstallPlan , metav1.UpdateOptions {}); err != nil {
@@ -1028,6 +1025,7 @@ var _ = Describe("Subscription", func() {
1028
1025
// - Wait for sub to have status condition SubscriptionInstallPlanMissing true
1029
1026
// - Ensure original non-InstallPlan status conditions remain after InstallPlan transitions
1030
1027
It ("can reconcile InstallPlan status" , func () {
1028
+ By (`TestSubscriptionInstallPlanStatus ensures that a Subscription has the appropriate status conditions for possible referenced InstallPlan states.` )
1031
1029
c := newKubeClient ()
1032
1030
crc := newCRClient ()
1033
1031
@@ -1074,6 +1072,7 @@ var _ = Describe("Subscription", func() {
1074
1072
ref := sub .Status .InstallPlanRef
1075
1073
Expect (ref ).ToNot (BeNil ())
1076
1074
1075
+ By (`Get the InstallPlan` )
1077
1076
plan := & operatorsv1alpha1.InstallPlan {}
1078
1077
plan .SetNamespace (ref .Namespace )
1079
1078
plan .SetName (ref .Name )
@@ -1185,16 +1184,13 @@ var _ = Describe("Subscription", func() {
1185
1184
Expect (err ).ToNot (HaveOccurred ())
1186
1185
Expect (sub ).ToNot (BeNil ())
1187
1186
1188
- // Ensure original non-InstallPlan status conditions remain after InstallPlan transitions
1189
- hashEqual := comparison .NewHashEqualitor ()
1187
+ By (`Ensure InstallPlan-related status conditions match what we're expecting` )
1190
1188
for _ , cond := range conds {
1191
1189
switch condType := cond .Type ; condType {
1192
1190
case operatorsv1alpha1 .SubscriptionInstallPlanPending , operatorsv1alpha1 .SubscriptionInstallPlanFailed :
1193
1191
require .FailNowf (GinkgoT (), "failed" , "subscription contains unexpected installplan condition: %v" , cond )
1194
1192
case operatorsv1alpha1 .SubscriptionInstallPlanMissing :
1195
1193
require .Equal (GinkgoT (), operatorsv1alpha1 .ReferencedInstallPlanNotFound , cond .Reason )
1196
- default :
1197
- require .True (GinkgoT (), hashEqual (cond , sub .Status .GetCondition (condType )), "non-installplan status condition changed" )
1198
1194
}
1199
1195
}
1200
1196
})
@@ -2638,14 +2634,27 @@ func subscriptionHasCurrentCSV(currentCSV string) subscriptionStateChecker {
2638
2634
}
2639
2635
2640
2636
func subscriptionHasCondition (condType operatorsv1alpha1.SubscriptionConditionType , status corev1.ConditionStatus , reason , message string ) subscriptionStateChecker {
2637
+ var lastCond operatorsv1alpha1.SubscriptionCondition
2638
+ lastTime := time .Now ()
2639
+ // if status/reason/message meet expectations, then subscription state is considered met/true
2640
+ // IFF this is the result of a recent change of status/reason/message
2641
+ // else, cache the current status/reason/message for next loop/comparison
2641
2642
return func (subscription * operatorsv1alpha1.Subscription ) bool {
2642
2643
cond := subscription .Status .GetCondition (condType )
2643
2644
if cond .Status == status && cond .Reason == reason && cond .Message == message {
2644
- fmt .Printf ("subscription condition met %v\n " , cond )
2645
+ if lastCond .Status != cond .Status && lastCond .Reason != cond .Reason && lastCond .Message == cond .Message {
2646
+ GinkgoT ().Logf ("waited %s subscription condition met %v\n " , time .Since (lastTime ), cond )
2647
+ lastTime = time .Now ()
2648
+ lastCond = cond
2649
+ }
2645
2650
return true
2646
2651
}
2647
2652
2648
- fmt .Printf ("subscription condition not met: %v\n " , cond )
2653
+ if lastCond .Status != cond .Status && lastCond .Reason != cond .Reason && lastCond .Message == cond .Message {
2654
+ GinkgoT ().Logf ("waited %s subscription condition not met: %v\n " , time .Since (lastTime ), cond )
2655
+ lastTime = time .Now ()
2656
+ lastCond = cond
2657
+ }
2649
2658
return false
2650
2659
}
2651
2660
}
0 commit comments