Commit 1577b73
authored
fix: don't create new environment instances every time we poll (#239)
The polling logic has a list of "environments" which is updated by the
poll loop. The loop retrieves a list of workspaces and agents from the
backend, and then it looks if the pairs are already part of the existing
environments. This is where we have an issue: we look by temporarily
creating a new "RemoteEnvironment" and use the id of the temporary env.
to search in the existing collection. Besides creating a lot of
temporary objects every 5 seconds, the logic has another flaw: the
constructor of the RemoteEnvironment triggers the ssh connection for
that workspace if it was marked in the settings store as connected in
the previous state. Asking to establish the ssh connection every 5
seconds is completely unnecessary, from my testings the newer versions
of Toolbox are able to remember in the same session that a connection
was opened, and it needs to be re-established again if it fails during
that session.
From now on the constructor for the RemoteEnvironment will request it
only for new login sessions, from then on it is up to TBX to remember
the connection state. In the early versions we added custom logic to
retrigger the ssh connection when API keys expired. Turns out that is
also no longer necessary to do. When an API key expires the user will
have to go again through the login sequence, which means starting with a
clean sheet of "environments". At the first poll run the
RemoteEnvironment constructor will request TBX to establish the ssh
connection again.1 parent b32fb9b commit 1577b73
5 files changed
Lines changed: 17 additions & 56 deletions
File tree
- src/main/kotlin/com/coder/toolbox
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
Lines changed: 4 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
308 | | - | |
309 | | - | |
| 307 | + | |
310 | 308 | | |
311 | | - | |
| 309 | + | |
312 | 310 | | |
313 | 311 | | |
314 | 312 | | |
315 | 313 | | |
316 | | - | |
| 314 | + | |
317 | 315 | | |
318 | | - | |
319 | 316 | | |
320 | 317 | | |
321 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
140 | 139 | | |
141 | 140 | | |
142 | | - | |
| 141 | + | |
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
| |||
153 | 152 | | |
154 | 153 | | |
155 | 154 | | |
156 | | - | |
| 155 | + | |
157 | 156 | | |
158 | 157 | | |
159 | 158 | | |
| |||
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
166 | | - | |
| 165 | + | |
167 | 166 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 167 | | |
184 | 168 | | |
185 | 169 | | |
| |||
190 | 174 | | |
191 | 175 | | |
192 | 176 | | |
193 | | - | |
194 | 177 | | |
195 | 178 | | |
196 | 179 | | |
| |||
225 | 208 | | |
226 | 209 | | |
227 | 210 | | |
228 | | - | |
229 | 211 | | |
230 | 212 | | |
231 | 213 | | |
| |||
Lines changed: 0 additions & 22 deletions
This file was deleted.
0 commit comments