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

fix(services_frontend): wrong error displayed during deletion #483

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [SYSTEM] [NODE] Uniformize editable fields on API and GUI
- [HTML] [NODE] Show better field errors while editing Node parameters
- [NETWORK] Avoid defining NATing routes using loopback interfaces
- [SERVICES] [FRONTEND] Wrong error displayed on frontend deletion


## [2.18.0] - 2024-12-18
Expand Down
5 changes: 4 additions & 1 deletion vulture_os/services/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
# that is, if the frontend is associated with a policy with at least one filter with buffering configured
was_darwin_buffered = DarwinBuffering.objects.filter(destination_filter__policy__frontend_set=frontend).exists()

used_by = set(frontend.userauthentication_set.all()).union(set(frontend.workflow_set.all()))

try:
# If POST request and no error: delete frontend
frontend.delete()
Expand Down Expand Up @@ -182,7 +184,7 @@
except ProtectedError as e:
logger.error("Error trying to delete Frontend '{}': Object is currently used :".format(frontend.name))
logger.exception(e)
error = "Object is currently used by a Workflow, cannot be deleted"
error = f"Object is currently used by {used_by}, cannot be deleted"

if api:
return JsonResponse({
Expand All @@ -207,6 +209,7 @@
return render(request, 'generic_delete.html', {
'obj_inst': frontend,
'related_objs': listeners,
'used_by': used_by,
'error': error,
'redirect_url': '/services/frontend/',
'menu_name': 'Services -> Listeners -> Delete'
Expand Down Expand Up @@ -540,13 +543,13 @@
logger.debug("Frontend '{}' (id={}) saved in MongoDB.".format(frontend.name, frontend.id))

""" And all the listeners early created """
for l in listener_objs:

Check failure on line 546 in vulture_os/services/frontend/views.py

View workflow job for this annotation

GitHub Actions / check

Ruff (E741)

vulture_os/services/frontend/views.py:546:17: E741 Ambiguous variable name: `l`
l.frontend = frontend
logger.debug("Saving listener {}".format(str(l)))
l.save()

""" Delete listeners deleted in form """
for l in frontend.listener_set.exclude(pk__in=[l.id for l in listener_objs]):

Check failure on line 552 in vulture_os/services/frontend/views.py

View workflow job for this annotation

GitHub Actions / check

Ruff (E741)

vulture_os/services/frontend/views.py:552:17: E741 Ambiguous variable name: `l`

Check failure on line 552 in vulture_os/services/frontend/views.py

View workflow job for this annotation

GitHub Actions / check

Ruff (E741)

vulture_os/services/frontend/views.py:552:69: E741 Ambiguous variable name: `l`
l.delete()
logger.info("Deleting listener {}".format(l))

Expand Down
Loading