@@ -58,12 +58,18 @@ var _ = Describe("Fail Forward Upgrades", func() {
58
58
When ("an InstallPlan is reporting a failed state" , func () {
59
59
60
60
var (
61
- magicCatalog * MagicCatalog
62
- catalogSourceName string
63
- subscription * operatorsv1alpha1.Subscription
61
+ magicCatalog * MagicCatalog
62
+ catalogSourceName string
63
+ subscription * operatorsv1alpha1.Subscription
64
+ originalInstallPlanRef * corev1.ObjectReference
65
+ failedInstallPlanRef * corev1.ObjectReference
64
66
)
65
67
66
68
BeforeEach (func () {
69
+ By ("creating a service account with no permission" )
70
+ saNameWithNoPerms := genName ("scoped-sa-" )
71
+ newServiceAccount (ctx .Ctx ().KubeClient (), ns .GetName (), saNameWithNoPerms )
72
+
67
73
By ("deploying the testing catalog" )
68
74
provider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , failForwardTestDataBaseDir , "example-operator.v0.1.0.yaml" ))
69
75
Expect (err ).To (BeNil ())
@@ -90,19 +96,18 @@ var _ = Describe("Fail Forward Upgrades", func() {
90
96
subscription , err := fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanChecker )
91
97
Expect (err ).Should (BeNil ())
92
98
93
- originalInstallPlanRef : = subscription .Status .InstallPlanRef
99
+ originalInstallPlanRef = subscription .Status .InstallPlanRef
94
100
95
101
By ("waiting for the v0.1.0 CSV to report a succeeded phase" )
96
102
_ , err = fetchCSV (crclient , subscription .Status .CurrentCSV , ns .GetName (), buildCSVConditionChecker (operatorsv1alpha1 .CSVPhaseSucceeded ))
97
103
Expect (err ).ShouldNot (HaveOccurred ())
98
104
99
- By ("patching the OperatorGroup to reduce the bundle unpacking timeout " )
100
- addBundleUnpackTimeoutOGAnnotation ( context . Background (), c , types. NamespacedName { Name : ogName , Namespace : ns . GetName ()}, "1s" )
105
+ By ("updating the operator group to use the service account without required permissions to simulate InstallPlan failure " )
106
+ Eventually ( operatorGroupServiceAccountNameSetter ( crclient , ns . GetName (), ogName , saNameWithNoPerms )). Should ( Succeed () )
101
107
102
- By ("updating the catalog with a broken v0.2.0 bundle image" )
103
- brokenProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , failForwardTestDataBaseDir , "example-operator.v0.2.0-non-existent-tag .yaml" ))
108
+ By ("updating the catalog with v0.2.0 bundle image" )
109
+ brokenProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , failForwardTestDataBaseDir , "example-operator.v0.2.0.yaml" ))
104
110
Expect (err ).To (BeNil ())
105
-
106
111
err = magicCatalog .UpdateCatalog (context .Background (), brokenProvider )
107
112
Expect (err ).To (BeNil ())
108
113
@@ -111,31 +116,29 @@ var _ = Describe("Fail Forward Upgrades", func() {
111
116
Expect (err ).Should (BeNil ())
112
117
113
118
By ("waiting for the bad InstallPlan to report a failed installation state" )
114
- ref : = subscription .Status .InstallPlanRef
115
- _ , err = fetchInstallPlan (GinkgoT (), crclient , ref .Name , ref .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
119
+ failedInstallPlanRef = subscription .Status .InstallPlanRef
120
+ _ , err = fetchInstallPlan (GinkgoT (), crclient , failedInstallPlanRef .Name , failedInstallPlanRef .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
116
121
Expect (err ).To (BeNil ())
117
122
123
+ By ("updating the operator group remove service account without permissions" )
124
+ Eventually (operatorGroupServiceAccountNameSetter (crclient , ns .GetName (), ogName , "" )).Should (Succeed ())
118
125
})
119
126
AfterEach (func () {
120
127
By ("removing the testing catalog resources" )
121
128
Expect (magicCatalog .UndeployCatalog (context .Background ())).To (BeNil ())
122
129
})
123
130
It ("eventually reports a successful state when multiple bad versions are rolled forward" , func () {
124
- By ("patching the catalog with another bad bundle version" )
131
+ By ("patching the OperatorGroup to reduce the bundle unpacking timeout" )
132
+ addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "1s" )
133
+
134
+ By ("patching the catalog with a bad bundle version" )
125
135
badProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/multiple-bad-versions" , "example-operator.v0.2.1-non-existent-tag.yaml" ))
126
136
Expect (err ).To (BeNil ())
127
-
128
137
err = magicCatalog .UpdateCatalog (context .Background (), badProvider )
129
138
Expect (err ).To (BeNil ())
130
139
131
- By ("waiting for the subscription to have the example-operator.v0.2.1 status.updatedCSV" )
132
- subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.2.1" ))
133
- Expect (err ).Should (BeNil ())
134
-
135
- By ("waiting for the bad v0.2.1 InstallPlan to report a failed installation state" )
136
- ref := subscription .Status .InstallPlanRef
137
- _ , err = fetchInstallPlan (GinkgoT (), crclient , ref .Name , ref .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
138
- Expect (err ).To (BeNil ())
140
+ By ("waiting for the subscription to maintain the example-operator.v0.2.0 status.currentCSV" )
141
+ Consistently (subscriptionCurrentCSVGetter (crclient , subscription .GetNamespace (), subscription .GetName ())).Should (Equal ("example-operator.v0.2.0" ))
139
142
140
143
By ("patching the OperatorGroup to increase the bundle unpacking timeout" )
141
144
addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "5m" )
@@ -146,57 +149,74 @@ var _ = Describe("Fail Forward Upgrades", func() {
146
149
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
147
150
Expect (err ).To (BeNil ())
148
151
149
- By ("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV" )
150
- subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
152
+ By ("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV" )
153
+ _ , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
154
+ Expect (err ).Should (BeNil ())
155
+
156
+ By ("verifying the subscription is referencing a new InstallPlan" )
157
+ subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanDifferentChecker (originalInstallPlanRef .Name ))
151
158
Expect (err ).Should (BeNil ())
159
+
160
+ By ("waiting for the fixed v0.3.0 InstallPlan to report a successful state" )
161
+ ref := subscription .Status .InstallPlanRef
162
+ _ , err = fetchInstallPlan (GinkgoT (), crclient , ref .Name , ref .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete ))
163
+ Expect (err ).To (BeNil ())
152
164
})
153
165
154
166
It ("eventually reports a successful state when using skip ranges" , func () {
155
- By ("patching the OperatorGroup to increase the bundle unpacking timeout" )
156
- addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "5m" )
157
-
158
167
By ("patching the catalog with a fixed version" )
159
168
fixedProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/skip-range" , "example-operator.v0.3.0.yaml" ))
160
169
Expect (err ).To (BeNil ())
161
170
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
162
171
Expect (err ).To (BeNil ())
163
172
164
- By ("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV" )
165
- subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
173
+ By ("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV" )
174
+ _ , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
175
+ Expect (err ).Should (BeNil ())
176
+
177
+ By ("verifying the subscription is referencing a new InstallPlan" )
178
+ subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanDifferentChecker (originalInstallPlanRef .Name ))
166
179
Expect (err ).Should (BeNil ())
180
+
181
+ By ("waiting for the fixed v0.3.0 InstallPlan to report a successful state" )
182
+ ref := subscription .Status .InstallPlanRef
183
+ _ , err = fetchInstallPlan (GinkgoT (), crclient , ref .Name , ref .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete ))
184
+ Expect (err ).To (BeNil ())
167
185
})
168
186
It ("eventually reports a successful state when using skips" , func () {
169
- By ("patching the OperatorGroup to increase the bundle unpacking timeout" )
170
- addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "5m" )
171
-
172
187
By ("patching the catalog with a fixed version" )
173
188
fixedProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/skips" , "example-operator.v0.3.0.yaml" ))
174
189
Expect (err ).To (BeNil ())
175
190
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
176
191
Expect (err ).To (BeNil ())
177
192
178
- By ("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV" )
179
- subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
193
+ By ("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV" )
194
+ _ , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
195
+ Expect (err ).Should (BeNil ())
196
+
197
+ By ("verifying the subscription is referencing a new InstallPlan" )
198
+ subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanDifferentChecker (originalInstallPlanRef .Name ))
180
199
Expect (err ).Should (BeNil ())
200
+
201
+ By ("waiting for the fixed v0.3.0 InstallPlan to report a successful state" )
202
+ ref := subscription .Status .InstallPlanRef
203
+ _ , err = fetchInstallPlan (GinkgoT (), crclient , ref .Name , ref .Namespace , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete ))
204
+ Expect (err ).To (BeNil ())
181
205
})
182
206
It ("eventually reports a failed state when using replaces" , func () {
183
- By ("patching the OperatorGroup to increase the bundle unpacking timeout" )
184
- addBundleUnpackTimeoutOGAnnotation (context .Background (), c , types.NamespacedName {Name : ogName , Namespace : ns .GetName ()}, "5m" )
185
-
186
207
By ("patching the catalog with a fixed version" )
187
208
fixedProvider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , "fail-forward/replaces" , "example-operator.v0.3.0.yaml" ))
188
209
Expect (err ).To (BeNil ())
189
210
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
190
211
Expect (err ).To (BeNil ())
191
212
192
- By ("waiting for the subscription to maintain the example-operator.v0.2.0 status.updatedCSV" )
193
- Consistently (func () string {
194
- subscription , err := crclient .OperatorsV1alpha1 ().Subscriptions (subscription .GetNamespace ()).Get (context .Background (), subscription .GetName (), metav1.GetOptions {})
195
- if err != nil || subscription == nil {
196
- return ""
197
- }
198
- return subscription .Status .CurrentCSV
199
- }).Should (Equal ("example-operator.v0.2.0" ))
213
+ By ("waiting for the subscription to maintain the example-operator.v0.2.0 status.currentCSV" )
214
+ Consistently (subscriptionCurrentCSVGetter (crclient , subscription .GetNamespace (), subscription .GetName ())).Should (Equal ("example-operator.v0.2.0" ))
215
+
216
+ By ("verifying the subscription is referencing the same InstallPlan" )
217
+ subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanChecker )
218
+ Expect (err ).Should (BeNil ())
219
+ Expect (subscription .Status .InstallPlanRef .Name ).To (Equal (failedInstallPlanRef .Name ))
200
220
})
201
221
})
202
222
When ("a CSV resource is in a failed state" , func () {
@@ -269,7 +289,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
269
289
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
270
290
Expect (err ).To (BeNil ())
271
291
272
- By ("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV " )
292
+ By ("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV " )
273
293
subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
274
294
Expect (err ).Should (BeNil ())
275
295
})
@@ -282,7 +302,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
282
302
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
283
303
Expect (err ).To (BeNil ())
284
304
285
- By ("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV " )
305
+ By ("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV " )
286
306
subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
287
307
Expect (err ).Should (BeNil ())
288
308
})
@@ -295,7 +315,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
295
315
err = magicCatalog .UpdateCatalog (context .Background (), fixedProvider )
296
316
Expect (err ).To (BeNil ())
297
317
298
- By ("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV " )
318
+ By ("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV " )
299
319
subscription , err = fetchSubscription (crclient , subscription .GetNamespace (), subscription .GetName (), subscriptionHasCurrentCSV ("example-operator.v0.3.0" ))
300
320
Expect (err ).Should (BeNil ())
301
321
})
0 commit comments