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

Handle exception for the updation of a replication rule #1405

Closed skumarp7 closed 1 month ago

skumarp7 commented 2 months ago

Description

This PR handles the exception handling for updation of a replication rule.

Earlier behavior:

First hit of the replication rule:

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

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

Second hit of the same Replication rule:

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

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

New behavior: First hit of the replication rule:

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

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

Second hit of the Replication rule:

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

curl : { "error" : { "root_cause" : [ { "type" : "resource_already_exists_exception", "reason" : "task with id {autofollow:leader:test3} already exist" } ], "type" : "exception", "reason" : "Exisiting Autofollow replication     
    rule cannot be updated", "caused_by" : { "type" : "resource_already_exists_exception", "reason" : "task with id {autofollow:leader:test3} already exist" } }, "status" : 500 }

Issues Resolved

https://github.com/opensearch-project/cross-cluster-replication/issues/1394

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.

skumarp7 commented 2 months ago

Hi @ankitkala & @monusingh-1 ,

Please provide feedback :)

skumarp7 commented 2 months ago

Hi @ankitkala @monusingh-1 and other maintainers,

I could see the integTest is failing for the below test case -

org.opensearch.replication.integ.rest.StartReplicationIT > test operations are fetched from lucene when leader is in mixed mode FAILED
    org.opensearch.client.ResponseException: method [PUT], host [http://[::1]:34485], URI [_cluster/settings], status line [HTTP/1.1 400 Bad Request]
    {"error":{"root_cause":[{"type":"settings_exception","reason":"persistent setting [migration.direction], not recognized"}],"type":"settings_exception","reason":"persistent setting [migration.direction], not recognized"},"status":400}
        at __randomizedtesting.SeedInfo.seed([1A13834D768F0352:4342CA6FD3CA47EA]:0)
        at app//org.opensearch.client.RestClient.convertResponse(RestClient.java:385)
        at app//org.opensearch.client.RestClient.performRequest(RestClient.java:355)
        at app//org.opensearch.client.RestClient.performRequest(RestClient.java:330)
        at app//org.opensearch.replication.integ.rest.StartReplicationIT.test operations are fetched from lucene when leader is in mixed mode(StartReplicationIT.kt:1287)
REPRODUCE WITH: ./gradlew ':integTest' --tests "org.opensearch.replication.integ.rest.StartReplicationIT.test operations are fetched from lucene when leader is in mixed mode" -Dtests.seed=1A13834D768F0352 -Dtests.security.manager=true -Dtests.locale=smn-FI -Dtests.timezone=US/Samoa -Druntime.java=11

I was able to find a PR which involves the exclusion of this test case in integTestRemote Task but not in integTest.

https://github.com/opensearch-project/cross-cluster-replication/pull/1379

I have for now excluded this particular test case from the integTest. Let me know if any other plan to fix this test case?

opensearch-trigger-bot[bot] commented 1 month ago

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1405-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 2da20341107bfe707487d93d271df70aed31356d
# Push it to GitHub
git push --set-upstream origin backport/backport-1405-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-1405-to-2.x.