Skip to content

Commit 90fff42

Browse files
committed
chore: Invert delay_login_until_ready, now login_before_ready
1 parent a753703 commit 90fff42

26 files changed

+331
-315
lines changed

cli/cliui/agent.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
4545
// We don't take the fast path for opts.NoWait yet because we want to
4646
// show the message.
4747
if agent.Status == codersdk.WorkspaceAgentConnected &&
48-
(!agent.DelayLoginUntilReady || agent.LifecycleState == codersdk.WorkspaceAgentLifecycleReady) {
48+
(agent.LoginBeforeReady || agent.LifecycleState == codersdk.WorkspaceAgentLifecycleReady) {
4949
return nil
5050
}
5151

@@ -93,7 +93,7 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
9393
// we do this just before starting the spinner to avoid needless
9494
// spinning.
9595
if agent.Status == codersdk.WorkspaceAgentConnected &&
96-
agent.DelayLoginUntilReady && opts.NoWait {
96+
!agent.LoginBeforeReady && opts.NoWait {
9797
showMessage()
9898
return nil
9999
}
@@ -137,7 +137,7 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
137137
// NOTE(mafredri): Once we have access to the workspace agent's
138138
// startup script logs, we can show them here.
139139
// https://github.com/coder/coder/issues/2957
140-
if agent.DelayLoginUntilReady && !opts.NoWait {
140+
if !agent.LoginBeforeReady && !opts.NoWait {
141141
switch agent.LifecycleState {
142142
case codersdk.WorkspaceAgentLifecycleReady:
143143
return nil

cli/cliui/agent_test.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ func TestAgent_StartupTimeout(t *testing.T) {
119119
WorkspaceName: "example",
120120
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
121121
agent := codersdk.WorkspaceAgent{
122-
Status: codersdk.WorkspaceAgentConnecting,
123-
DelayLoginUntilReady: true,
124-
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
125-
TroubleshootingURL: wantURL,
122+
Status: codersdk.WorkspaceAgentConnecting,
123+
LoginBeforeReady: false,
124+
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
125+
TroubleshootingURL: wantURL,
126126
}
127127

128128
if s := status.Load(); s != "" {
@@ -177,10 +177,10 @@ func TestAgent_StartErrorExit(t *testing.T) {
177177
WorkspaceName: "example",
178178
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
179179
agent := codersdk.WorkspaceAgent{
180-
Status: codersdk.WorkspaceAgentConnecting,
181-
DelayLoginUntilReady: true,
182-
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
183-
TroubleshootingURL: wantURL,
180+
Status: codersdk.WorkspaceAgentConnecting,
181+
LoginBeforeReady: false,
182+
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
183+
TroubleshootingURL: wantURL,
184184
}
185185

186186
if s := status.Load(); s != "" {
@@ -232,10 +232,10 @@ func TestAgent_NoWait(t *testing.T) {
232232
WorkspaceName: "example",
233233
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
234234
agent := codersdk.WorkspaceAgent{
235-
Status: codersdk.WorkspaceAgentConnecting,
236-
DelayLoginUntilReady: true,
237-
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
238-
TroubleshootingURL: wantURL,
235+
Status: codersdk.WorkspaceAgentConnecting,
236+
LoginBeforeReady: false,
237+
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
238+
TroubleshootingURL: wantURL,
239239
}
240240

241241
if s := status.Load(); s != "" {
@@ -301,10 +301,10 @@ func TestAgent_DelayLoginUntilReadyDisabled(t *testing.T) {
301301
WorkspaceName: "example",
302302
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
303303
agent := codersdk.WorkspaceAgent{
304-
Status: codersdk.WorkspaceAgentConnecting,
305-
DelayLoginUntilReady: false,
306-
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
307-
TroubleshootingURL: wantURL,
304+
Status: codersdk.WorkspaceAgentConnecting,
305+
LoginBeforeReady: true,
306+
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
307+
TroubleshootingURL: wantURL,
308308
}
309309

310310
if s := status.Load(); s != "" {

coderd/apidoc/docs.go

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dump.sql

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
BEGIN;
2+
ALTER TABLE workspace_agents RENAME COLUMN login_before_ready TO delay_login_until_ready;
3+
ALTER TABLE workspace_agents ALTER COLUMN delay_login_until_ready SET DEFAULT false;
4+
5+
UPDATE workspace_agents SET delay_login_until_ready = NOT delay_login_until_ready;
6+
7+
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).';
8+
COMMIT;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
BEGIN;
2+
ALTER TABLE workspace_agents RENAME COLUMN delay_login_until_ready TO login_before_ready;
3+
ALTER TABLE workspace_agents ALTER COLUMN login_before_ready SET DEFAULT true;
4+
5+
UPDATE workspace_agents SET login_before_ready = NOT login_before_ready;
6+
7+
COMMENT ON COLUMN workspace_agents.login_before_ready IS 'If true, the agent will not prevent login before it is ready (e.g. startup script is still executing).';
8+
COMMIT;

coderd/database/models.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

+15-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaceagents.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ INSERT INTO
5757
connection_timeout_seconds,
5858
troubleshooting_url,
5959
motd_file,
60-
delay_login_until_ready,
60+
login_before_ready,
6161
startup_script_timeout_seconds
6262
)
6363
VALUES

coderd/workspaceagents.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
785785
ConnectionTimeoutSeconds: dbAgent.ConnectionTimeoutSeconds,
786786
TroubleshootingURL: troubleshootingURL,
787787
LifecycleState: codersdk.WorkspaceAgentLifecycle(dbAgent.LifecycleState),
788-
DelayLoginUntilReady: dbAgent.DelayLoginUntilReady,
788+
LoginBeforeReady: dbAgent.LoginBeforeReady,
789789
StartupScriptTimeoutSeconds: dbAgent.StartupScriptTimeoutSeconds,
790790
}
791791
node := coordinator.Node(dbAgent.ID)

codersdk/workspaceagents.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ type WorkspaceAgent struct {
7777
DERPLatency map[string]DERPRegion `json:"latency,omitempty"`
7878
ConnectionTimeoutSeconds int32 `json:"connection_timeout_seconds"`
7979
TroubleshootingURL string `json:"troubleshooting_url"`
80-
// DelayLoginUntilReady if true, the agent will delay logins until it is ready (e.g. executing startup script has ended).
81-
DelayLoginUntilReady bool `db:"delay_login_until_ready" json:"delay_login_until_ready"`
80+
// LoginBeforeReady if true, the agent will delay logins until it is ready (e.g. executing startup script has ended).
81+
LoginBeforeReady bool `db:"login_before_ready" json:"login_before_ready"`
8282
// StartupScriptTimeoutSeconds 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.
8383
StartupScriptTimeoutSeconds int32 `db:"startup_script_timeout_seconds" json:"startup_script_timeout_seconds"`
8484
}

0 commit comments

Comments
 (0)