Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit db82812

Browse files
committedJun 11, 2025·
fix: provide latest resources for agent matching
Before agent matching we check the state of a workspace and if it is stopped we automatically start it (if Disable autostart is not enabled). However the agent matching code still received an old copy of the stopped workspace. Stopped workspaces don't have resources.
1 parent fd55a2c commit db82812

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ class CoderRemoteProvider(
109109
return@launch
110110
}
111111

112-
113112
// Reconfigure if environments changed.
114113
if (lastEnvironments.size != resolvedEnvironments.size || lastEnvironments != resolvedEnvironments) {
115114
context.logger.info("Workspaces have changed, reconfiguring CLI: $resolvedEnvironments")

‎src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ open class CoderProtocolHandler(
7575
if (!prepareWorkspace(workspace, restClient, workspaceName, deploymentURL)) return
7676
// we resolve the agent after the workspace is started otherwise we can get misleading
7777
// errors like: no agent available while workspace is starting or stopping
78-
agent = resolveAgent(params, workspace) ?: return
78+
// we also need to retrieve the workspace again to have the latest resources (ex: agent)
79+
// attached to the workspace.
80+
agent = resolveAgent(
81+
params,
82+
restClient.workspace(workspace.id)
83+
) ?: return
7984
if (!ensureAgentIsReady(workspace, agent)) return
8085
} finally {
8186
unmarkAsBusy()

0 commit comments

Comments
 (0)
Please sign in to comment.