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

Skip to content

Commit 57e130f

Browse files
committed
chore: Invert delay_login_until_ready, now login_before_ready
1 parent a753703 commit 57e130f

28 files changed

+336
-320
lines changed

cli/cliui/agent.go

Lines changed: 3 additions & 3 deletions
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

Lines changed: 17 additions & 17 deletions
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 != "" {
@@ -284,7 +284,7 @@ func TestAgent_NoWait(t *testing.T) {
284284
require.NoError(t, <-done, "ready - should exit early")
285285
}
286286

287-
func TestAgent_DelayLoginUntilReadyDisabled(t *testing.T) {
287+
func TestAgent_LoginBeforeReadyEnabled(t *testing.T) {
288288
t.Parallel()
289289

290290
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
@@ -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

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

coderd/apidoc/swagger.json

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

coderd/database/dump.sql

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 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: 15 additions & 15 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: 1 addition & 1 deletion
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/provisionerdserver/provisionerdserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
972972
ConnectionTimeoutSeconds: prAgent.GetConnectionTimeoutSeconds(),
973973
TroubleshootingURL: prAgent.GetTroubleshootingUrl(),
974974
MOTDFile: prAgent.GetMotdFile(),
975-
DelayLoginUntilReady: prAgent.GetDelayLoginUntilReady(),
975+
LoginBeforeReady: prAgent.GetLoginBeforeReady(),
976976
StartupScriptTimeoutSeconds: prAgent.GetStartupScriptTimeoutSeconds(),
977977
})
978978
if err != nil {

coderd/workspaceagents.go

Lines changed: 1 addition & 1 deletion
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)

0 commit comments

Comments
 (0)