mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
chore: refactor agent routines that use the v2 API (#12223)
In anticipation of needing the `LogSender` to run on a context that doesn't get immediately canceled when you `Close()` the agent, I've undertaken a little refactor to manage the goroutines that get run against the Tailnet and Agent API connection. This handles controlling two contexts, one that gets canceled right away at the start of graceful shutdown, and another that stays up to allow graceful shutdown to complete.
This commit is contained in:
@ -231,13 +231,14 @@ func TestAuditLogging(t *testing.T) {
|
||||
},
|
||||
DontAddLicense: true,
|
||||
})
|
||||
workspace, agent := setupWorkspaceAgent(t, client, user, 0)
|
||||
conn, err := client.DialWorkspaceAgent(ctx, agent.ID, nil) //nolint:gocritic // RBAC is not the purpose of this test
|
||||
r := setupWorkspaceAgent(t, client, user, 0)
|
||||
conn, err := client.DialWorkspaceAgent(ctx, r.sdkAgent.ID, nil) //nolint:gocritic // RBAC is not the purpose of this test
|
||||
require.NoError(t, err)
|
||||
defer conn.Close()
|
||||
connected := conn.AwaitReachable(ctx)
|
||||
require.True(t, connected)
|
||||
build := coderdtest.CreateWorkspaceBuild(t, client, workspace, database.WorkspaceTransitionStop)
|
||||
_ = r.agent.Close() // close first so we don't drop error logs from outdated build
|
||||
build := coderdtest.CreateWorkspaceBuild(t, client, r.workspace, database.WorkspaceTransitionStop)
|
||||
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, build.ID)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user