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

Skip to content

Commit b6c8e5b

Browse files
authored
fix(cli/ssh): Fetch up-to-date build info to avoid ws has no agents (coder#7650)
Fixes coder#5836
1 parent f47ecc2 commit b6c8e5b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cli/ssh.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func getWorkspaceAndAgent(ctx context.Context, inv *clibase.Invocation, client *
349349
err error
350350
)
351351

352-
workspace, err = namedWorkspace(inv.Context(), client, workspaceParts[0])
352+
workspace, err = namedWorkspace(ctx, client, workspaceParts[0])
353353
if err != nil {
354354
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
355355
}
@@ -362,6 +362,11 @@ func getWorkspaceAndAgent(ctx context.Context, inv *clibase.Invocation, client *
362362
if err != nil {
363363
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
364364
}
365+
// Fetch up-to-date build information after completion.
366+
workspace.LatestBuild, err = client.WorkspaceBuild(ctx, workspace.LatestBuild.ID)
367+
if err != nil {
368+
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
369+
}
365370
}
366371
if workspace.LatestBuild.Transition == codersdk.WorkspaceTransitionDelete {
367372
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.Errorf("workspace %q is being deleted", workspace.Name)

0 commit comments

Comments
 (0)