Fix two items: (#2544)

* Randomize order of worker output. This uses the standard
  rand.Shuffle() call; cribbed from
  https://pkg.go.dev/math/rand#example-Shuffle
* Have some error/eventing in the worker status path use the base
  context instead of the status-call-specific context to allow eventing
  after a timeout event
This commit is contained in:
Jeff Mitchell committed 2022-10-18 16:57:07 -04:00
1 parent 16e90ddd35
commit 37273d7a9c
3 files changed
+20 -7

No files matched your search

@@ -703,6 +703,11 @@ func (s Service) AuthorizeSession(ctx context.Context, req *pbs.AuthorizeSession
"No workers are available to handle this session, or all have been filtered.")
}
// Randomize the workers
rand.Shuffle(len(selectedWorkers), func(i, j int) {
selectedWorkers[i], selectedWorkers[j] = selectedWorkers[j], selectedWorkers[i]
})
requestedId := req.GetHostId()
staticHostRepo, err := s.staticHostRepoFn()
if err != nil {