Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FoD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Schmitz
FoD
Commits
933a85e4
Commit
933a85e4
authored
3 years ago
by
David Schmitz
Browse files
Options
Downloads
Patches
Plain Diff
fix for new tasks::delete_route
parent
486cf3bb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flowspec/tasks.py
+4
-2
4 additions, 2 deletions
flowspec/tasks.py
flowspec/test_viewsets.py
+3
-3
3 additions, 3 deletions
flowspec/test_viewsets.py
with
7 additions
and
5 deletions
flowspec/tasks.py
+
4
−
2
View file @
933a85e4
...
...
@@ -140,6 +140,7 @@ def delete_route(routepk, **kwargs):
"""
For Route in ACTIVE state, deactivate it at first. Finally, delete the Route from the DB. Permissions must be checked before this call.
"""
from
flowspec.models
import
Route
route
=
Route
.
objects
.
get
(
pk
=
routepk
)
logger
.
info
(
"
tasks::delete_route(): initial route.status=
"
+
str
(
route
.
status
))
if
route
.
status
!=
"
INACTIVE
"
:
logger
.
info
(
"
Deactivating active route...
"
)
# call deactivate_route() directly since we are already on background (celery task)
...
...
@@ -155,8 +156,9 @@ def delete_route(routepk, **kwargs):
# Repeat due to error in deactivation
route
.
status
=
"
PENDING
"
route
.
save
()
logger
.
error
(
"
Deactivation failed, repeat the deletion process.
"
)
raise
TimeoutError
()
if
True
:
logger
.
error
(
"
Deactivation failed, repeat the deletion process.
"
)
raise
TimeoutError
()
if
route
.
status
==
"
INACTIVE
"
:
logger
.
info
(
"
Deleting inactive route...
"
)
...
...
This diff is collapsed.
Click to expand it.
flowspec/test_viewsets.py
+
3
−
3
View file @
933a85e4
...
...
@@ -303,7 +303,7 @@ class TestRoute:
response
=
api_client
.
delete
(
f
"
{
endpoint
}
"
)
print
(
"
route
"
+
str
(
route_id
)
+
"
deleted
"
)
assert
response
.
status_code
==
20
4
assert
response
.
status_code
==
20
2
try
:
Route
.
objects
.
get
(
id
=
route_id
)
...
...
@@ -367,7 +367,7 @@ class TestRouteOuter:
print
(
"
response.content
"
+
str
(
response
.
content
))
# Validate response headers and body contents, e.g. status code.
assert
response
.
status_code
==
201
or
response
.
status_code
==
20
4
assert
response
.
status_code
==
201
or
response
.
status_code
==
20
2
resp_data
=
json
.
loads
(
response
.
content
)
print
(
"
myresp_data=
"
+
str
(
resp_data
))
...
...
@@ -394,6 +394,6 @@ class TestRouteOuter:
response
=
requests
.
delete
(
endpoint
,
headers
=
fod_api_headers
)
assert
response
.
status_code
==
20
4
assert
response
.
status_code
==
20
2
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment