mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-12 00:03:43 +00:00
fix(multiplayer): recover ambiguous agones allocations
This commit is contained in:
@@ -43,11 +43,30 @@ func (w Worker) RunOnce(ctx context.Context) (bool, error) {
|
||||
return true, fmt.Errorf("recover allocation for match %s: %w", request.MatchID, err)
|
||||
}
|
||||
if !recorded {
|
||||
result, err := w.Service.Allocate(ctx, request, AllocationLabels(request))
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("allocate claimed match %s: %w", request.MatchID, err)
|
||||
if recoverer, ok := w.Service.Provider.(ProviderRecoverer); ok {
|
||||
recovered, found, err := recoverer.RecoverAllocation(ctx, request, w.Now())
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("recover provider allocation for match %s: %w", request.MatchID, err)
|
||||
}
|
||||
if found {
|
||||
if _, err := w.Service.RecordProviderAllocation(ctx, recovered, w.Now()); err != nil {
|
||||
return true, fmt.Errorf("record recovered allocation for match %s: %w", request.MatchID, err)
|
||||
}
|
||||
allocation = recovered.Allocation
|
||||
} else {
|
||||
result, err := w.Service.Allocate(ctx, request, AllocationLabels(request))
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("allocate claimed match %s: %w", request.MatchID, err)
|
||||
}
|
||||
allocation = result.Allocation
|
||||
}
|
||||
} else {
|
||||
result, err := w.Service.Allocate(ctx, request, AllocationLabels(request))
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("allocate claimed match %s: %w", request.MatchID, err)
|
||||
}
|
||||
allocation = result.Allocation
|
||||
}
|
||||
allocation = result.Allocation
|
||||
}
|
||||
if err := w.Claims.BindAllocatedMatch(ctx, allocation); err != nil {
|
||||
return true, fmt.Errorf("bind allocated match %s: %w", request.MatchID, err)
|
||||
|
||||
Reference in New Issue
Block a user