Commit e0f3104
authored
fix: slow workspace list refresh when many workspaces are stopped (#328)
A customer reported that refreshing the workspace list could take around
ten seconds. The client logs showed that most of that time was spent
expanding the auth header command: stopped workspaces do not include
their resources in the /workspaces response, so we were issuing a
separate resource lookup for each stopped workspace just to recover its
agents, and every one of those HTTP calls paid the header command
expansion cost (roughly half a second per call — about 9.7 seconds for
the 21 stopped workspaces in the customer's search).
Instead of trying to make those calls faster, we questioned why they
were needed at all. Agents only matter when there is something to
connect to, and nothing can connect to a stopped workspace: the SSH
configuration is only useful for running workspaces, and the agent list
arrives for free in the /workspaces response the moment a workspace is
running. So stopped (and otherwise not-running) workspaces are now
registered as workspace-only environments, identified by workspace name
alone, with no resource lookup at all. When a workspace comes up, the
poller replaces the workspace-only row with one row per agent and
regenerates the SSH configuration, which now covers running workspaces
only.
While reviewing the features that interact with stopped workspaces I
found and fixed three problems this change would have introduced:
- deep links (URI handling) became racy: the agent environment and its
SSH config entry now exist only after the poller observes the running
workspace, so a fixed two-second delay was no longer enough. The
protocol handler now nudges the poller and waits for the environment to
actually appear (with a timeout) before showing the environment page and
launching the IDE.
- an environment without an agent used to hand Toolbox an SSH contents
view with an empty host. It now returns a manual contents view with
empty IDE and project lists, so Toolbox never attempts to connect to a
blank host.
- Toolbox closes environments that disappear from the provider list by
cancelling their wrapper scope without ever firing the
AfterDisconnectHook. This one took a lot of time to figure out and was
only possible by verifying against the Toolbox bytecode. Since
stop/start transitions now replace environment instances, a connected
environment leaked its network metrics poll job. The provider now
disposes dropped instances explicitly, both during poll refreshes and on
close/logout.
Two known issues remain and I think we can consider them acceptable:
(1) the environment id changes across a stop/start cycle, so an
environment page left open while the workspace stops can go throw a
weird error about Toolbox not being able to find it;
(2) a workspace that goes from running and ssh connected to stopped and
then back to running, no longer auto-connects
- resolves DEVEX-372
- resolves DEVEX-3741 parent bd1ab0e commit e0f3104
12 files changed
Lines changed: 173 additions & 192 deletions
File tree
- src
- main/kotlin/com/coder/toolbox
- sdk
- v2
- util
- views
- test/kotlin/com/coder/toolbox
- sdk
- util
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
488 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
489 | 491 | | |
490 | 492 | | |
491 | 493 | | |
| |||
Lines changed: 61 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | | - | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| 59 | + | |
54 | 60 | | |
55 | | - | |
56 | | - | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | | - | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
79 | 85 | | |
80 | 86 | | |
81 | 87 | | |
82 | | - | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
87 | | - | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
| |||
122 | 128 | | |
123 | 129 | | |
124 | 130 | | |
| 131 | + | |
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
| 139 | + | |
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
| |||
145 | 153 | | |
146 | 154 | | |
147 | 155 | | |
| 156 | + | |
148 | 157 | | |
149 | 158 | | |
150 | 159 | | |
| |||
204 | 213 | | |
205 | 214 | | |
206 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
| |||
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
| 228 | + | |
216 | 229 | | |
217 | | - | |
| 230 | + | |
218 | 231 | | |
219 | 232 | | |
220 | 233 | | |
| |||
244 | 257 | | |
245 | 258 | | |
246 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
247 | 274 | | |
248 | 275 | | |
249 | 276 | | |
| |||
259 | 286 | | |
260 | 287 | | |
261 | 288 | | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
| 289 | + | |
266 | 290 | | |
267 | 291 | | |
268 | 292 | | |
269 | 293 | | |
270 | 294 | | |
| 295 | + | |
271 | 296 | | |
272 | 297 | | |
273 | 298 | | |
274 | 299 | | |
275 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
276 | 303 | | |
277 | 304 | | |
278 | 305 | | |
| |||
285 | 312 | | |
286 | 313 | | |
287 | 314 | | |
288 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
289 | 322 | | |
290 | 323 | | |
291 | 324 | | |
292 | 325 | | |
293 | | - | |
| 326 | + | |
| 327 | + | |
294 | 328 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
302 | 342 | | |
303 | 343 | | |
304 | 344 | | |
| |||
Lines changed: 25 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
108 | 106 | | |
| 107 | + | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
136 | 140 | | |
137 | 141 | | |
138 | 142 | | |
139 | | - | |
| 143 | + | |
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
| |||
181 | 185 | | |
182 | 186 | | |
183 | 187 | | |
184 | | - | |
| 188 | + | |
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| |||
203 | 207 | | |
204 | 208 | | |
205 | 209 | | |
206 | | - | |
207 | | - | |
| 210 | + | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
| |||
224 | 228 | | |
225 | 229 | | |
226 | 230 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
234 | 237 | | |
235 | | - | |
| 238 | + | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
239 | 243 | | |
240 | 244 | | |
241 | 245 | | |
242 | 246 | | |
243 | | - | |
| 247 | + | |
244 | 248 | | |
245 | 249 | | |
246 | 250 | | |
| |||
288 | 292 | | |
289 | 293 | | |
290 | 294 | | |
| 295 | + | |
291 | 296 | | |
292 | 297 | | |
293 | 298 | | |
| |||
590 | 595 | | |
591 | 596 | | |
592 | 597 | | |
593 | | - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
594 | 603 | | |
595 | 604 | | |
596 | 605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
202 | 201 | | |
203 | 202 | | |
204 | 203 | | |
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 | 204 | | |
231 | 205 | | |
232 | 206 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 71 | | |
0 commit comments