fix(multiplayer): recover ambiguous agones allocations

This commit is contained in:
Josh Creek
2026-09-01 18:05:43 +01:00
parent b72a7cf843
commit bf396afcaf
6 changed files with 161 additions and 8 deletions
+23 -4
View File
@@ -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)