Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ecee858

Browse files
committed
Only enable connection timeouts when set to non-zero
1 parent b567c55 commit ecee858

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

cli/ssh_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ func TestSSH(t *testing.T) {
110110

111111
wantURL := "https://example.com/troubleshoot"
112112
client, workspace, _ := setupWorkspaceForAgent(t, func(a []*proto.Agent) []*proto.Agent {
113-
// One second is the lowest we can go.
113+
// Unfortunately, one second is the lowest
114+
// we can go because 0 disables the feature.
114115
a[0].ConnectionTimeout = 1
115116
a[0].TroubleshootingUrl = wantURL
116117
return a

coderd/database/dump.sql

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
BEGIN;
22

3-
-- Default value same as in terraform-provider-coder.
43
ALTER TABLE workspace_agents
5-
ADD COLUMN connection_timeout integer NOT NULL DEFAULT 120;
4+
ADD COLUMN connection_timeout integer NOT NULL DEFAULT 0;
5+
6+
COMMENT ON COLUMN workspace_agents.connection_timeout IS 'Connection timeout in seconds, 0 means disabled.';
67

78
ALTER TABLE workspace_agents
89
ADD COLUMN troubleshooting_url text NOT NULL DEFAULT '';
910

11+
COMMENT ON COLUMN workspace_agents.troubleshooting_url IS 'URL for troubleshooting the agent.';
12+
1013
COMMIT;

coderd/workspaceagents.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,10 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
722722
}
723723

724724
connectionTimeout := time.Duration(dbAgent.ConnectionTimeout) * time.Second
725-
726725
switch {
727726
case !dbAgent.FirstConnectedAt.Valid:
728727
switch {
729-
case database.Now().Sub(dbAgent.CreatedAt) > connectionTimeout:
728+
case connectionTimeout > 0 && database.Now().Sub(dbAgent.CreatedAt) > connectionTimeout:
730729
// If the agent took too long to connect the first time,
731730
// mark it as timed out.
732731
workspaceAgent.Status = codersdk.WorkspaceAgentTimeout

0 commit comments

Comments
 (0)