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] Add support to clear archived index settings #9019

Merged
merged 16 commits into from
Aug 22, 2023

Conversation

ankitkala
Copy link
Member

@ankitkala ankitkala commented Aug 1, 2023

Description

Whenever OS encounters a unknown setting, it moves the setting to archived. You can't modify any setting unless the archived setting has been cleared up. For index settings, currently if a setting moves to archived setting, it can't be cleared up.
This PR addresses this bug allowing users to clear the index level archived settings on closed indices.
Changes done:

  • All index settings are expected to start with index. and during any operation on the settings we normalize the user provided input with this prefix which doesn't work for archived settings. As archived.index.foo becomes index.archived.index.foo which doesn't exist. We now skip this normalisation for archived settings.
  • Skip the validation for presence of archived settings during setting update (from MetadataUpdateSettingsService)
  • We've a logic to determine if the new settings(after update) is same as the latest version. if same, it doesn't update the cluster service. Currently this logic doesn't accounts for archived settings. Added additional check for this.

Related Issues

#2803

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

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.

Testing done

To Reproduce

  • Tested by creating a snapshot after introducing a dummy index setting and using that to restore on a test cluster locally where the setting is not present.
ankikala@bcd074645674 OpenSearch % curl -k -X PUT "http://localhost:9200/_snapshot/my_fs_backup" -H 'Content-Type: application/json' -d'
{
  "type": "fs",
  "settings": {
    "location": "/Users/ankikala/Desktop/test-repo"
  }
}'


{"acknowledged":true}%                                                                                                                                    ankikala@bcd074645674 ankikala@bcd074645674 OpenSearch % curl -k -X POST "http://localhost:9200/_snapshot/my_fs_backup/my_snapshot/_restore" -H 'Content-Type: application/json' -d'
{
  "indices": "test_index"
}'                                   
{"accepted":true}%                                                                                                                                        ankikala@bcd074645674 
OpenSearch % curl localhost:9200/_cat/recovery
test_index 0 242ms snapshot done n/a n/a 127.0.0.1 runTask-0 my_fs_backup my_snapshot 4 4 100.0% 4 5084 5084 100.0% 5084 0 0 100.0%
ankikala@bcd074645674 OpenSearch % curl localhost:9200/_cat/indices  
green open test_index k8Nt2qc0TW6kJdeeXjvpjQ 1 0 1 0 4.9kb 4.9kb
ankikala@bcd074645674 OpenSearch % curl "localhost:9200/test_index/_settings?pretty"
{
  "test_index" : {
    "settings" : {
      "archived" : {
        "index" : {
          "dummy_setting" : "foobar"
        }
      },
      "index" : {
        "replication" : {
          "type" : "DOCUMENT"
        },
        "number_of_shards" : "1",
        "provided_name" : "test_index",
        "creation_date" : "1690774033942",
        "number_of_replicas" : "0",
        "uuid" : "k8Nt2qc0TW6kJdeeXjvpjQ",
        "version" : {
          "created" : "137217827"
        }
      }
    }
  }
}
ankikala@bcd074645674 OpenSearch % curl -XPUT "localhost:9200/test_index/_settings?pretty" -H 'Content-Type: application/json' -d '{"archived.*" : null}'
ankikala@bcd074645674 OpenSearch % curl -XPUT "localhost:9200/test_index/_settings" -H 'Content-Type: application/json' -d '{"archived.*" : null}'
{"acknowledged":true}%                                                                                                                                    ankikala@bcd074645674 OpenSearch % curl "localhost:9200/test_index/_settings?pretty"                                                              
{
  "test_index" : {
    "settings" : {
      "archived" : {
        "index" : {
          "dummy_setting" : "foobar"
        }
      },
      "index" : {
        "replication" : {
          "type" : "DOCUMENT"
        },
        "number_of_shards" : "1",
        "provided_name" : "test_index",
        "creation_date" : "1690774033942",
        "number_of_replicas" : "0",
        "uuid" : "k8Nt2qc0TW6kJdeeXjvpjQ",
        "version" : {
          "created" : "137217827"
        }
      }
    }
  }
}
ankikala@bcd074645674 OpenSearch % curl -XPUT "localhost:9200/test_index/_settings" -H 'Content-Type: application/json' -d '{"archived.index.dummy_setting" : null}'
{"error":{"root_cause":[{"type":"settings_exception","reason":"unknown setting [index.archived.index.dummy_setting] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"}],"type":"settings_exception","reason":"unknown setting [index.archived.index.dummy_setting] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"},"status":400}% 

After Fix

Without wildcard

ankikala@bcd074645674 OpenSearch % curl -k -X PUT "http://localhost:9200/_snapshot/my_fs_backup" -H 'Content-Type: application/json' -d'
{
  "type": "fs",
  "settings": {
    "location": "/Users/ankikala/Desktop/test-repo"
  }
}'

{"acknowledged":true}%                                                                                                                                    ankikala@bcd074645674 OpenSearch % curl -k -X POST "http://localhost:9200/_snapshot/my_fs_backup/my_snapshot/_restore" -H 'Content-Type: application/json' -d'
{
  "indices": "test_index"
}'

{"accepted":true}%                                                                                                                                        ankikala@bcd074645674 OpenSearch % curl "localhost:9200/test_index/_settings?pretty"
{
  "test_index" : {
    "settings" : {
      "archived" : {
        "index" : {
          "dummy_setting" : "foobar"
        }
      },
      "index" : {
        "replication" : {
          "type" : "DOCUMENT"
        },
        "number_of_shards" : "1",
        "provided_name" : "test_index",
        "creation_date" : "1690774033942",
        "number_of_replicas" : "0",
        "uuid" : "UfYsccUMReuwTFcSRNcY4g",
        "version" : {
          "created" : "137217827"
        }
      }
    }
  }
}
ankikala@bcd074645674 OpenSearch % curl -XPUT "localhost:9200/test_index/_settings" -H 'Content-Type: application/json' -d '{"archived.index.dummy_setting" : null}'
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Can't update non dynamic settings [[archived.index.dummy_setting]] for open indices [[test_index/UfYsccUMReuwTFcSRNcY4g]]"}],"type":"illegal_argument_exception","reason":"Can't update non dynamic settings [[archived.index.dummy_setting]] for open indices [[test_index/UfYsccUMReuwTFcSRNcY4g]]"},"status":400}%                                                                                  ankikala@bcd074645674 OpenSearch % curl -XPOST "localhost:9200/test_index/_close"
{"acknowledged":true,"shards_acknowledged":true,"indices":{"test_index":{"closed":true}}}%                                                                ankikala@bcd074645674 OpenSearch % curl -XPUT "localhost:9200/test_index/_settings" -H 'Content-Type: application/json' -d '{"archived.index.dummy_setting" : null}'
{"acknowledged":true}%                                                                                                                                    ankikala@bcd074645674 OpenSearch % curl -XPOST "localhost:9200/test_index/_open"
{"acknowledged":true,"shards_acknowledged":true}%                                                                                                         ankikala@bcd074645674 OpenSearch % curl "localhost:9200/test_index/_settings?pretty"
{
  "test_index" : {
    "settings" : {
      "index" : {
        "replication" : {
          "type" : "DOCUMENT"
        },
        "number_of_shards" : "1",
        "provided_name" : "test_index",
        "creation_date" : "1690774033942",
        "number_of_replicas" : "0",
        "uuid" : "UfYsccUMReuwTFcSRNcY4g",
        "version" : {
          "created" : "137217827"
        }
      }
    }
  }
}

With wildcard

curl -k -X POST "http://localhost:9200/_snapshot/my_fs_backup/my_snapshot/_restore" -H 'Content-Type: application/json' -d'
{
  "indices": "test_index"
}'
{"accepted":true}%                                                                                                                                        ankikala@bcd074645674 OpenSearch % curl "localhost:9200/test_index/_settings?pretty"
{
  "test_index" : {
    "settings" : {
      "archived" : {
        "index" : {
          "dummy_setting" : "foobar"
        }
      },
      "index" : {
        "replication" : {
          "type" : "DOCUMENT"
        },
        "number_of_shards" : "1",
        "provided_name" : "test_index",
        "creation_date" : "1690774033942",
        "number_of_replicas" : "0",
        "uuid" : "JTMs_4ERT96zAgikaWYRsQ",
        "version" : {
          "created" : "137217827"
        }
      }
    }
  }
}
ankikala@bcd074645674 OpenSearch % curl -XPUT "localhost:9200/test_index/_settings" -H 'Content-Type: application/json' -d '{"archived.*" : null}'
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Can't update non dynamic settings [[archived.*]] for open indices [[test_index/JTMs_4ERT96zAgikaWYRsQ]]"}],"type":"illegal_argument_exception","reason":"Can't update non dynamic settings [[archived.*]] for open indices [[test_index/JTMs_4ERT96zAgikaWYRsQ]]"},"status":400}%                                                                                                                      ankikala@bcd074645674 OpenSearch % curl -XPOST "localhost:9200/test_index/_close"
{"acknowledged":true,"shards_acknowledged":true,"indices":{"test_index":{"closed":true}}}%                                                                ankikala@bcd074645674 OpenSearch % curl -XPUT "localhost:9200/test_index/_settings" -H 'Content-Type: application/json' -d '{"archived.*" : null}'
{"acknowledged":true}%                                                                                                                                    ankikala@bcd074645674 OpenSearch % curl -XPOST "localhost:9200/test_index/_open"                                                                  
{"acknowledged":true,"shards_acknowledged":true}%                                                                                                         ankikala@bcd074645674 OpenSearch % curl "localhost:9200/test_index/_settings?pretty"                                                              
{
  "test_index" : {
    "settings" : {
      "index" : {
        "replication" : {
          "type" : "DOCUMENT"
        },
        "number_of_shards" : "1",
        "provided_name" : "test_index",
        "creation_date" : "1690774033942",
        "number_of_replicas" : "0",
        "uuid" : "JTMs_4ERT96zAgikaWYRsQ",
        "version" : {
          "created" : "137217827"
        }
      }
    }
  }
}

@ankitkala ankitkala changed the title [BUG] Add support to clear archived index setting [BUG] Add support to clear archived index settings Aug 1, 2023
@ankitkala ankitkala marked this pull request as ready for review August 1, 2023 09:07
@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.cluster.routing.allocation.decider.DiskThresholdDeciderIT.testIndexCreateBlockIsRemovedWhenAnyNodesNotExceedHighWatermarkWithAutoReleaseEnabled
      1 org.opensearch.backwards.MixedClusterClientYamlTestSuiteIT.test {p0=cluster.allocation_explain/10_basic/cluster shard allocation explanation test with empty request}

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.indices.replication.SegmentReplicationIT.testDropPrimaryDuringReplication
      1 org.opensearch.backwards.MixedClusterClientYamlTestSuiteIT.test {p0=cluster.allocation_explain/10_basic/cluster shard allocation explanation test with empty request}

Copy link
Member

@shwetathareja shwetathareja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ankitkala for picking this up.

Signed-off-by: Ankit Kala <ankikala@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@ankitkala
Copy link
Member Author

Gradle check failing due to unrelated flaky tests: https://build.ci.opensearch.org/job/gradle-check/22903/
Opened one issue: #9407

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@ankitkala
Copy link
Member Author

Tracking issue for Check compatibility failure: #9409

Copy link
Member

@shwetathareja shwetathareja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment, otherwise LGTM

Signed-off-by: Ankit Kala <ankikala@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Ankit Kala <ankikala@amazon.com>
@opensearch-trigger-bot
Copy link
Contributor

Compatibility status:

Checks if related components are compatible with change 48d4087

Incompatible components

Incompatible components: [https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/asynchronous-search.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/security-analytics.git]

Skipped components

Compatible components

Compatible components: [https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/sql.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/reporting.git, https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/performance-analyzer.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git]

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@ankitkala
Copy link
Member Author

Gradle precommit failing on main: #9478

@shwetathareja shwetathareja merged commit ebdffbb into opensearch-project:main Aug 22, 2023
@shwetathareja shwetathareja added the backport 2.x Backport to 2.x branch label Aug 22, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

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

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch/backport-2.x
# Create a new branch
git switch --create backport/backport-9019-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ebdffbb2bf057096028aa3e6321be8a2ebc08ec4
# Push it to GitHub
git push --set-upstream origin backport/backport-9019-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch/backport-2.x

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

ankitkala added a commit to ankitkala/OpenSearch that referenced this pull request Aug 23, 2023
…t#9019)

* Add support to clear archived index setting

Signed-off-by: Ankit Kala <ankikala@amazon.com>
(cherry picked from commit ebdffbb)
@ankitkala ankitkala deleted the archived_setting branch August 24, 2023 03:24
austintlee pushed a commit to austintlee/OpenSearch that referenced this pull request Aug 25, 2023
…t#9019)

* Add support to clear archived index setting

Signed-off-by: Ankit Kala <ankikala@amazon.com>
shwetathareja pushed a commit that referenced this pull request Aug 25, 2023
* [BUG] Add support to clear archived index settings (#9019)

Signed-off-by: Ankit Kala <ankikala@amazon.com>
(cherry picked from commit ebdffbb)
Gaganjuneja pushed a commit to Gaganjuneja/OpenSearch that referenced this pull request Aug 28, 2023
…t#9019)

* Add support to clear archived index setting

Signed-off-by: Ankit Kala <ankikala@amazon.com>
Gaganjuneja pushed a commit to Gaganjuneja/OpenSearch that referenced this pull request Aug 28, 2023
…t#9019)

* Add support to clear archived index setting

Signed-off-by: Ankit Kala <ankikala@amazon.com>
Signed-off-by: Gagan Juneja <gjjuneja@amazon.com>
kkmr pushed a commit to kkmr/OpenSearch that referenced this pull request Aug 28, 2023
…t#9019)

* Add support to clear archived index setting

Signed-off-by: Ankit Kala <ankikala@amazon.com>
Signed-off-by: Kiran Reddy <kkreddy@amazon.com>
kaushalmahi12 pushed a commit to kaushalmahi12/OpenSearch that referenced this pull request Sep 12, 2023
…t#9019)

* Add support to clear archived index setting

Signed-off-by: Ankit Kala <ankikala@amazon.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
brusic pushed a commit to brusic/OpenSearch that referenced this pull request Sep 25, 2023
…t#9019)

* Add support to clear archived index setting

Signed-off-by: Ankit Kala <ankikala@amazon.com>
Signed-off-by: Ivan Brusic <ivan.brusic@flocksafety.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
…t#9019)

* Add support to clear archived index setting

Signed-off-by: Ankit Kala <ankikala@amazon.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch backport-failed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants