@@ -79,7 +79,6 @@ import javax.swing.JPanel
79
79
import javax.swing.ListCellRenderer
80
80
import javax.swing.SwingConstants
81
81
import javax.swing.event.DocumentEvent
82
- import kotlin.coroutines.cancellation.CancellationException
83
82
84
83
class CoderLocateRemoteProjectStepView (private val setNextButtonEnabled : (Boolean ) -> Unit ) : CoderWorkspacesWizardStep, Disposable {
85
84
private val cs = CoroutineScope (Dispatchers .Main )
@@ -179,6 +178,8 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
179
178
180
179
ideResolvingJob = cs.launch {
181
180
val ides = suspendingRetryWithExponentialBackOff(
181
+ label = " retrieve IDEs" ,
182
+ logger = logger,
182
183
action= { attempt ->
183
184
logger.info(" Deploying to ${selectedWorkspace.name} on $deploymentURL (attempt $attempt )" )
184
185
// Reset text in the select dropdown.
@@ -187,54 +188,38 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
187
188
if (attempt > 1 ) CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.retry.text" , attempt)
188
189
else CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.loading.text" ))
189
190
}
190
- try {
191
- val executor = createRemoteExecutor(CoderCLIManager .getHostName(deploymentURL, selectedWorkspace))
192
- if (ComponentValidator .getInstance(tfProject).isEmpty) {
193
- installRemotePathValidator(executor)
194
- }
195
- retrieveIDEs(executor, selectedWorkspace)
196
- } catch (e: Exception ) {
197
- when (e) {
198
- is InterruptedException -> Unit
199
- is CancellationException -> Unit
200
- // Throw to retry these. The main one is
201
- // DeployException which fires when dd times out.
202
- is ConnectionException , is TimeoutException ,
203
- is SSHException , is DeployException -> throw e
204
- else -> {
205
- withContext(Dispatchers .Main ) {
206
- logger.error(" Failed to retrieve IDEs (attempt $attempt )" , e)
207
- cbIDEComment.foreground = UIUtil .getErrorForeground()
208
- cbIDEComment.text = e.message ? : " The error did not provide any further details"
209
- cbIDE.renderer = IDECellRenderer (CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.error.text" ), UIUtil .getBalloonErrorIcon())
210
- }
211
- }
212
- }
213
- null
191
+ val executor = createRemoteExecutor(CoderCLIManager .getHostName(deploymentURL, selectedWorkspace))
192
+ if (ComponentValidator .getInstance(tfProject).isEmpty) {
193
+ installRemotePathValidator(executor)
214
194
}
195
+ retrieveIDEs(executor, selectedWorkspace)
196
+ },
197
+ predicate = { e ->
198
+ e is ConnectionException || e is TimeoutException
199
+ || e is SSHException || e is DeployException
215
200
},
216
- update = { attempt, retryMs, e ->
217
- logger.error(" Failed to retrieve IDEs (attempt $attempt ; will retry in $retryMs ms)" , e)
201
+ update = { _, e, retryMs ->
218
202
cbIDEComment.foreground = UIUtil .getErrorForeground()
219
203
// When the dd command times out all we get is a
220
- // DeployException and some text that it failed but not why.
221
- // Plus it includes a long tmp path that is a bit nasty to
204
+ // DeployException and some text that it failed. Plus
205
+ // it includes a long tmp path that is a bit nasty to
222
206
// display so replace it with something nicer.
223
- if (e is DeployException && e.message.contains(" Worker binary deploy failed" )) {
224
- cbIDEComment.text = " Failed to upload worker binary...it may have timed out. Check the command log for details."
207
+ cbIDEComment.text =
208
+ if (e is DeployException && e.message.contains(" Worker binary deploy failed" ))
209
+ " Failed to upload worker binary...it may have timed out. Check the command log for details."
210
+ else e?.message ? : CoderGatewayBundle .message(" gateway.connector.no-details" )
211
+ if (retryMs != null ) {
212
+ val delayS = TimeUnit .MILLISECONDS .toSeconds(retryMs)
213
+ val delay = if (delayS < 1 ) " now" else " in $delayS second${if (delayS > 1 ) " s" else " " } "
214
+ cbIDE.renderer = IDECellRenderer (CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.retry-error.text" , delay))
225
215
} else {
226
- cbIDEComment.text = e .message ? : " The error did not provide any further details. "
216
+ cbIDE.renderer = IDECellRenderer ( CoderGatewayBundle .message( " gateway.connector.view.coder.remoteproject. error.text " ), UIUtil .getBalloonErrorIcon())
227
217
}
228
- val delayS = TimeUnit .MILLISECONDS .toSeconds(retryMs)
229
- val delay = if (delayS < 1 ) " now" else " in $delayS second${if (delayS > 1 ) " s" else " " } "
230
- cbIDE.renderer = IDECellRenderer (CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.retry-error.text" , delay))
231
218
},
232
219
)
233
- if (ides != null ) {
234
- withContext(Dispatchers .Main ) {
235
- ideComboBoxModel.addAll(ides)
236
- cbIDE.selectedIndex = 0
237
- }
220
+ withContext(Dispatchers .Main ) {
221
+ ideComboBoxModel.addAll(ides)
222
+ cbIDE.selectedIndex = 0
238
223
}
239
224
}
240
225
}
0 commit comments