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

Added lock for EVC deletion #480

Merged
merged 5 commits into from
Jul 22, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,23 +424,25 @@ def delete_circuit(self, request: Request) -> JSONResponse:
"""
circuit_id = request.path_params["circuit_id"]
log.debug("delete_circuit /v2/evc/%s", circuit_id)
try:
evc = self.circuits.pop(circuit_id)
except KeyError:
result = f"circuit_id {circuit_id} not found"
log.debug("delete_circuit result %s %s", result, 404)
raise HTTPException(404, detail=result) from KeyError
with self._lock:
try:
evc = self.circuits.pop(circuit_id)
except KeyError:
result = f"circuit_id {circuit_id} not found"
log.debug("delete_circuit result %s %s", result, 404)
raise HTTPException(404, detail=result) from KeyError

log.info("Removing %s", evc)
with evc.lock:
evc.remove_current_flows()
evc.remove_failover_flows(sync=False)
evc.deactivate()
evc.disable()
self.sched.remove(evc)
evc.archive()
evc.remove_uni_tags()
evc.sync()

log.info("Removing %s", evc)
with evc.lock:
evc.remove_current_flows()
evc.remove_failover_flows(sync=False)
evc.deactivate()
evc.disable()
self.sched.remove(evc)
evc.archive()
evc.remove_uni_tags()
evc.sync()
log.info("EVC removed. %s", evc)
result = {"response": f"Circuit {circuit_id} removed"}
status = 200
Expand Down
Loading