Skip to content

Commit

Permalink
Add lock on release
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHerve-Descours-Cabaud committed May 28, 2024
1 parent 4e93c39 commit 45b20d8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions core/app/handlers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,16 @@ def delete_room(body):
v1.delete_namespaced_service(namespace=namespace, name='instance-'+body["instance"])

# Remove ingress entry
networking = client.NetworkingV1Api()
current_ingress = networking.read_namespaced_ingress(name=ingress, namespace=namespace)
current_ingress_paths = current_ingress.spec.rules[0].http.paths
current_ingress_paths = list(filter(lambda x: x.backend.service.name != f"instance-{body['instance']}", current_ingress_paths))
current_ingress.spec.rules[0].http.paths = current_ingress_paths
if lock.acquire_lock():
try:
networking = client.NetworkingV1Api()
current_ingress = networking.read_namespaced_ingress(name=ingress, namespace=namespace)
current_ingress_paths = current_ingress.spec.rules[0].http.paths
current_ingress_paths = list(filter(lambda x: x.backend.service.name != f"instance-{body['instance']}", current_ingress_paths))
current_ingress.spec.rules[0].http.paths = current_ingress_paths

networking.patch_namespaced_ingress(ingress, namespace, current_ingress)
networking.patch_namespaced_ingress(ingress, namespace, current_ingress)
finally:
lock.release_lock()

return "Ok"

0 comments on commit 45b20d8

Please sign in to comment.