Commit d68b694
authored
🤖 fix: back off provisioner reconciliation on coderd 429s (#65)
## Summary
This PR hardens `CoderProvisioner` reconciliation against coderd API
rate limiting by adding explicit 429 backoff behavior, plus optional
rate-limit bypass with fallback in bootstrap client calls. It also
includes the existing `flake.nix` dev-tooling update present in this
workspace.
## Background
Provisioner reconciliation was entering tight error loops after coderd
returned HTTP 429 (`Too Many Requests`), which amplified API pressure
and prevented stable reconciliation. The operator needed
controller-level pacing and safer bootstrap API behavior when bypass
headers are unavailable.
## Implementation
- Added explicit per-resource jittered exponential backoff for coderd
429s in `CoderProvisionerReconciler`:
- base `2s`, cap `2m`, floor `1s`, jitter ratio `0.2`
- converts 429 failures into `RequeueAfter` instead of immediate error
retries
- sets `ProvisionerKeyReady=False` with `Reason=RateLimited`
- resets per-resource backoff after non-rate-limited outcomes
- Added bootstrap SDK helpers:
- `withOptionalRateLimitBypass(...)`
- `bypassRateLimitRoundTripper` to inject `X-Coder-Bypass-Ratelimit:
true` when requested
- automatic retry without bypass when server rejects bypass (`412
Precondition Required`)
- exported `IsRateLimitError(err)` helper for controller logic
- Applied bypass/fallback flow to:
- workspace proxy create/patch operations
- provisioner key create/query/delete paths
- Added tests:
- controller backoff + `RateLimited` condition coverage
- workspace proxy bypass fallback coverage
- provisioner key ensure/delete bypass fallback coverage
- Included existing workspace change in `flake.nix` (`yazi` added to dev
shell packages)
## Validation
- `make test`
- `make build`
- `make lint`
- `make verify-vendor`
## Risks
- **Low-to-medium**: reconcile timing changes for 429 paths only.
- Main risk is slower convergence during sustained coderd throttling;
this is intentional to prevent hot-loop amplification and API overload.
- Scope is limited to bootstrap calls and provisioner reconciliation
retry behavior.
---
_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking:
`xhigh` • Cost: `$1.46`_
<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh
costs=1.46 -->1 parent a84bece commit d68b694
7 files changed
Lines changed: 443 additions & 35 deletions
File tree
- internal
- coderbootstrap
- controller
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
20 | 78 | | |
21 | 79 | | |
22 | 80 | | |
| |||
60 | 118 | | |
61 | 119 | | |
62 | 120 | | |
63 | | - | |
| 121 | + | |
64 | 122 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 123 | + | |
76 | 124 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 125 | | |
82 | 126 | | |
83 | 127 | | |
| |||
86 | 130 | | |
87 | 131 | | |
88 | 132 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
93 | 139 | | |
94 | 140 | | |
95 | 141 | | |
| |||
109 | 155 | | |
110 | 156 | | |
111 | 157 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
118 | 166 | | |
119 | 167 | | |
120 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
203 | 270 | | |
204 | 271 | | |
205 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| |||
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
122 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
| |||
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
169 | | - | |
| 175 | + | |
170 | 176 | | |
171 | 177 | | |
172 | 178 | | |
| |||
0 commit comments