agones icon indicating copy to clipboard operation
agones copied to clipboard

Context has canceled bug Allocate will retry

Open alvin-7 opened this issue 2 years ago • 0 comments

pkg/gameserverallocations/allocator.go 442 lines

func (c *Allocator) allocate(ctx context.Context, gsa *allocationv1.GameServerAllocation) (*agonesv1.GameServer, error) {
	// creates an allocation request. This contains the requested GameServerAllocation, as well as the
	// channel we expect the return values to come back for this GameServerAllocation
	req := request{gsa: gsa, response: make(chan response)}

	// this pushes the request into the batching process
	c.pendingRequests <- req

	select {
	case res := <-req.response: // wait for the batch to be completed
		return res.gs, res.err
	case <-ctx.Done():
-               return nil, errors.New("shutting down")
+               return nil, ErrTotalTimeoutExceeded // or new error state to stop retry
	}
}

What happened: the context is canceled by kill signal, but allocateFromLocalCluster still retry.

What you expected to happen: return ErrTotalTimeoutExceeded when context is canceled.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

  • Agones version: latest
  • Kubernetes version (use kubectl version): N/A
  • Cloud provider or hardware configuration:N/A
  • Install method (yaml/helm):N/A
  • Troubleshooting guide log(s):N/A
  • Others:N/A

alvin-7 avatar Sep 09 '22 09:09 alvin-7