hashicorp / consul

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
https://www.consul.io
Other
28.05k stars 4.4k forks source link

consul config delete is ambiguous #18166

Open nvanthao opened 11 months ago

nvanthao commented 11 months ago

Overview of the Issue

The consul config delete command deletes the configuration entry specified by the kind and name. However, it always reports success, even if the entry does not exist.

Reproduction Steps

Steps to reproduce this issue, eg:

  1. Run consul agent -dev
  2. Run consul config delete with any Kind and Name
  3. View message
~ consul config delete -kind service-defaults -name foo
Config entry deleted: service-defaults/foo

~ consul config delete -kind service-resolver -name bar
Config entry deleted: service-resolver/bar

~ curl -v --request DELETE 0:8500/v1/config/service-resolver/foobar
*   Trying 0.0.0.0:8500...
* Connected to 0.0.0.0 (127.0.0.1) port 8500 (#0)
> DELETE /v1/config/service-resolver/foobar HTTP/1.1
> Host: 0.0.0.0:8500
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Vary: Accept-Encoding
< X-Consul-Default-Acl-Policy: allow
< Date: Tue, 18 Jul 2023 12:02:36 GMT
< Content-Length: 3
<
{}

Consul info for both Client and Server

Consul 1.16.0

I believe the fix is straightforward and would like to contribute a PR.

https://github.com/hashicorp/consul/blob/62005369b54c63ccd7842c001de740ff3795d02c/agent/consul/config_endpoint.go#L135-L150

huikang commented 11 months ago

@nvanthao, thanks for reporting. PR is very welcome to fix the issue.

nvanthao commented 11 months ago

Many thanks @huikang I have linked the PR