Skip to content

Commit e2f8fe6

Browse files
committed
Fix: retrieve agents from the template
- template is more reliable than a workspace build job (which can be one that stops) - resolves #67
1 parent 869e99c commit e2f8fe6

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
### Changed
1111
- workspace panel is now updated every 5 seconds
12+
- combinations of workspace names and agent names are now listed even when a workspace is down
1213
- minimum supported Gateway build is now 222.3739.40
1314

1415
### Fixed

src/main/kotlin/com/coder/gateway/sdk/CoderRestClientService.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ class CoderRestClientService {
101101
}
102102

103103
/**
104-
* Retrieves the workspace agents. A workspace is a collection of objects like, VMs, containers, cloud DBs, etc...
105-
* Agents run on compute hosts like VMs or containers.
104+
* Retrieves the workspace agents a template declares.
105+
* A workspace is a collection of objects like, VMs, containers, cloud DBs, etc...Agents run on compute hosts like VMs or containers.
106106
*
107107
* @throws WorkspaceResourcesResponseException if workspace resources could not be retrieved.
108108
*/
109-
fun workspaceAgents(workspace: Workspace): List<WorkspaceAgent> {
110-
val workspaceResourcesResponse = retroRestClient.workspaceResourceByBuild(workspace.latestBuild.id).execute()
109+
fun workspaceAgentsByTemplate(workspace: Workspace): List<WorkspaceAgent> {
110+
val workspaceResourcesResponse = retroRestClient.templateVersionResources(workspace.latestBuild.templateVersionID).execute()
111111
if (!workspaceResourcesResponse.isSuccessful) {
112112
throw WorkspaceResourcesResponseException("Could not retrieve agents for ${workspace.name} workspace :${workspaceResourcesResponse.code()}, reason: ${workspaceResourcesResponse.message()}")
113113
}

src/main/kotlin/com/coder/gateway/sdk/v2/CoderV2RestFacade.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ interface CoderV2RestFacade {
3131
@GET("api/v2/buildinfo")
3232
fun buildInfo(): Call<BuildInfo>
3333

34-
@GET("api/v2/workspacebuilds/{buildID}/resources")
35-
fun workspaceResourceByBuild(@Path("buildID") build: UUID): Call<List<WorkspaceResource>>
34+
@GET("api/v2/templateversions/{templateID}/resources")
35+
fun templateVersionResources(@Path("templateID") templateID: UUID): Call<List<WorkspaceResource>>
3636

3737
/**
3838
* Queues a new build to occur for a workspace.

src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
332332

333333
private fun Workspace.agentModels(): List<WorkspaceAgentModel> {
334334
return try {
335-
val agents = coderClient.workspaceAgents(this)
335+
val agents = coderClient.workspaceAgentsByTemplate(this)
336336
when (agents.size) {
337337
0 -> {
338338
listOf(

0 commit comments

Comments
 (0)