Search code examples
curlopensearch

Delete settings from Opensearch cluster via API


I have an Opensearch cluster with cross cluster search setted up with official guide (https://opensearch.org/docs/latest/security/access-control/cross-cluster-search/). Now I need to disable it. I don't have access to nodes or underlying VMs, only curl and API.

For now my cluster settings looks like that:

# Setting up cross-cluster search
curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '
{
  "persistent": {
    "cluster.remote": {
      "cross-cluster-name": {
        "seeds": ["cross-cluster-node-01:9300", "cross-cluster-node-02:9300", "cross-cluster-node-03:9300", "cross-cluster-node-04:9300" ]
      }
    }
  }
}'

# Get cluster settings
curl -XGET -k -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings?pretty'

# output:
{
  "persistent" : {
    "cluster" : {
      "remote" : {
        "cross-cluster-name" : {
          "seeds" : [
            "cross-cluster-node-01:9300",
            "cross-cluster-node-02:9300",
            "cross-cluster-node-03:9300",
            "cross-cluster-node-04:9300"
          ]
        }
      }
    }
  },
  "transient" : { }
}

How can I delete those settings to disable cross cluster search?

What I tried:

# tried to delete settings alltogether
curl -XDELETE -k -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings'
# output:
{"error":"Incorrect HTTP method for uri [/_cluster/settings] and method [DELETE], allowed: [PUT, GET]","status":405}%  

# tried to replace with empty setting 
curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '
{ "persistent": { "cluster" : { "remote" : {} } }, "transient" : { } }'
# output:
{"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: no settings to update;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: no settings to update;"},"status":400}%           

Update: Thanks to Martin P. answer I was able to found the right solution. To remove remote cluster from settings, it seeds must be set to null:

curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '
{
  "persistent": {
    "cluster.remote": {
      "cross-cluster-name": {
        "seeds": null
      }
    }
  }
}'

found an answer here: https://discuss.elastic.co/t/cross-cluster-search-questions/222379/7 and there is more documentation on module here: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/modules-cross-cluster-search.html


Solution

  • Try setting a null value. That's the way to remove a previous done setting.

    curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '{ "persistent": { "cluster.remote": null  }}'