Commit ddf0131
committed
pkg: Use risk.Source framework to feed Upgradeable
This simplifies the complex cvo package by shifting some logic into
small, narrowly scoped helper packages. That makes for easier unit
testing of that logic, and less complication when reading the
remaining cvo package code.
Using the risk.Source framework with the new aggregate implementation
allows Upgradeable risks to feed into the conditionalUpdateRisks
framework. This should help reduce confusion some users experience
when the see Upgradeable=False and think it applies to all updates
(when in reality it applies to major and minor bumps, but does not
apply to patch updates, especially since 6f8f984, OTA-1860: Stop
blocking patch updates when cluster version overrides are set,
2026-02-10, #1314). It will also allow structured access to
individual risks that are reported via this pipeline, while
Upgradeable had an aggregated message string only consumable by
humans.
I'm also removing internal.UpgradeableAdminAckRequired and similar
from ClusterVersion status.conditions. While these were visible by
end users, they were mostly a mechanism for passing data from one part
of the CVO to another. There are no known consumers outside of the
CVO.
With the refactor providing clearer abstraction layers, I could drop
the entire upgradeableCheckIntervals structure. Major touches in the
history of that structure were bd05174 (pkg/cvo/upgradeable.go:
Sync Upgradeable status of the CVO more often, 2022-08-02, #808) and
cc94c95 (pkg/cvo/upgradeable: refactor throttling, 2023-01-11, #882).
The new approach is event-driven via the informer handlers for almost
all of the new risk.Source implementations. The one source that still
relies on polling is the deletion source, where it's watching a
CVO-side global variable, and not a Kube-side informer. It will still
sync whenever ClusterVersion status is updated though, which should be
often enough for this usually-transient situation. If folks want
lower latency, follow up work could add informer-style handler
callbacks to the deletion global.
The addition of '.' and '-' to validName in pkg/risk allows for names
like ClusterOperatorUpgradeable-test-operator in the Upgradeable test,
composed with the ClusterOperator name. That requires us to extend
the regular expression to allow the characters supported by
ClusterOperator names [2]. We could alternatively build a system that
CamelCased ClusterOperator names, but that seemed difficult, and not
worth the effort.
The changeCallback in unit tests is unbuffered, because I want to know
exactly how often that callback is being called. If a logic change in
the packages causes additional callback calls, the unbuffered channel
will block them from sending the message, deadlock the informer for
that handler [1], and break later test-cases.
[1]: https://github.com/kubernetes/client-go/blob/v0.35.3/tools/cache/shared_informer.go#L1052-L1086
[2]: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names1 parent de31a3f commit ddf0131
21 files changed
Lines changed: 2025 additions & 2003 deletions
File tree
- pkg
- cvo
- risk
- adminack
- aggregate
- deletion
- overrides
- updating
- upgradeable
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
| |||
133 | 139 | | |
134 | 140 | | |
135 | 141 | | |
136 | | - | |
137 | | - | |
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 147 | + | |
| 148 | + | |
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
| |||
264 | 262 | | |
265 | 263 | | |
266 | 264 | | |
267 | | - | |
268 | 265 | | |
269 | 266 | | |
270 | 267 | | |
| |||
274 | 271 | | |
275 | 272 | | |
276 | 273 | | |
277 | | - | |
278 | 274 | | |
279 | 275 | | |
280 | 276 | | |
281 | 277 | | |
282 | 278 | | |
283 | | - | |
284 | 279 | | |
285 | 280 | | |
286 | 281 | | |
| |||
293 | 288 | | |
294 | 289 | | |
295 | 290 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | 291 | | |
303 | 292 | | |
304 | 293 | | |
| |||
320 | 309 | | |
321 | 310 | | |
322 | 311 | | |
323 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
324 | 325 | | |
325 | 326 | | |
326 | 327 | | |
| |||
483 | 484 | | |
484 | 485 | | |
485 | 486 | | |
486 | | - | |
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | 557 | | |
567 | 558 | | |
568 | 559 | | |
569 | 560 | | |
570 | 561 | | |
571 | 562 | | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | 563 | | |
577 | 564 | | |
578 | 565 | | |
| |||
622 | 609 | | |
623 | 610 | | |
624 | 611 | | |
625 | | - | |
626 | 612 | | |
627 | 613 | | |
628 | 614 | | |
| |||
643 | 629 | | |
644 | 630 | | |
645 | 631 | | |
646 | | - | |
647 | 632 | | |
648 | 633 | | |
649 | 634 | | |
650 | 635 | | |
651 | | - | |
652 | 636 | | |
653 | 637 | | |
654 | 638 | | |
| |||
859 | 843 | | |
860 | 844 | | |
861 | 845 | | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | 846 | | |
888 | 847 | | |
889 | 848 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| 119 | + | |
| 120 | + | |
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
| 128 | + | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
| |||
0 commit comments