Skip to content

Commit

Permalink
fix(game-creator): catch exc when removing path (#1474)
Browse files Browse the repository at this point in the history
* fix(game-creator): catch exc when removing path

* test with no ingress
  • Loading branch information
razvan-pro committed Feb 26, 2021
1 parent b66830e commit 40e7e1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aimmo-game-creator/game_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ def _remove_path_from_ingress(self, game_id):
path = kubernetes.client.NetworkingV1beta1HTTPIngressPath(
backend, f"/{game_name}(/|$)(.*)"
)
ingress = self.networking_api.list_namespaced_ingress("default").items[0]
try:
ingress = self.networking_api.list_namespaced_ingress("default").items[0]
except IndexError:
LOGGER.warning("No ingress found to remove path from.")
return
paths = ingress.spec.rules[0].http.paths
try:
index_to_delete = paths.index(path)
Expand Down
4 changes: 4 additions & 0 deletions aimmo-game-creator/tests/test_game_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,7 @@ def test_delete_game(self):
),
]
)

# Test again with no ingress
game_manager.networking_api.list_namespaced_ingress.return_value.items = []
game_manager.delete_game(100)

0 comments on commit 40e7e1e

Please sign in to comment.