Commit 30dda05
committed
Check capabilities before watching OLM resource
Only try to watch subscriptions and installplans if the "marketplace"
and "OperatorLifecycleManager" capabilities are enabled.
If the "OperatorLifecycleManager" capability is not enabled, the
installplans and subscriptions resources do not exist, and if the
"marketplace" capability is not enabled, the default catalog does not
exist. Before this commit, the operator would fail to initialize when
these capabilities were not enabled as the status and gatewayclass
controllers would try and fail to watch the non-existent resources.
This commit fixes OCPBUGS-55317
https://issues.redhat.com/browse/OCPBUGS-55317
* pkg/operator/controller/gatewayapi/controller.go (Config): Add
MarketplaceEnabled and OperatorLifecycleManagerEnabled fields to
indicate whether the associated capabilities are enabled.
(Reconcile): Don't enable dependent controllers if the marketplace and
OLM capabilities are not enabled.
* pkg/operator/controller/gatewayapi/controller_test.go
(Test_Reconcile): Add a test case in which the featuregates are enabled
but the marketplace and OLM capabilities are not enabled. Indicate that
the capabilities are enabled for the existing test cases.
(TestReconcileOnlyStartsControllerOnce): Set MarketplaceEnabled and
OperatorLifecycleManagerEnabled to true for the test.
* pkg/operator/controller/status/controller.go (New): Only watch
subscriptions if the required capabilities are enabled.
(Config): Add MarketplaceEnabled and OperatorLifecycleManagerEnabled
fields.
(getOperatorState): Only try to get the subscription if the required
capabilities are enabled.
* pkg/operator/operator.go (New): Read the capabilities from the cluster
ClusterVersion, and set the MarketplaceEnabled and
OperatorLifecycleManagerEnabled fields in the status controller's and
gatewayapi controller's configs accordingly.1 parent 2e6bd66 commit 30dda05
File tree
4 files changed
+117
-28
lines changed- pkg/operator
- controller
- gatewayapi
- status
4 files changed
+117
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
151 | 167 | | |
152 | 168 | | |
153 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
76 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| |||
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
106 | 112 | | |
107 | 113 | | |
108 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
109 | 139 | | |
110 | 140 | | |
111 | 141 | | |
| |||
126 | 156 | | |
127 | 157 | | |
128 | 158 | | |
| 159 | + | |
| 160 | + | |
129 | 161 | | |
130 | 162 | | |
131 | 163 | | |
| |||
154 | 186 | | |
155 | 187 | | |
156 | 188 | | |
| 189 | + | |
| 190 | + | |
157 | 191 | | |
158 | 192 | | |
159 | 193 | | |
| |||
180 | 214 | | |
181 | 215 | | |
182 | 216 | | |
| 217 | + | |
| 218 | + | |
183 | 219 | | |
184 | 220 | | |
185 | 221 | | |
| |||
241 | 277 | | |
242 | 278 | | |
243 | 279 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
247 | 285 | | |
248 | 286 | | |
249 | 287 | | |
| |||
316 | 354 | | |
317 | 355 | | |
318 | 356 | | |
319 | | - | |
320 | | - | |
321 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
322 | 362 | | |
323 | 363 | | |
324 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
103 | 111 | | |
104 | 112 | | |
105 | 113 | | |
| |||
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
132 | 146 | | |
133 | 147 | | |
134 | 148 | | |
| |||
338 | 352 | | |
339 | 353 | | |
340 | 354 | | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
346 | 365 | | |
347 | | - | |
348 | | - | |
349 | 366 | | |
350 | 367 | | |
351 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
| |||
208 | 220 | | |
209 | 221 | | |
210 | 222 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
216 | 230 | | |
217 | 231 | | |
218 | 232 | | |
| |||
324 | 338 | | |
325 | 339 | | |
326 | 340 | | |
327 | | - | |
328 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
329 | 345 | | |
330 | 346 | | |
331 | 347 | | |
| |||
0 commit comments