Skip to content

Commit

Permalink
Merge pull request #1075 from untergeek/fix/1058
Browse files Browse the repository at this point in the history
Add code to delete target index if shrink fails
  • Loading branch information
untergeek committed Sep 28, 2017
2 parents 8329a8a + 9d0993d commit 4e95048
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
- ES_VERSION=5.3.3
- ES_VERSION=5.4.3
- ES_VERSION=5.5.2
- ES_VERSION=5.6.2

os: linux

Expand Down
1 change: 1 addition & 0 deletions curator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ._version import __version__
from .exceptions import *
from .defaults import *
from .validators import *
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.2.0'
__version__ = '5.3.0.dev1'

16 changes: 11 additions & 5 deletions curator/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2071,11 +2071,17 @@ def do_action(self):
raise ActionError('Unable to proceed with shrink action. Cluster health is not "green"')
# Do the shrink
self.loggit.info('Shrinking index "{0}" to "{1}" with settings: {2}, wait_for_active_shards={3}'.format(idx, target, self.body, self.wait_for_active_shards))
self.client.indices.shrink(index=idx, target=target, body=self.body, wait_for_active_shards=self.wait_for_active_shards)
# Wait for it to complete
if self.wfc:
self.loggit.debug('Wait for shards to complete allocation for index: {0}'.format(target))
wait_for_it(self.client, 'shrink', wait_interval=self.wait_interval, max_wait=self.max_wait)
try:
self.client.indices.shrink(index=idx, target=target, body=self.body, wait_for_active_shards=self.wait_for_active_shards)
# Wait for it to complete
if self.wfc:
self.loggit.debug('Wait for shards to complete allocation for index: {0}'.format(target))
wait_for_it(self.client, 'shrink', wait_interval=self.wait_interval, max_wait=self.max_wait)
except Exception as e:
if self.client.indices.exists(index=target):
self.loggit.error('Deleting target index "{0}" due to failure to complete shrink'.format(target))
self.client.indices.delete(index=target)
raise ActionError('Unable to shrink index "{0}" -- Error: {1}'.format(index, e))
self.loggit.info('Index "{0}" successfully shrunk to "{1}"'.format(idx, target))
# Do post-shrink steps
# Unblock writes on index (just in case)
Expand Down
10 changes: 10 additions & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
Changelog
=========

5.3.0 (? ? ?)
-------------

**New Features**

**Bug Fixes**

* Delete the target index (if it exists) in the event that a shrink fails.
Requested in #1058 (untergeek)

5.2.0 (1 September 2017)
------------------------

Expand Down
6 changes: 3 additions & 3 deletions docs/asciidoc/index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:curator_version: 5.2.0
:curator_version: 5.3.0.dev1
:curator_major: 5
:curator_doc_tree: 5.2
:curator_doc_tree: 5.3
:es_py_version: 5.4.0
:es_doc_tree: 5.5
:es_doc_tree: 5.6
:pybuild_ver: 3.6.2
:ref: http://www.elastic.co/guide/en/elasticsearch/reference/{es_doc_tree}

Expand Down

0 comments on commit 4e95048

Please sign in to comment.