Commit 36ca5ab
authored
flowcontrol: Support dynamic priority provisioning (#2006)
* flowcontrol: support dynamic priority provisioning
This commit implements dynamic provisioning for priority bands, enabling
the system to accept requests with priority levels that were not
explicitly configured at startup.
Key Changes:
1. Hybrid State Model:
- Adopts `sync.Map` in `FlowRegistry` and `registryShard` for
operational state (queues, stats). This enables lock-free reads on
the hot path and safe concurrent writes when provisioning new
bands.
- Retains `map` + `RWMutex` for the `Config` definition to ensure a
consistent source of truth for topology limits and names.
2. Dynamic Provisioning Logic:
- `prepareNewFlow` implements an optimistic lock-free check for band
existence.
- `ensurePriorityBand` handles the atomic JIT creation of new bands,
updating both the global config definitions and the active shard
runtimes.
3. Configuration Extensions:
- Added `DefaultPriorityBand` to `Config` to serve as the template
for dynamically created bands.
- Updated validation logic to support empty static band lists,
defaulting instead to a purely dynamic configuration.
- Removed obsolescent test cases enforcing static band requirements.
* flowcontrol: add tests for dynamic provisioning
This commit extends the test suite to validate the new dynamic priority
provisioning capabilities in the FlowRegistry and Shard components.
Key Updates:
1. Shard Tests:
- Added `TestShard_DynamicProvisioning` to verify that
`addPriorityBand` correctly updates internal state (`sync.Map`,
sorted levels) and maintains idempotency.
- Verified that accessing missing configuration triggers the
expected invariant violation panic.
2. Registry Tests:
- Added `TestFlowRegistry_DynamicProvisioning` to verify the
end-to-end flow: creating a new priority via `WithConnection`
updates the global config, stats, and propagates to all active
shards.
- Added concurrency tests to ensure multiple clients requesting the
same new priority simultaneously do not race or duplicate work.
- Verified that dynamic bands are correctly persisted across scaling
events.
3. Config Tests:
- Updated `TestNewConfig` to support empty static band
configurations (now valid).
- Added verification for `DefaultPriorityBand` template
initialization and cloning behavior.
* flowcontrol: adopt dynamic bootstrapping for POC
Removes the explicit hardcoded configuration of the "Default" priority
band (Priority 0) in the main entry point.
The system now relies entirely on the newly implemented
`DefaultPriorityBand` mechanism to dynamically provision Priority 0
just-in-time upon the first request. This simplifies the wiring code and
validates the zero-config startup path.1 parent a37709b commit 36ca5ab
File tree
7 files changed
+424
-154
lines changed- cmd/epp/runner
- pkg/epp/flowcontrol/registry
7 files changed
+424
-154
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 | + | |
| 108 | + | |
113 | 109 | | |
114 | 110 | | |
115 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | 115 | | |
117 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
122 | 126 | | |
123 | | - | |
124 | | - | |
| 127 | + | |
| 128 | + | |
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
| |||
223 | 227 | | |
224 | 228 | | |
225 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
226 | 238 | | |
227 | 239 | | |
228 | 240 | | |
| |||
304 | 316 | | |
305 | 317 | | |
306 | 318 | | |
307 | | - | |
308 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
309 | 332 | | |
310 | 333 | | |
311 | 334 | | |
| |||
317 | 340 | | |
318 | 341 | | |
319 | 342 | | |
320 | | - | |
| 343 | + | |
321 | 344 | | |
322 | 345 | | |
323 | 346 | | |
| |||
387 | 410 | | |
388 | 411 | | |
389 | 412 | | |
390 | | - | |
391 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
392 | 419 | | |
393 | 420 | | |
| 421 | + | |
394 | 422 | | |
395 | 423 | | |
396 | 424 | | |
| |||
462 | 490 | | |
463 | 491 | | |
464 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
465 | 499 | | |
466 | 500 | | |
467 | 501 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | 110 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 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 | + | |
| 139 | + | |
| 140 | + | |
117 | 141 | | |
| 142 | + | |
| 143 | + | |
118 | 144 | | |
119 | 145 | | |
120 | 146 | | |
| |||
334 | 360 | | |
335 | 361 | | |
336 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
337 | 380 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
125 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
| |||
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
160 | 164 | | |
161 | 165 | | |
162 | 166 | | |
| |||
167 | 171 | | |
168 | 172 | | |
169 | 173 | | |
170 | | - | |
| 174 | + | |
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| |||
252 | 256 | | |
253 | 257 | | |
254 | 258 | | |
255 | | - | |
256 | | - | |
257 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
258 | 271 | | |
259 | 272 | | |
260 | 273 | | |
| |||
272 | 285 | | |
273 | 286 | | |
274 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
275 | 316 | | |
276 | 317 | | |
277 | 318 | | |
| |||
288 | 329 | | |
289 | 330 | | |
290 | 331 | | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
295 | 338 | | |
296 | 339 | | |
297 | | - | |
298 | | - | |
| 340 | + | |
| 341 | + | |
299 | 342 | | |
300 | | - | |
| 343 | + | |
| 344 | + | |
301 | 345 | | |
302 | 346 | | |
303 | 347 | | |
| |||
585 | 629 | | |
586 | 630 | | |
587 | 631 | | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
| 632 | + | |
| 633 | + | |
593 | 634 | | |
594 | 635 | | |
595 | 636 | | |
| |||
0 commit comments