Skip to content

Commit 9fdb354

Browse files
committed
Fix start/shutdown timeout status
These mean the script is still running and is taking longer than expected. Also we can connect with login_before_ready when in the start_timeout state.
1 parent d5abf2b commit 9fdb354

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/main/kotlin/com/coder/gateway/models/WorkspaceAndAgentStatus.kt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,36 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
2828
CONNECTING("⦿ Connecting", "The agent is connecting."),
2929
DISCONNECTED("⦸ Disconnected", "The agent has disconnected."),
3030
TIMEOUT("ⓧ Timeout", "The agent has timed out."),
31-
AGENT_STARTING("⦿ Starting", "The agent is running the startup script."),
32-
AGENT_STARTING_READY("⦿ Starting", "The agent is running the startup script but is ready to accept connections."),
31+
AGENT_STARTING("⦿ Starting", "The startup script is running."),
32+
AGENT_STARTING_READY("⦿ Starting", "The startup script is still running but the agent ready to accept connections."),
3333
CREATED("⦿ Created", "The agent has been created."),
3434
START_ERROR("◍ Started with error", "The agent is ready but the startup script errored."),
35-
START_TIMEOUT("◍ Started with timeout", "The agent is ready but the startup script timed out"),
35+
START_TIMEOUT("◍ Starting", "The startup script is taking longer than expected."),
36+
START_TIMEOUT_READY("◍ Starting", "The startup script is taking longer than expected but the agent is ready to accept connections."),
3637
SHUTTING_DOWN("◍ Shutting down", "The agent is shutting down."),
3738
SHUTDOWN_ERROR("⦸ Shutdown with error", "The agent shut down but the shutdown script errored."),
38-
SHUTDOWN_TIMEOUT("Shutdown with timeout", "The agent shut down but the shutdown script timed out."),
39+
SHUTDOWN_TIMEOUT("Shutting down", "The shutdown script is taking longer than expected."),
3940
OFF("⦸ Off", "The agent has shut down."),
4041
READY("⦿ Ready", "The agent is ready to accept connections.");
4142

4243
fun statusColor(): JBColor = when (this) {
43-
READY, AGENT_STARTING_READY -> JBColor.GREEN
44-
START_ERROR, START_TIMEOUT -> JBColor.YELLOW
45-
FAILED, DISCONNECTED, TIMEOUT, SHUTTING_DOWN, SHUTDOWN_ERROR, SHUTDOWN_TIMEOUT -> JBColor.RED
44+
READY, AGENT_STARTING_READY, START_TIMEOUT_READY -> JBColor.GREEN
45+
START_ERROR, START_TIMEOUT, SHUTDOWN_TIMEOUT -> JBColor.YELLOW
46+
FAILED, DISCONNECTED, TIMEOUT, SHUTDOWN_ERROR -> JBColor.RED
4647
else -> if (JBColor.isBright()) JBColor.LIGHT_GRAY else JBColor.DARK_GRAY
4748
}
4849

4950
// We want to check that the workspace is `running`, the agent is
5051
// `connected`, and the agent lifecycle state is `ready` to ensure the best
5152
// possible scenario for attempting a connection.
5253
//
53-
// We can also choose to allow `start_timeout` and `start_error` for the
54-
// agent state; this means the startup script did not successfully complete
55-
// but the agent will accept SSH connections.
54+
// We can also choose to allow `start_error` for the agent state; this means
55+
// the startup script did not successfully complete but the agent will still
56+
// accept SSH connections.
5657
//
5758
// Lastly we can also allow connections when the agent lifecycle state is
58-
// `starting` if `login_before_ready` is true on the workspace response.
59+
// `starting` or `start_timeout` if `login_before_ready` is true on the
60+
// workspace response since this bypasses the need to wait for the script.
5961
//
6062
// Note that latest_build.status is derived from latest_build.job.status and
6163
// latest_build.job.transition so there is no need to check those.
@@ -67,7 +69,7 @@ enum class WorkspaceAndAgentStatus(val label: String, val description: String) {
6769
WorkspaceAgentStatus.CONNECTED -> when (agent.lifecycleState) {
6870
WorkspaceAgentLifecycleState.CREATED -> CREATED
6971
WorkspaceAgentLifecycleState.STARTING -> if (agent.loginBeforeReady == true) AGENT_STARTING_READY else AGENT_STARTING
70-
WorkspaceAgentLifecycleState.START_TIMEOUT -> START_TIMEOUT
72+
WorkspaceAgentLifecycleState.START_TIMEOUT -> if (agent.loginBeforeReady == true) START_TIMEOUT_READY else START_TIMEOUT
7173
WorkspaceAgentLifecycleState.START_ERROR -> START_ERROR
7274
WorkspaceAgentLifecycleState.READY -> READY
7375
WorkspaceAgentLifecycleState.SHUTTING_DOWN -> SHUTTING_DOWN

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
133133
setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
134134
selectionModel.addListSelectionListener {
135135
val ready = listOf(
136-
WorkspaceAndAgentStatus.READY, WorkspaceAndAgentStatus.START_ERROR,
137-
WorkspaceAndAgentStatus.START_TIMEOUT, WorkspaceAndAgentStatus.AGENT_STARTING_READY
136+
WorkspaceAndAgentStatus.READY,
137+
WorkspaceAndAgentStatus.START_ERROR,
138+
WorkspaceAndAgentStatus.AGENT_STARTING_READY,
139+
WorkspaceAndAgentStatus.START_TIMEOUT_READY,
138140
).contains(selectedObject?.agentStatus)
139141
setNextButtonEnabled(ready && selectedObject?.agentOS == OS.LINUX)
140142
if (ready && selectedObject?.agentOS != OS.LINUX) {

0 commit comments

Comments
 (0)