@@ -68,7 +68,6 @@ import net.schmizz.sshj.connection.ConnectionException
68
68
import java.awt.Component
69
69
import java.awt.FlowLayout
70
70
import java.util.Locale
71
- import java.util.concurrent.TimeUnit
72
71
import java.util.concurrent.TimeoutException
73
72
import javax.swing.ComboBoxModel
74
73
import javax.swing.DefaultComboBoxModel
@@ -79,7 +78,6 @@ import javax.swing.JPanel
79
78
import javax.swing.ListCellRenderer
80
79
import javax.swing.SwingConstants
81
80
import javax.swing.event.DocumentEvent
82
- import kotlin.coroutines.cancellation.CancellationException
83
81
84
82
class CoderLocateRemoteProjectStepView (private val setNextButtonEnabled : (Boolean ) -> Unit ) : CoderWorkspacesWizardStep, Disposable {
85
83
private val cs = CoroutineScope (Dispatchers .Main )
@@ -179,6 +177,8 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
179
177
180
178
ideResolvingJob = cs.launch {
181
179
val ides = suspendingRetryWithExponentialBackOff(
180
+ label = " retrieve IDEs" ,
181
+ logger = logger,
182
182
action= { attempt ->
183
183
logger.info(" Deploying to ${selectedWorkspace.name} on $deploymentURL (attempt $attempt )" )
184
184
// Reset text in the select dropdown.
@@ -187,46 +187,27 @@ class CoderLocateRemoteProjectStepView(private val setNextButtonEnabled: (Boolea
187
187
if (attempt > 1 ) CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.retry.text" , attempt)
188
188
else CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.loading.text" ))
189
189
}
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
190
+ val executor = createRemoteExecutor(CoderCLIManager .getHostName(deploymentURL, selectedWorkspace))
191
+ if (ComponentValidator .getInstance(tfProject).isEmpty) {
192
+ installRemotePathValidator(executor)
214
193
}
194
+ retrieveIDEs(executor, selectedWorkspace)
195
+ },
196
+ predicate = { e ->
197
+ e is ConnectionException || e is TimeoutException
198
+ || e is SSHException || e is DeployException
215
199
},
216
- update = { attempt, retryMs, e ->
217
- logger.error(" Failed to retrieve IDEs (attempt $attempt ; will retry in $retryMs ms)" , e)
200
+ update = { _, e, remaining ->
218
201
cbIDEComment.foreground = UIUtil .getErrorForeground()
219
- cbIDEComment.text = e.message ? : " The error did not provide any further details"
220
- val delayS = TimeUnit . MILLISECONDS .toSeconds(retryMs)
221
- val delay = if (delayS < 1 ) " now " else " in $delayS second ${ if (delayS > 1 ) " s " else " " } "
222
- cbIDE.renderer = IDECellRenderer (CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.retry- error.text" , delay ))
202
+ cbIDEComment.text = e? .message ? : CoderGatewayBundle .message( " gateway.connector.no- details" )
203
+ cbIDE.renderer =
204
+ if (remaining != null ) IDECellRenderer ( CoderGatewayBundle .message( " gateway.connector.view.coder.remoteproject.retry-error.text " , remaining))
205
+ else IDECellRenderer (CoderGatewayBundle .message(" gateway.connector.view.coder.remoteproject.error.text" ), UIUtil .getBalloonErrorIcon( ))
223
206
},
224
207
)
225
- if (ides != null ) {
226
- withContext(Dispatchers .Main ) {
227
- ideComboBoxModel.addAll(ides)
228
- cbIDE.selectedIndex = 0
229
- }
208
+ withContext(Dispatchers .Main ) {
209
+ ideComboBoxModel.addAll(ides)
210
+ cbIDE.selectedIndex = 0
230
211
}
231
212
}
232
213
}
0 commit comments