Skip to content

Commit

Permalink
Merge pull request #1022 from untergeek/fix/1021
Browse files Browse the repository at this point in the history
Address API change in ES 5.5.0
  • Loading branch information
untergeek committed Aug 2, 2017
2 parents 5a986c8 + 5cd3a82 commit b9586a3
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ env:
- ES_VERSION=5.1.2
- ES_VERSION=5.2.2
- ES_VERSION=5.3.3
- ES_VERSION=5.4.1
- ES_VERSION=5.4.3
- ES_VERSION=5.5.1

os: linux

Expand Down
17 changes: 16 additions & 1 deletion curator/indexlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,22 @@ def filter_none(self):

def filter_by_alias(self, aliases=None, exclude=False):
"""
Match indices which are associated with the alias identified by `name`
Match indices which are associated with the alias or list of aliases
identified by `aliases`.
An update to Elasticsearch 5.5.0 changes the behavior of this from
previous 5.x versions:
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking-changes-5.5.html#breaking_55_rest_changes
What this means is that indices must appear in all aliases in list
`aliases` or a 404 error will result, leading to no indices being
matched. In older versions, if the index was associated with even one
of the aliases in `aliases`, it would result in a match.
It is unknown if this behavior affects anyone. At the time this was
written, no users have been bit by this. The code could be adapted
to manually loop if the previous behavior is desired. But if no users
complain, this will become the accepted/expected behavior.
:arg aliases: A list of alias names.
:type aliases: list
Expand Down
12 changes: 12 additions & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ Changelog
5.1.2 (? ? ?)
-------------

**Errata**

* An update to Elasticsearch 5.5.0 changes the behavior of
``filter_by_aliases``, differing from previous 5.x versions.

If a list of aliases is provided, indices must appear in _all_ listed
aliases or a 404 error will result, leading to no indices being matched.
In older versions, if the index was associated with even one of the
aliases in aliases, it would result in a match.

Tests and documentation have been updated to address these changes.

**Bug Fixes**

* Support date math in reindex operations better. It did work previously,
Expand Down
3 changes: 2 additions & 1 deletion docs/asciidoc/filter_elements.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ You can use <<envvars,environment variables>> in your configuration files.
[[fe_aliases]]
== aliases

include::inc_filter_by_aliases.asciidoc[]

NOTE: This setting is used only when using the <<filtertype_alias,alias>>
filter.

Expand Down Expand Up @@ -80,7 +82,6 @@ There is no default value. This setting must be set by the user or an
exception will be raised, and execution will halt.



[[fe_allocation_type]]
== allocation_type

Expand Down
2 changes: 2 additions & 0 deletions docs/asciidoc/filters.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ indices based on whether they are associated with the given
remain in, or be removed from the actionable list based on the value of
<<fe_exclude,exclude>>.

include::inc_filter_by_aliases.asciidoc[]

=== Required settings

* <<fe_aliases,aliases>>
Expand Down
2 changes: 1 addition & 1 deletion docs/asciidoc/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:curator_major: 5
:curator_doc_tree: 5.1
:es_py_version: 5.4.0
:es_doc_tree: 5.4
:es_doc_tree: 5.5
:pybuild_ver: 3.6.1
:ref: http://www.elastic.co/guide/en/elasticsearch/reference/{es_doc_tree}

Expand Down
6 changes: 5 additions & 1 deletion test/integration/test_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def test_filter_by_array_of_aliases(self):
self.args['actionfile']
],
)
self.assertEquals(1, len(curator.get_indices(self.client)))
ver = curator.get_version(self.client)
if ver >= (5,5,0):
self.assertEquals(2, len(curator.get_indices(self.client)))
else:
self.assertEquals(1, len(curator.get_indices(self.client)))
def test_filter_by_alias_bad_aliases(self):
alias = 'testalias'
self.write_config(
Expand Down

0 comments on commit b9586a3

Please sign in to comment.