Skip to content

Commit

Permalink
Fix alias race condition reported
Browse files Browse the repository at this point in the history
This should address the problem reported.
  • Loading branch information
untergeek committed Dec 6, 2017
1 parent f6682dc commit e7ceae9
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ env:
- ES_VERSION=5.3.3
- ES_VERSION=5.4.3
- ES_VERSION=5.5.2
- ES_VERSION=5.6.4
- ES_VERSION=6.0.0-rc2
- ES_VERSION=5.6.5
- ES_VERSION=6.0.0

os: linux

Expand Down
2 changes: 1 addition & 1 deletion curator/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '5.4.0'
__version__ = '5.4.1'

12 changes: 6 additions & 6 deletions curator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ def process_action(client, config, **kwargs):
# Special behavior for this action, as it has 2 index lists
logger.debug('Running "{0}" action'.format(action.upper()))
action_obj = action_class(**mykwargs)
if 'add' in config:
logger.debug('Adding indices to alias "{0}"'.format(opts['name']))
adds = IndexList(client)
adds.iterate_filters(config['add'])
action_obj.add(adds, warn_if_no_indices=opts['warn_if_no_indices'])
removes = IndexList(client)
adds = IndexList(client)
if 'remove' in config:
logger.debug(
'Removing indices from alias "{0}"'.format(opts['name']))
removes = IndexList(client)
removes.iterate_filters(config['remove'])
action_obj.remove(
removes, warn_if_no_indices= opts['warn_if_no_indices'])
if 'add' in config:
logger.debug('Adding indices to alias "{0}"'.format(opts['name']))
adds.iterate_filters(config['add'])
action_obj.add(adds, warn_if_no_indices=opts['warn_if_no_indices'])
elif action in [ 'cluster_routing', 'create_index', 'rollover']:
action_obj = action_class(client, **mykwargs)
elif action == 'delete_snapshots' or action == 'restore':
Expand Down
26 changes: 26 additions & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@
Changelog
=========

5.4.1 (? ? ?)
-------------

**Bug Fixes**

* Improve Dockerfile to build from source and produce slimmer image
#1111 (mikn)
* Fix ``filter_kibana`` to correctly use ``exclude`` argument
#1116 (cjuroz)
* Fix `ssl_no_validate` behavior within AWS ES #1118 (igalarzab)
* Improve command-line exception management #1119 (4383)
* Make ``alias`` action always process ``remove`` before ``add``
to prevent undesired alias removals. #1120 (untergeek)

**General**

* Bump ES versions in Travis CI

**Documentation**

* Remove ``unit_count`` parameter doc for parameter that no longer
exists #1107 (dashford)
* Add missing ``exclude: True`` in ``timestring`` docs #1117 (GregMefford)



5.4.0 (13 November 2017)
------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/asciidoc/index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:curator_version: 5.4.0
:curator_version: 5.4.1
:curator_major: 5
:curator_doc_tree: 5.4
:es_py_version: 5.4.0
:es_py_version: 5.4.1
:es_doc_tree: 5.6
:pybuild_ver: 3.6.3
:ref: http://www.elastic.co/guide/en/elasticsearch/reference/{es_doc_tree}
Expand Down
40 changes: 40 additions & 0 deletions test/integration/test_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,43 @@ def test_extra_options(self):
],
)
self.assertEqual(-1, result.exit_code)
def test_add_and_remove_sorted(self):
alias = 'testalias'
alias_add_remove = (
'---\n'
'actions:\n'
' 1:\n'
' description: "Add/remove specified indices from designated alias"\n'
' action: alias\n'
' options:\n'
' name: {0}\n'
' continue_if_exception: False\n'
' disable_action: False\n'
' add:\n'
' filters:\n'
' - filtertype: none\n'
' remove:\n'
' filters:\n'
' - filtertype: pattern\n'
' kind: prefix\n'
' value: my\n'

)
self.write_config(
self.args['configfile'], testvars.client_config.format(host, port))
self.write_config(self.args['actionfile'], alias_add_remove.format(alias))
self.create_index('my_index')
self.create_index('dummy')
self.client.indices.put_alias(index='my_index', name=alias)
test = clicktest.CliRunner()
result = test.invoke(
curator.cli,
[
'--config', self.args['configfile'],
self.args['actionfile']
],
)
self.assertEqual(
{'dummy': {'aliases': {alias: {}}}, 'my_index': {'aliases': {alias: {}}}},
self.client.indices.get_alias(name=alias)
)

0 comments on commit e7ceae9

Please sign in to comment.