Skip to content

Commit df9944e

Browse files
committed
Add new columns to workspace agent table
1 parent bd1a87f commit df9944e

File tree

9 files changed

+260
-217
lines changed

9 files changed

+260
-217
lines changed

coderd/database/dump.sql

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
ALTER TABLE workspace_agents DROP COLUMN startup_script_timeout;
2+
ALTER TABLE workspace_agents DROP COLUMN delay_login_until_ready;
3+
14
ALTER TABLE workspace_agents DROP COLUMN lifecycle_state;
25

36
DROP TYPE workspace_agent_lifecycle_state;
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
CREATE TYPE workspace_agent_lifecycle_state AS ENUM ('created', 'starting', 'start_timeout', 'start_error', 'ready');
22

33
ALTER TABLE workspace_agents ADD COLUMN lifecycle_state workspace_agent_lifecycle_state NOT NULL DEFAULT 'created';
4-
54
COMMENT ON COLUMN workspace_agents.lifecycle_state IS 'The current lifecycle state of the workspace agent.';
5+
6+
/* Set default values that conform to current behavior */
7+
/* Allow logins immediately after agent connect */
8+
ALTER TABLE workspace_agents ADD COLUMN delay_login_until_ready boolean NOT NULL DEFAULT false;
9+
COMMENT ON COLUMN workspace_agents.delay_login_until_ready IS 'If true, the agent will delay logins until it is ready (e.g. executing startup script has ended).';
10+
11+
/* Disable startup script timeouts by default */
12+
ALTER TABLE workspace_agents ADD COLUMN startup_script_timeout_seconds int4 NOT NULL DEFAULT 0;
13+
COMMENT ON COLUMN workspace_agents.startup_script_timeout_seconds IS 'The number of seconds to wait for the startup script to complete. If the script does not complete within this time, the agent lifecycle will be marked as start_timeout.';

coderd/database/models.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 42 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaceagents.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ INSERT INTO
5656
resource_metadata,
5757
connection_timeout_seconds,
5858
troubleshooting_url,
59-
motd_file
59+
motd_file,
60+
delay_login_until_ready,
61+
startup_script_timeout_seconds
6062
)
6163
VALUES
62-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) RETURNING *;
64+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19) RETURNING *;
6365

6466
-- name: UpdateWorkspaceAgentConnectionByID :exec
6567
UPDATE

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,11 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
946946
String: prAgent.StartupScript,
947947
Valid: prAgent.StartupScript != "",
948948
},
949-
ConnectionTimeoutSeconds: prAgent.GetConnectionTimeoutSeconds(),
950-
TroubleshootingURL: prAgent.GetTroubleshootingUrl(),
951-
MOTDFile: prAgent.GetMotdFile(),
949+
ConnectionTimeoutSeconds: prAgent.GetConnectionTimeoutSeconds(),
950+
TroubleshootingURL: prAgent.GetTroubleshootingUrl(),
951+
MOTDFile: prAgent.GetMotdFile(),
952+
DelayLoginUntilReady: prAgent.GetDelayLoginUntilReady(),
953+
StartupScriptTimeoutSeconds: prAgent.GetStartupScriptTimeoutSeconds(),
952954
})
953955
if err != nil {
954956
return xerrors.Errorf("insert agent: %w", err)

0 commit comments

Comments
 (0)