Skip to content

Commit

Permalink
Merge pull request #1316 from untergeek/fix/1313
Browse files Browse the repository at this point in the history
Show rollover results
  • Loading branch information
untergeek committed Nov 15, 2018
2 parents c20a654 + 1bb48cd commit 9028197
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.egg
localhost.es
oneliners.py
*.py[co]
*.zip
*~
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
- ES_VERSION=6.2.4
- ES_VERSION=6.3.2
- ES_VERSION=6.4.3
- ES_VERSION=6.5.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 +1 @@
__version__ = '5.6.0'
__version__ = '5.7.0.dev0'
35 changes: 31 additions & 4 deletions curator/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,35 @@ def body(self):
retval['settings'] = self.settings
return retval

def log_result(self, result):
"""
Log the results based on whether the index rolled over or not
"""
dryrun_string = ''
if result['dry_run']:
dryrun_string = 'DRY-RUN: '
self.loggit.debug('{0}Result: {1}'.format(dryrun_string, result))
rollover_string = '{0}Old index {1} rolled over to new index {2}'.format(
dryrun_string,
result['old_index'],
result['new_index']
)
# Success is determined by at one condition being True
success = False
for k in list(result['conditions'].keys()):
if result['conditions'][k]:
success = True
if result['dry_run'] and success: # log "successful" dry-run
self.loggit.info(rollover_string)
elif result['rolled_over']:
self.loggit.info(rollover_string)
else:
self.loggit.info(
'{0}Rollover conditions not met. Index {0} not rolled over.'.format(
dryrun_string,
result['old_index'])
)

def doit(self, dry_run=False):
"""
This exists solely to prevent having to have duplicate code in both
Expand All @@ -931,17 +960,15 @@ def do_dry_run(self):
Log what the output would be, but take no action.
"""
self.loggit.info('DRY-RUN MODE. No changes will be made.')
result = self.doit(dry_run=True)
self.loggit.info('DRY-RUN: rollover: {0} result: '
'{1}'.format(self.name, result))
self.log_result(self.doit(dry_run=True))

def do_action(self):
"""
Rollover the index referenced by alias `name`
"""
self.loggit.info('Performing index rollover')
try:
self.doit()
self.log_result(self.doit())
except Exception as e:
utils.report_failure(e)

Expand Down
12 changes: 12 additions & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
Changelog
=========

5.7.0 (? ? ?)
-------------

**New**

* TravisCI testing for Elasticsearch 6.5.0 (untergeek)

**Bug Fixes**

* Report rollover results in both dry-run and regular runs. Requested
in #1313 (untergeek)

5.6.0 (13 November 2018)
------------------------

Expand Down
6 changes: 3 additions & 3 deletions docs/asciidoc/index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
:curator_version: 5.6.0
:curator_version: 5.7.0.dev0
:curator_major: 5
:curator_doc_tree: 5.6
:curator_doc_tree: 5.7
:es_py_version: 6.3.1
:es_doc_tree: 6.5
:pybuild_ver: 3.6.6
:pybuild_ver: 3.6.7
:ref: http://www.elastic.co/guide/en/elasticsearch/reference/{es_doc_tree}

[[curator-reference]]
Expand Down

0 comments on commit 9028197

Please sign in to comment.