Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Cross cluster replication API doesn't fail if multiple pattern is configured in same rule. #1034

Open
chaitrahegde115 opened this issue Jul 5, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@chaitrahegde115
Copy link

chaitrahegde115 commented Jul 5, 2023

What is the bug?
Cross cluster replication API doesn't fail if multiple pattern is configured in same rule.

How can one reproduce the bug?
I am using Opensearch 2.7.0 version. I created a new replication rule which contains multiple patterns to be replicated like below. But curl API doesn't throw any error and it doesn't replicate any data from leader to follower.
Steps:

  1. Create a replication rule with multiple index pattern
curl -XPOST -k -H 'Content-Type: application/json' -u 'ccr-user:ccruser' 'https://localhost:9200/_plugins/_replication/_autofollow?pretty' -d '
{
   "leader_alias" : "leader-cluster",
   "name": "replication-rules",
   "pattern": "log*, test*",
   "use_roles":{
      "leader_cluster_role": "cross_cluster_replication_leader_full_access",
      "follower_cluster_role": "cross_cluster_replication_follower_full_access"
   }
}'
{
  "acknowledged" : true
}
  1. If I check /autofollow_stats it lists both indexpatterns. But it doesn't replicate any data.
curl -XGET -u 'admin:admin' -k 'https://localhost:9200/_plugins/_replication/autofollow_stats' {
  "num_success_start_replication" : 0,
  "num_failed_start_replication" : 0,
  "num_failed_leader_calls" : 0,
  "failed_indices" : [ ],
  "autofollow_stats" : [
    {
      "name" : "replication-rules",
      "pattern" : "log*, test*",
      "num_success_start_replication" : 0,
      "num_failed_start_replication" : 0,
      "num_failed_leader_calls" : 0,
      "failed_indices" : [ ],
      "last_execution_time" : 1688106988643
    }
  ]
}

What is the expected behavior?
Atleast curl command should fail if multiple index pattern replication can't be configured and not supported.

What is your host/environment?

  • OS: k8s 1.21(Linux)
  • Version 1.21
  • Plugins: cross cluster replication
@chaitrahegde115 chaitrahegde115 added bug Something isn't working untriaged labels Jul 5, 2023
@monusingh-1
Copy link
Collaborator

Hi @chaitrahegde115, you can only have 1 autofollow pattern in a autofollow rule.
To enable autofollow on 2 patterns, create two autofollow rules like below:

curl -XPOST -k -H 'Content-Type: application/json' -u 'ccr-user:ccruser' 'https://localhost:9200/_plugins/_replication/_autofollow?pretty' -d '
{
   "leader_alias" : "leader-cluster",
   "name": "replication-log",
   "pattern": "log*",
   "use_roles":{
      "leader_cluster_role": "cross_cluster_replication_leader_full_access",
      "follower_cluster_role": "cross_cluster_replication_follower_full_access"
   }
}'


curl -XPOST -k -H 'Content-Type: application/json' -u 'ccr-user:ccruser' 'https://localhost:9200/_plugins/_replication/_autofollow?pretty' -d '
{
   "leader_alias" : "leader-cluster",
   "name": "replication-test",
   "pattern": "test*",
   "use_roles":{
      "leader_cluster_role": "cross_cluster_replication_leader_full_access",
      "follower_cluster_role": "cross_cluster_replication_follower_full_access"
   }
}'

In the case where you put "pattern": "log*, test*", the string will be considered as a single autofollow pattern, since there is space " " in the pattern and Opensearch index name cannot have " ", the replication rule will not match any index.

@chaitrahegde115
Copy link
Author

Hi,
Creating multiple replication rule is fine. But curl command should not give "acknowledged" : true as this would be misleading. If multiple patterns are configured and since it's not supported, the curl output should be some error.

@skumarp7
Copy link
Contributor

Hi,

Request feedback from maintainers on whether the requested change is valid/desirable from the plugin's design, and if yes, I would like to contribute for this.

@skumarp7
Copy link
Contributor

skumarp7 commented Feb 2, 2024

Hi ,

Since there is no validation done to check if the pattern configured intthe autofollow API is a valid indexpattern, I would like to raise a PR to add validations to check if it's a valid indexpattern thats configured in the autofollow pattern by checking for these invalid characters [ "\" , "/" , "?" , '"' , "<", ">", "|", " ", "," , "#" , ":" ]. Request feedback from maintainers on whether the changes are valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants