@@ -36,7 +36,6 @@ import (
36
36
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
37
37
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
38
38
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/projection"
39
- "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison"
40
39
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
41
40
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
42
41
registryapi "github.com/operator-framework/operator-registry/pkg/api"
@@ -498,14 +497,20 @@ var _ = Describe("Subscription", func() {
498
497
return subscription != nil && subscription .Status .InstallPlanRef .Name != fetchedInstallPlan .GetName () && subscription .Status .State == operatorsv1alpha1 .SubscriptionStateUpgradePending , err
499
498
}, 5 * time .Minute , 1 * time .Second ).Should (BeTrue (), "expected new installplan for upgraded csv" )
500
499
501
- upgradeInstallPlan , err := fetchInstallPlanWithNamespace (GinkgoT (), crc , subscription .Status .InstallPlanRef .Name , generatedNamespace .GetName (), requiresApprovalChecker )
502
- require .NoError (GinkgoT (), err )
503
-
504
- // Approve the upgrade installplan and wait for
505
- upgradeInstallPlan .Spec .Approved = true
506
- _ , err = crc .OperatorsV1alpha1 ().InstallPlans (generatedNamespace .GetName ()).Update (context .Background (), upgradeInstallPlan , metav1.UpdateOptions {})
507
- require .NoError (GinkgoT (), err )
500
+ // Approve install plan
501
+ Eventually (func () (bool , error ) {
502
+ upgradeInstallPlan , err := fetchInstallPlanWithNamespace (GinkgoT (), crc , subscription .Status .InstallPlanRef .Name , generatedNamespace .GetName (), requiresApprovalChecker )
503
+ if err != nil {
504
+ return false , nil
505
+ }
508
506
507
+ // Approve the upgrade installplan and wait for
508
+ upgradeInstallPlan .Spec .Approved = true
509
+ if _ , err = crc .OperatorsV1alpha1 ().InstallPlans (generatedNamespace .GetName ()).Update (context .Background (), upgradeInstallPlan , metav1.UpdateOptions {}); err != nil {
510
+ return false , nil
511
+ }
512
+ return true , nil
513
+ }, 1 * time .Minute , 5 * time .Second ).Should (BeTrue (), "expected new installplan for upgraded csv" )
509
514
_ , err = awaitCSV (crc , generatedNamespace .GetName (), csvB .GetName (), csvSucceededChecker )
510
515
require .NoError (GinkgoT (), err )
511
516
@@ -1035,6 +1040,7 @@ var _ = Describe("Subscription", func() {
1035
1040
// - Wait for sub to have status condition SubscriptionInstallPlanMissing true
1036
1041
// - Ensure original non-InstallPlan status conditions remain after InstallPlan transitions
1037
1042
It ("can reconcile InstallPlan status" , func () {
1043
+ By (`TestSubscriptionInstallPlanStatus ensures that a Subscription has the appropriate status conditions for possible referenced InstallPlan states.` )
1038
1044
c := newKubeClient ()
1039
1045
crc := newCRClient ()
1040
1046
@@ -1081,6 +1087,7 @@ var _ = Describe("Subscription", func() {
1081
1087
ref := sub .Status .InstallPlanRef
1082
1088
Expect (ref ).ToNot (BeNil ())
1083
1089
1090
+ By (`Get the InstallPlan` )
1084
1091
plan := & operatorsv1alpha1.InstallPlan {}
1085
1092
plan .SetNamespace (ref .Namespace )
1086
1093
plan .SetName (ref .Name )
@@ -1192,16 +1199,13 @@ var _ = Describe("Subscription", func() {
1192
1199
Expect (err ).ToNot (HaveOccurred ())
1193
1200
Expect (sub ).ToNot (BeNil ())
1194
1201
1195
- // Ensure original non-InstallPlan status conditions remain after InstallPlan transitions
1196
- hashEqual := comparison .NewHashEqualitor ()
1202
+ By (`Ensure InstallPlan-related status conditions match what we're expecting` )
1197
1203
for _ , cond := range conds {
1198
1204
switch condType := cond .Type ; condType {
1199
1205
case operatorsv1alpha1 .SubscriptionInstallPlanPending , operatorsv1alpha1 .SubscriptionInstallPlanFailed :
1200
1206
require .FailNowf (GinkgoT (), "failed" , "subscription contains unexpected installplan condition: %v" , cond )
1201
1207
case operatorsv1alpha1 .SubscriptionInstallPlanMissing :
1202
1208
require .Equal (GinkgoT (), operatorsv1alpha1 .ReferencedInstallPlanNotFound , cond .Reason )
1203
- default :
1204
- require .True (GinkgoT (), hashEqual (cond , sub .Status .GetCondition (condType )), "non-installplan status condition changed" )
1205
1209
}
1206
1210
}
1207
1211
})
@@ -2825,14 +2829,53 @@ func subscriptionHasCurrentCSV(currentCSV string) subscriptionStateChecker {
2825
2829
}
2826
2830
2827
2831
func subscriptionHasCondition (condType operatorsv1alpha1.SubscriptionConditionType , status corev1.ConditionStatus , reason , message string ) subscriptionStateChecker {
2832
+ var lastCond operatorsv1alpha1.SubscriptionCondition
2833
+ lastTime := time .Now ()
2834
+ // if status/reason/message meet expectations, then subscription state is considered met/true
2835
+ // IFF this is the result of a recent change of status/reason/message
2836
+ // else, cache the current status/reason/message for next loop/comparison
2828
2837
return func (subscription * operatorsv1alpha1.Subscription ) bool {
2829
2838
cond := subscription .Status .GetCondition (condType )
2830
2839
if cond .Status == status && cond .Reason == reason && cond .Message == message {
2831
- fmt .Printf ("subscription condition met %v\n " , cond )
2840
+ if lastCond .Status != cond .Status && lastCond .Reason != cond .Reason && lastCond .Message == cond .Message {
2841
+ GinkgoT ().Logf ("waited %s subscription condition met %v\n " , time .Since (lastTime ), cond )
2842
+ lastTime = time .Now ()
2843
+ lastCond = cond
2844
+ }
2845
+ return true
2846
+ }
2847
+
2848
+ if lastCond .Status != cond .Status && lastCond .Reason != cond .Reason && lastCond .Message == cond .Message {
2849
+ GinkgoT ().Logf ("waited %s subscription condition not met: %v\n " , time .Since (lastTime ), cond )
2850
+ lastTime = time .Now ()
2851
+ lastCond = cond
2852
+ }
2853
+ return false
2854
+ }
2855
+ }
2856
+
2857
+ func subscriptionDoesNotHaveCondition (condType operatorsv1alpha1.SubscriptionConditionType ) subscriptionStateChecker {
2858
+ var lastStatus corev1.ConditionStatus
2859
+ lastTime := time .Now ()
2860
+ // if status meets expectations, then subscription state is considered met/true
2861
+ // IFF this is the result of a recent change of status
2862
+ // else, cache the current status for next loop/comparison
2863
+ return func (subscription * operatorsv1alpha1.Subscription ) bool {
2864
+ cond := subscription .Status .GetCondition (condType )
2865
+ if cond .Status == corev1 .ConditionUnknown {
2866
+ if cond .Status != lastStatus {
2867
+ GinkgoT ().Logf ("waited %s subscription condition not found\n " , time .Since (lastTime ))
2868
+ lastStatus = cond .Status
2869
+ lastTime = time .Now ()
2870
+ }
2832
2871
return true
2833
2872
}
2834
2873
2835
- fmt .Printf ("subscription condition not met: %v\n " , cond )
2874
+ if cond .Status != lastStatus {
2875
+ GinkgoT ().Logf ("waited %s subscription condition found: %v\n " , time .Since (lastTime ), cond )
2876
+ lastStatus = cond .Status
2877
+ lastTime = time .Now ()
2878
+ }
2836
2879
return false
2837
2880
}
2838
2881
}
0 commit comments