Skip to content

feat: support force delete resource#9810

Merged
juststillthinking merged 2 commits into
apache:masterfrom
lingsamuel:force-delete
Jul 14, 2023
Merged

feat: support force delete resource#9810
juststillthinking merged 2 commits into
apache:masterfrom
lingsamuel:force-delete

Conversation

@lingsamuel

@lingsamuel lingsamuel commented Jul 11, 2023

Copy link
Copy Markdown
Member

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) <[email protected]>
Comment thread docs/en/latest/admin-api.md Outdated
@kingluo

kingluo commented Jul 14, 2023

Copy link
Copy Markdown
Contributor

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) <[email protected]>
@juststillthinking
juststillthinking merged commit 3e3b410 into apache:master Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal: support force delete resource without reference check

4 participants