Closed skumarp7 closed 4 months ago
Hi @monusingh-1 ,
Yes, the current behaviour as of now is as below:
curl -Method DELETE -Uri "http://localhost:9201/_plugins/_replication/_autofollow?pretty" -H @{'Content-T
ype' = 'application/json'} -body '{"leader_alias":"leader", "name": "test1"}'
curl : { "error" : { "root_cause" : [ { "type" : "resource_not_found_exception", "reason" : "Metadata for leader:test1 doesn't exist" } ], "type" :
"resource_not_found_exception", "reason" : "Metadata for leader:test1 doesn't exist" }, "status" : 404 }
But if there is any replication rule already there :
a) Create a replication rule "leader:test1"
curl -Method POST -Uri "http://localhost:9201/_plugins/_replication/_autofollow?pretty" -H @{'Content-Typ
e' = 'application/json'} -body '{"leader_alias":"leader", "name": "test1", "pattern": "test1"}'
StatusCode : 200
StatusDescription : OK
Content : {
"acknowledged" : true
}
b) Delete a non existing rule (say "leader:test2"), then the deletion of that replication rule returns 200.
curl -Method DELETE -Uri "http://localhost:9201/_plugins/_replication/_autofollow?pretty" -H @{'Content-T
ype' = 'application/json'} -body '{"leader_alias":"leader", "name": "test2"}'
StatusCode : 200
StatusDescription : OK
Content : {
"acknowledged" : true
}
Description
This PR handles the exception for deletion of any non-existing replication rule.
Earlier behaviour:
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.
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.
Behaviour now:
Deletion of any non existing replication rule.
Issues Resolved
https://github.com/opensearch-project/cross-cluster-replication/issues/1370
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.