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

feat: support force delete resource #9810

Merged
merged 2 commits into from
Jul 14, 2023

Conversation

lingsamuel
Copy link
Member

@lingsamuel lingsamuel commented Jul 11, 2023

Description

Support to force delete resources with header X-Force-Delete: true.

Fixes #9795

example:

❯ curl http://127.0.0.1:9180/apisix/admin/upstreams/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{
    "nodes": {
        "127.0.0.1:8080": 1
    },
    "type": "roundrobin"
}'
❯ curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{
    "uri": "/*",
    "upstream_id": 1
}'
{"value":{"priority":0,"upstream_id":1,"uri":"/*","create_time":1689038794,"id":"1","status":1,"update_time":1689038916},"key":"/apisix/routes/1"}

❯ curl http://127.0.0.1:9180/apisix/admin/upstreams/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X DELETE
{"error_msg":"can not delete this upstream, route [1] is still using it now"}
❯ curl http://127.0.0.1:9180/apisix/admin/upstreams/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X DELETE -H 'X-Force-Delete: anyvalue'
{"error_msg":"can not delete this upstream, route [1] is still using it now"}
❯ curl http://127.0.0.1:9180/apisix/admin/upstreams/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X DELETE -H 'X-Force-Delete: true'
{"deleted":"1","key":"/apisix/upstreams/1"}

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

Signed-off-by: Ling Samuel (WSL) <lingsamuelgrace@gmail.com>
@kingluo
Copy link
Contributor

kingluo commented Jul 14, 2023

URL arg is better. The admin API did not use arguments that much, so it's ok to insist on this simple way.

Signed-off-by: Ling Samuel (WSL) <lingsamuelgrace@gmail.com>
@monkeyDluffy6017 monkeyDluffy6017 merged commit 3e3b410 into apache:master Jul 14, 2023
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proposal: support force delete resource without reference check
4 participants