Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(game-servers): Improve available gameserver detection #1341

Conversation

NetroScript
Copy link
Contributor

@NetroScript NetroScript commented Nov 2, 2021

Sometimes it happens, that a game server references a game, despite that game not running anymore.

This PR improves the detection of available game servers. Instead if just checking if a game server has a game property, it also loads the game which is attached to the game server to confirm, that the game is still running.

If the game is not running anymore, the game server gets released and returned as available.

Additionally this PR adds a property endedAt to the Game model. This is used to identify if a cleanup of a game is already finished.

This PR only releases a game server, if the game state is ended or interrupted since at least two minutes.

@NetroScript NetroScript force-pushed the improve-available-gameserver-detection branch from 9fa57bb to 751ceab Compare November 2, 2021 20:43
@garrappachc
Copy link
Member

We need to make sure not only the assigned game has ended, but also the gameserver it was running on got cleaned up.

@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #1341 (5df9411) into master (b82b557) will increase coverage by 11.55%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1341       +/-   ##
===========================================
+ Coverage   83.48%   95.04%   +11.55%     
===========================================
  Files         182      182               
  Lines        3652     3670       +18     
  Branches      328      334        +6     
===========================================
+ Hits         3049     3488      +439     
+ Misses        602      180      -422     
- Partials        1        2        +1     
Impacted Files Coverage Δ
src/games/services/game-event-handler.service.ts 95.94% <ø> (ø)
src/games/services/game-runtime.service.ts 90.78% <ø> (ø)
src/game-servers/services/game-servers.service.ts 95.45% <100.00%> (+1.08%) ⬆️
src/games/models/game.ts 97.43% <100.00%> (+0.06%) ⬆️
src/games/services/player-substitution.service.ts 98.41% <0.00%> (+2.38%) ⬆️
src/queue/services/queue.service.ts 89.38% <0.00%> (+2.79%) ⬆️
src/games/models/game-slot.ts 100.00% <0.00%> (+6.25%) ⬆️
...ame-servers/controllers/game-servers.controller.ts 100.00% <0.00%> (+7.14%) ⬆️
src/profile/services/profile.service.ts 100.00% <0.00%> (+10.00%) ⬆️
... and 30 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b82b557...5df9411. Read the comment docs.

This property is needed to ensure that the cleanup already happened of a server
@garrappachc garrappachc merged commit 535b540 into tf2pickup-org:master Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants