mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: Invert delay_login_until_ready, now login_before_ready (#5893)
This commit is contained in:
+4
-4
@@ -45,7 +45,7 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
|
||||
// We don't take the fast path for opts.NoWait yet because we want to
|
||||
// show the message.
|
||||
if agent.Status == codersdk.WorkspaceAgentConnected &&
|
||||
(!agent.DelayLoginUntilReady || agent.LifecycleState == codersdk.WorkspaceAgentLifecycleReady) {
|
||||
(agent.LoginBeforeReady || agent.LifecycleState == codersdk.WorkspaceAgentLifecycleReady) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
|
||||
// we do this just before starting the spinner to avoid needless
|
||||
// spinning.
|
||||
if agent.Status == codersdk.WorkspaceAgentConnected &&
|
||||
agent.DelayLoginUntilReady && opts.NoWait {
|
||||
!agent.LoginBeforeReady && opts.NoWait {
|
||||
showMessage()
|
||||
return nil
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
|
||||
// NOTE(mafredri): Once we have access to the workspace agent's
|
||||
// startup script logs, we can show them here.
|
||||
// https://github.com/coder/coder/issues/2957
|
||||
if agent.DelayLoginUntilReady && !opts.NoWait {
|
||||
if !agent.LoginBeforeReady && !opts.NoWait {
|
||||
switch agent.LifecycleState {
|
||||
case codersdk.WorkspaceAgentLifecycleReady:
|
||||
return nil
|
||||
@@ -176,7 +176,7 @@ func waitingMessage(agent codersdk.WorkspaceAgent, opts AgentOptions) (m *messag
|
||||
Prompt: "Don't panic, your workspace is booting up!",
|
||||
}
|
||||
defer func() {
|
||||
if opts.NoWait {
|
||||
if agent.Status == codersdk.WorkspaceAgentConnected && opts.NoWait {
|
||||
m.Spin = ""
|
||||
}
|
||||
if m.Spin != "" {
|
||||
|
||||
+20
-18
@@ -30,7 +30,8 @@ func TestAgent(t *testing.T) {
|
||||
WorkspaceName: "example",
|
||||
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
|
||||
agent := codersdk.WorkspaceAgent{
|
||||
Status: codersdk.WorkspaceAgentDisconnected,
|
||||
Status: codersdk.WorkspaceAgentDisconnected,
|
||||
LoginBeforeReady: true,
|
||||
}
|
||||
if disconnected.Load() {
|
||||
agent.Status = codersdk.WorkspaceAgentConnected
|
||||
@@ -73,6 +74,7 @@ func TestAgent_TimeoutWithTroubleshootingURL(t *testing.T) {
|
||||
agent := codersdk.WorkspaceAgent{
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
TroubleshootingURL: wantURL,
|
||||
LoginBeforeReady: true,
|
||||
}
|
||||
switch {
|
||||
case !connected.Load() && timeout.Load():
|
||||
@@ -119,10 +121,10 @@ func TestAgent_StartupTimeout(t *testing.T) {
|
||||
WorkspaceName: "example",
|
||||
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
|
||||
agent := codersdk.WorkspaceAgent{
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
DelayLoginUntilReady: true,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
TroubleshootingURL: wantURL,
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
LoginBeforeReady: false,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
TroubleshootingURL: wantURL,
|
||||
}
|
||||
|
||||
if s := status.Load(); s != "" {
|
||||
@@ -177,10 +179,10 @@ func TestAgent_StartErrorExit(t *testing.T) {
|
||||
WorkspaceName: "example",
|
||||
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
|
||||
agent := codersdk.WorkspaceAgent{
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
DelayLoginUntilReady: true,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
TroubleshootingURL: wantURL,
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
LoginBeforeReady: false,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
TroubleshootingURL: wantURL,
|
||||
}
|
||||
|
||||
if s := status.Load(); s != "" {
|
||||
@@ -232,10 +234,10 @@ func TestAgent_NoWait(t *testing.T) {
|
||||
WorkspaceName: "example",
|
||||
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
|
||||
agent := codersdk.WorkspaceAgent{
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
DelayLoginUntilReady: true,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
TroubleshootingURL: wantURL,
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
LoginBeforeReady: false,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
TroubleshootingURL: wantURL,
|
||||
}
|
||||
|
||||
if s := status.Load(); s != "" {
|
||||
@@ -284,7 +286,7 @@ func TestAgent_NoWait(t *testing.T) {
|
||||
require.NoError(t, <-done, "ready - should exit early")
|
||||
}
|
||||
|
||||
func TestAgent_DelayLoginUntilReadyDisabled(t *testing.T) {
|
||||
func TestAgent_LoginBeforeReadyEnabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
@@ -301,10 +303,10 @@ func TestAgent_DelayLoginUntilReadyDisabled(t *testing.T) {
|
||||
WorkspaceName: "example",
|
||||
Fetch: func(_ context.Context) (codersdk.WorkspaceAgent, error) {
|
||||
agent := codersdk.WorkspaceAgent{
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
DelayLoginUntilReady: false,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
TroubleshootingURL: wantURL,
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
LoginBeforeReady: true,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
TroubleshootingURL: wantURL,
|
||||
}
|
||||
|
||||
if s := status.Load(); s != "" {
|
||||
|
||||
@@ -26,6 +26,7 @@ func TestWorkspaceResources(t *testing.T) {
|
||||
Agents: []codersdk.WorkspaceAgent{{
|
||||
Name: "dev",
|
||||
Status: codersdk.WorkspaceAgentConnected,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
Architecture: "amd64",
|
||||
OperatingSystem: "linux",
|
||||
}},
|
||||
@@ -60,6 +61,7 @@ func TestWorkspaceResources(t *testing.T) {
|
||||
Agents: []codersdk.WorkspaceAgent{{
|
||||
CreatedAt: database.Now().Add(-10 * time.Second),
|
||||
Status: codersdk.WorkspaceAgentConnecting,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleCreated,
|
||||
Name: "dev",
|
||||
OperatingSystem: "linux",
|
||||
Architecture: "amd64",
|
||||
@@ -70,12 +72,14 @@ func TestWorkspaceResources(t *testing.T) {
|
||||
Name: "dev",
|
||||
Agents: []codersdk.WorkspaceAgent{{
|
||||
Status: codersdk.WorkspaceAgentConnected,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleReady,
|
||||
Name: "go",
|
||||
Architecture: "amd64",
|
||||
OperatingSystem: "linux",
|
||||
}, {
|
||||
DisconnectedAt: &disconnected,
|
||||
Status: codersdk.WorkspaceAgentDisconnected,
|
||||
LifecycleState: codersdk.WorkspaceAgentLifecycleReady,
|
||||
Name: "postgres",
|
||||
Architecture: "amd64",
|
||||
OperatingSystem: "linux",
|
||||
|
||||
Reference in New Issue
Block a user