From 738fc07aba839670bd54f10c22083b334158d25d Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 15 Mar 2023 13:14:00 -0800 Subject: [PATCH 1/2] Use the same port for all executors Gateway seems to keep the SSH sessions up (as indicated by the Coder proxy process persisting) and since we have one executor using port 22 and another using port 0 it was spawning two separate processes. Using the same port causes it to use the existing process. No idea if this will really affect much but I guess it does at least help guarantee that if you were able to list the editors you will be able to connect as well since it would use the same connection? --- .../gateway/views/steps/CoderLocateRemoteProjectStepView.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt index 9172eeea..dd2ccfe9 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt @@ -217,6 +217,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit RemoteCredentialsHolder().apply { setHost("coder.${wizard.selectedWorkspace?.name}") userName = "coder" + port = 22 authType = AuthType.OPEN_SSH }, true From 2f16bf32d51cf4f13de367208e3a6be0016c49ec Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 15 Mar 2023 13:14:04 -0800 Subject: [PATCH 2/2] Pass in selected workspace to executor No really good reason, just figured since we already have it and we use it in other function calls in the same area we might as well. It does let us avoid the `?` I suppose. --- .../views/steps/CoderLocateRemoteProjectStepView.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt b/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt index dd2ccfe9..558e6dd5 100644 --- a/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt +++ b/src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt @@ -140,7 +140,7 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit ideResolvingJob = cs.launch { try { - val executor = withTimeout(Duration.ofSeconds(60)) { createRemoteExecutor() } + val executor = withTimeout(Duration.ofSeconds(60)) { createRemoteExecutor(selectedWorkspace) } retrieveIDES(executor, selectedWorkspace) if (ComponentValidator.getInstance(tfProject).isEmpty) { installRemotePathValidator(executor) @@ -212,10 +212,10 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit }) } - private suspend fun createRemoteExecutor(): HighLevelHostAccessor { + private suspend fun createRemoteExecutor(selectedWorkspace: WorkspaceAgentModel): HighLevelHostAccessor { return HighLevelHostAccessor.create( RemoteCredentialsHolder().apply { - setHost("coder.${wizard.selectedWorkspace?.name}") + setHost("coder.${selectedWorkspace.name}") userName = "coder" port = 22 authType = AuthType.OPEN_SSH @@ -352,4 +352,4 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit companion object { val logger = Logger.getInstance(CoderLocateRemoteProjectStepView::class.java.simpleName) } -} \ No newline at end of file +}