Skip to content

Commit

Permalink
fix(cli/ssh): Fetch up-to-date build info to avoid ws has no agents (#…
Browse files Browse the repository at this point in the history
…7650)

Fixes #5836
  • Loading branch information
mafredri committed May 24, 2023
1 parent f47ecc2 commit b6c8e5b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cli/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func getWorkspaceAndAgent(ctx context.Context, inv *clibase.Invocation, client *
err error
)

workspace, err = namedWorkspace(inv.Context(), client, workspaceParts[0])
workspace, err = namedWorkspace(ctx, client, workspaceParts[0])
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
}
Expand All @@ -362,6 +362,11 @@ func getWorkspaceAndAgent(ctx context.Context, inv *clibase.Invocation, client *
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
}
// Fetch up-to-date build information after completion.
workspace.LatestBuild, err = client.WorkspaceBuild(ctx, workspace.LatestBuild.ID)
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
}
}
if workspace.LatestBuild.Transition == codersdk.WorkspaceTransitionDelete {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.Errorf("workspace %q is being deleted", workspace.Name)
Expand Down

0 comments on commit b6c8e5b

Please sign in to comment.