From 4d26778871e737512cb307db66ffe88277319403 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 23 May 2023 15:55:10 +0000 Subject: [PATCH 1/2] fix(cli/ssh): Fetch up-to-date build info to avoid ws has no agents Fixes #5836 --- cli/ssh.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cli/ssh.go b/cli/ssh.go index 5b89ca9fc56ad..db22cfd40f12f 100644 --- a/cli/ssh.go +++ b/cli/ssh.go @@ -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) From 2fd7d2350b6732167593c6ae25eb6e970c09ef27 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 23 May 2023 15:58:48 +0000 Subject: [PATCH 2/2] Fly-by fix, use correct context --- cli/ssh.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/ssh.go b/cli/ssh.go index db22cfd40f12f..aa8a4cad1f877 100644 --- a/cli/ssh.go +++ b/cli/ssh.go @@ -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 }