Commit 6e35b34
authored
✨ Implement warm replica support for controllers (#3192)
* [Warm Replicas] Implement warm replica support for controllers.
* Remove irrelevant runnable_group.go code.
* Rename ShouldWarmup.
* fmt
* Change to atomic.Bool to avoid race in test.
* Address comments.
* Add ready check to block controller startup until warmup is complete.
* Keep test helper structs private.
* Address comments.
* Fix lint.
* Address naming + comments from sbueringer.
* Refactor tests to use HaveValue.
* Document + add UT for WaitForWarmupComplete behavior on ctx cancellation.
* Add unit test that exercises controller warmup integration with manager.
* Add UT that verifies WaitForWarmupComplete blocking / non-blocking behavior.
* Verify r.Others.startQueue in runnables test cases.
* Fix UT to verify runnable ordering.
* Fix UT for WaitForWarmupComplete blocking.
* Document !NeedLeaderElection+NeedWarmup behavior
* Fix test race.
* Cleanup test wrapper runnables.
* Make didStartEventSources run once with sync.Once + UT.
* Rewrite Warmup to avoid polling.
* Rename NeedWarmup to EnableWarmup.
* Clarify comment on Warmup.
* Move reset watches critical section inside of startEventSources.
* Add test to assert startEventSources blocking behavior.
* Make Start threadsafe with Warmup + UT.
* Change warmup to use buffered error channel and add New method.
* Fail in warmup directly and rely on sync.Once for warmup thread-safety without WaitForWarmupComplete.
* Sync controller EnableWarmup comments.
* Rename to startEventSourcesLocked and lock with c.mu
* Address edge case for watch added after warmup completes.
* Fix test description and set leaderelection==true
* Fix lint.
* Change shutdown order to shutdown warmup runnables in parallel with other runnables.
* Fix test races by ensuring goroutines do not outlive their It blocks.
* Block on source start on context cancel.
* Guard access to c.Queue explicitly.
* Initialize queue in warmup with test.
* Fix watch comment.
* Add warmup to manager and controller integration tests.
* fmt + lint.
* Add tests for Warmup for parity with Start.
* golangci-lint
* Increase test coverage for start with warmup race.
* Remove synchronization code around c.Queue concurrent access.
* Assert startedEventSourcesAndQueue is set in tests.
* fmt
* Clarify namespace predicate vs. cleanup in controller integration test.
* Add option for fake leader elector package and assert that warmup runnables are started before leader election.
* fmt + rename
* Address PR comments.1 parent 948d554 commit 6e35b34
File tree
13 files changed
+1348
-128
lines changed- pkg
- config
- controller
- internal/controller
- leaderelection/fake
- manager
- internal/integration
13 files changed
+1348
-128
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
63 | 76 | | |
64 | 77 | | |
65 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
96 | 109 | | |
97 | 110 | | |
98 | 111 | | |
| |||
124 | 137 | | |
125 | 138 | | |
126 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
127 | 144 | | |
128 | 145 | | |
129 | 146 | | |
| |||
243 | 260 | | |
244 | 261 | | |
245 | 262 | | |
246 | | - | |
| 263 | + | |
247 | 264 | | |
248 | 265 | | |
249 | 266 | | |
| |||
253 | 270 | | |
254 | 271 | | |
255 | 272 | | |
256 | | - | |
| 273 | + | |
| 274 | + | |
257 | 275 | | |
258 | 276 | | |
259 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
27 | 30 | | |
| 31 | + | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| |||
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
51 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
64 | 79 | | |
65 | 80 | | |
| 81 | + | |
| 82 | + | |
66 | 83 | | |
67 | 84 | | |
68 | 85 | | |
69 | 86 | | |
| 87 | + | |
70 | 88 | | |
71 | 89 | | |
72 | 90 | | |
73 | 91 | | |
74 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
75 | 98 | | |
76 | 99 | | |
77 | 100 | | |
| |||
110 | 133 | | |
111 | 134 | | |
112 | 135 | | |
113 | | - | |
| 136 | + | |
114 | 137 | | |
115 | 138 | | |
116 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
117 | 146 | | |
118 | | - | |
| 147 | + | |
119 | 148 | | |
120 | 149 | | |
121 | 150 | | |
122 | 151 | | |
123 | 152 | | |
124 | 153 | | |
125 | | - | |
| 154 | + | |
126 | 155 | | |
127 | 156 | | |
128 | 157 | | |
| |||
145 | 174 | | |
146 | 175 | | |
147 | 176 | | |
148 | | - | |
| 177 | + | |
149 | 178 | | |
150 | 179 | | |
151 | 180 | | |
152 | 181 | | |
153 | 182 | | |
154 | 183 | | |
155 | | - | |
| 184 | + | |
156 | 185 | | |
157 | 186 | | |
158 | 187 | | |
159 | 188 | | |
160 | | - | |
| 189 | + | |
161 | 190 | | |
162 | 191 | | |
163 | 192 | | |
164 | 193 | | |
165 | | - | |
| 194 | + | |
166 | 195 | | |
167 | 196 | | |
168 | 197 | | |
| |||
174 | 203 | | |
175 | 204 | | |
176 | 205 | | |
177 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
178 | 212 | | |
179 | 213 | | |
180 | 214 | | |
| |||
194 | 228 | | |
195 | 229 | | |
196 | 230 | | |
197 | | - | |
| 231 | + | |
198 | 232 | | |
199 | 233 | | |
200 | | - | |
| 234 | + | |
201 | 235 | | |
202 | 236 | | |
203 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
204 | 241 | | |
205 | 242 | | |
206 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
207 | 252 | | |
208 | 253 | | |
209 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
477 | 543 | | |
478 | 544 | | |
0 commit comments