opensearch-project / cross-cluster-replication

Synchronize your data across multiple clusters for lower latencies and higher availability
https://opensearch.org/docs/latest/replication-plugin/index/
Apache License 2.0
47 stars 57 forks source link

[BUG] Deletion of non-existing autofollow replication rule is successful with "Acknowledge: true" response #1370

Closed skumarp7 closed 4 months ago

skumarp7 commented 4 months ago

Hi,

Deletion of any non-existing autofollow replication rule gives "Acknowledge: true" response.

How can one reproduce the bug?

If any replication rule is tried to be deleted before creation of the first replication rule, it throws ResourceNotFoundException.

ex:

Directly delete the autofollow replication rule before creation of any autofollow rule.

curl -Method DELETE -Uri "http://localhost:9201/_plugins/_replication/_autofollow?pretty"  -H @{'Content-Type' = 'application/json'} -body '{"leader_alias":"leader", "name": "dummy"}'

curl : { "error" : { "root_cause" : [ { "type" : "resource_not_found_exception", "reason" : "Metadata for leader_sanjay:asd doesn't exist" } ],     
"type" : "resource_not_found_exception", "reason" : "Metadata for leader_sanjay:asd doesn't exist" }, "status" : 404 } 

Now, create a new replication rule 'A' and try to delete replication rule 'B'. Here we could see that there is a successful response in deleting a non-existing replication rule.

curl -Method POST -Uri "http://localhost:9201/_plugins/_replication/_autofollow?pretty"  -H @{'Content-Typ
e' = 'application/json'} -body '{"leader_alias":"leader", "name": "test", "pattern": "test-*"}'                   

StatusCode        : 200
StatusDescription : OK
Content           : {
                      "acknowledged" : true
                    }
curl -Method DELETE -Uri "http://localhost:9201/_plugins/_replication/_autofollow?pretty"  -H @{'Content-T
ype' = 'application/json'} -body '{"leader_alias":"leader", "name": "dummy"}'                             

StatusCode        : 200
StatusDescription : OK
Content           : {
                      "acknowledged" : true
                    }

What is the expected behavior? Deletion of any non-existing replication should throw ResourceNotFoundException at the API level interaction.

skumarp7 commented 4 months ago

Closing this issue as the PR got merged.