mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 04:58:50 +00:00
f5b2dfd052
Fixes a bug where alias creation would allow `null` for index name, which thereby applied the alias to _all_ indices. This patch makes the validator throw an exception if the index is null. ```bash POST /_aliases { "actions": [ { "add": { "alias": "empty-alias", "index": null } } ] } ``` ```json { "error": "ActionRequestValidationException[Validation Failed: 1: Alias action [add]: [index] may not be null;]", "status": 400 } ``` The reason this bug wasn't caught by the existing tests is because the old test for nullness only validated against a cluster which had zero indices. The null index is translated into "_all", and since there are no indices, this fails because the index doesn't exist. So the test passes. However, as soon as you add an index, "_all" resolves and you get the situation described in the original bug report: null index is accepted by the alias, resolves to "_all" and gets applied to everything. The REST tests, otoh, explicitly tested this bug as a real feature and therefore passed. The REST tests were modified to change this behavior. Fixes #7863
225 lines
4.5 KiB
YAML
225 lines
4.5 KiB
YAML
---
|
|
setup:
|
|
|
|
- do:
|
|
indices.create:
|
|
index: test_index1
|
|
|
|
- do:
|
|
indices.create:
|
|
index: test_index2
|
|
|
|
- do:
|
|
indices.create:
|
|
index: foo
|
|
|
|
- do:
|
|
indices.put_alias:
|
|
name: alias1
|
|
index:
|
|
- test_index1
|
|
- foo
|
|
body:
|
|
routing: "routing value"
|
|
- do:
|
|
indices.put_alias:
|
|
name: alias2
|
|
index:
|
|
- test_index2
|
|
- foo
|
|
body:
|
|
routing: "routing value"
|
|
|
|
---
|
|
"check setup":
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias1
|
|
|
|
- match: {test_index1.aliases.alias1.search_routing: "routing value"}
|
|
- match: {foo.aliases.alias1.search_routing: "routing value"}
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias2
|
|
|
|
- match: {test_index2.aliases.alias2.search_routing: "routing value"}
|
|
- match: {foo.aliases.alias2.search_routing: "routing value"}
|
|
|
|
---
|
|
"check delete with _all index":
|
|
- do:
|
|
indices.delete_alias:
|
|
index: _all
|
|
name: alias1
|
|
|
|
- do:
|
|
catch: missing
|
|
indices.get_alias:
|
|
name: alias1
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias2
|
|
|
|
- match: {test_index2.aliases.alias2.search_routing: "routing value"}
|
|
- match: {foo.aliases.alias2.search_routing: "routing value"}
|
|
|
|
---
|
|
"check delete with * index":
|
|
- do:
|
|
indices.delete_alias:
|
|
index: "*"
|
|
name: alias1
|
|
|
|
- do:
|
|
catch: missing
|
|
indices.get_alias:
|
|
name: alias1
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias2
|
|
|
|
- match: {test_index2.aliases.alias2.search_routing: "routing value"}
|
|
- match: {foo.aliases.alias2.search_routing: "routing value"}
|
|
|
|
---
|
|
"check delete with index list":
|
|
- do:
|
|
indices.delete_alias:
|
|
index: "test_index1,test_index2"
|
|
name: alias1
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias1
|
|
|
|
- match: {foo.aliases.alias1.search_routing: "routing value"}
|
|
- is_false: test_index1
|
|
- is_false: test_index2
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias2
|
|
|
|
- match: {test_index2.aliases.alias2.search_routing: "routing value"}
|
|
- match: {foo.aliases.alias2.search_routing: "routing value"}
|
|
|
|
---
|
|
"check delete with prefix* index":
|
|
- do:
|
|
indices.delete_alias:
|
|
index: "test_*"
|
|
name: alias1
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias1
|
|
|
|
- match: {foo.aliases.alias1.search_routing: "routing value"}
|
|
- is_false: test_index1
|
|
- is_false: test_index2
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias2
|
|
|
|
- match: {test_index2.aliases.alias2.search_routing: "routing value"}
|
|
- match: {foo.aliases.alias2.search_routing: "routing value"}
|
|
|
|
|
|
---
|
|
"check delete with index list and * aliases":
|
|
- do:
|
|
indices.delete_alias:
|
|
index: "test_index1,test_index2"
|
|
name: "*"
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias1
|
|
|
|
- match: {foo.aliases.alias1.search_routing: "routing value"}
|
|
- is_false: test_index1
|
|
- is_false: test_index2
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias2
|
|
|
|
- match: {foo.aliases.alias2.search_routing: "routing value"}
|
|
- is_false: test_index1
|
|
- is_false: test_index2
|
|
|
|
---
|
|
"check delete with index list and _all aliases":
|
|
- do:
|
|
indices.delete_alias:
|
|
index: "test_index1,test_index2"
|
|
name: _all
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias1
|
|
|
|
- match: {foo.aliases.alias1.search_routing: "routing value"}
|
|
- is_false: test_index1
|
|
- is_false: test_index2
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias2
|
|
|
|
- match: {foo.aliases.alias2.search_routing: "routing value"}
|
|
- is_false: test_index1
|
|
- is_false: test_index2
|
|
|
|
---
|
|
"check delete with index list and wildcard aliases":
|
|
- do:
|
|
indices.delete_alias:
|
|
index: "test_index1,test_index2"
|
|
name: "*1"
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias1
|
|
|
|
- match: {foo.aliases.alias1.search_routing: "routing value"}
|
|
- is_false: test_index1
|
|
- is_false: test_index2
|
|
|
|
- do:
|
|
indices.get_alias:
|
|
name: alias2
|
|
|
|
- match: {test_index2.aliases.alias2.search_routing: "routing value"}
|
|
- match: {foo.aliases.alias2.search_routing: "routing value"}
|
|
|
|
---
|
|
"check 404 on no matching alias":
|
|
- do:
|
|
catch: missing
|
|
indices.delete_alias:
|
|
index: "*"
|
|
name: "non_existent"
|
|
|
|
- do:
|
|
catch: missing
|
|
indices.delete_alias:
|
|
index: "non_existent"
|
|
name: "alias1"
|
|
|
|
|
|
---
|
|
"check delete with blank index and blank alias":
|
|
- do:
|
|
catch: param
|
|
indices.delete_alias:
|
|
name: "alias1"
|
|
|
|
- do:
|
|
catch: param
|
|
indices.delete_alias:
|
|
index: "test_index1"
|
|
|