mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
fix: Multiple builds using the incorrect agent token (#983)
This was an issue with our in-memory database that caused newer builds to return an outdated agent, which would then be rejected. A test case has been added to ensure this can't happen again!
This commit is contained in:
@ -626,7 +626,9 @@ func (q *fakeQuerier) GetWorkspaceAgentByAuthToken(_ context.Context, authToken
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
for _, agent := range q.provisionerJobAgent {
|
||||
// The schema sorts this by created at, so we iterate the array backwards.
|
||||
for i := len(q.provisionerJobAgent) - 1; i >= 0; i-- {
|
||||
agent := q.provisionerJobAgent[i]
|
||||
if agent.AuthToken.String() == authToken.String() {
|
||||
return agent, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user