Skip to content

Commit

Permalink
Fix #185 and #186
Browse files Browse the repository at this point in the history
This corrects some small bugs and omissions.

Update Changelog

closes #185
closes #186
  • Loading branch information
untergeek committed Oct 8, 2014
1 parent 7d073b5 commit 7b2e009
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
12 changes: 10 additions & 2 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
Changelog
=========

2.0.1 (? ? ?)
-------------
2.0.2 (8 October 2014)
----------------------

**Bug fixes**

* Snapshot name not displayed in log or STDOUT #185 (untergeek)
* Variable name collision in delete_snapshot() #186 (untergeek)

2.0.1 (1 October 2014)
----------------------

**Bug fix**

Expand Down
16 changes: 10 additions & 6 deletions curator/curator.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,18 +658,22 @@ def create_snapshot(client, indices='_all', snapshot_name=None,
return True

### Delete a snapshot
def delete_snapshot(client, snapshot_name, repository=None, **kwargs):
def delete_snapshot(client, snap, **kwargs):
"""
Delete a snapshot (or comma-separated list of snapshots)
:arg client: The Elasticsearch client connection
:arg snapshot_name: The snapshot name
:arg repository: The Elasticsearch snapshot repository to use
"""
if not "repository" in kwargs:
logger.error("Repository information omitted. Must specify repository to delete snapshot.")
else:
repository = kwargs["repository"]
try:
client.snapshot.delete(repository=repository, snapshot=snapshot_name)
client.snapshot.delete(repository=repository, snapshot=snap)
except elasticsearch.RequestError as e:
logger.error("Unable to delete snapshot {0}. Error: {1} Check logs for more information.".format(snapshot_name, e))
logger.error("Unable to delete snapshot {0}. Error: {1} Check logs for more information.".format(snap, e))

# Operations typically used by the curator_script, directly or indirectly
## Loop through a list of objects and perform the indicated operation
Expand Down Expand Up @@ -1085,7 +1089,7 @@ def snapshot(client, dry_run=False, **kwargs):
logger.info(kwargs['prepend'] + "Deleting specified snapshots...")
kwargs['older_than'] = kwargs['delete_older_than'] # Fix for delete in this case only.
snapshot_list = client.snapshot.get(repository=kwargs['repository'], snapshot="_all")['snapshots']
matching_snapshots = filter_by_timestamp(object_list=snapshot_list, object_type='snapshot', **kwargs)
matching_snapshots = list(filter_by_timestamp(object_list=snapshot_list, object_type='snapshot', **kwargs))
_op_loop(client, matching_snapshots, op=delete_snapshot, dry_run=dry_run, **kwargs)
logger.info(kwargs['prepend'] + 'Specified snapshots deleted.')
else:
Expand All @@ -1095,13 +1099,13 @@ def snapshot(client, dry_run=False, **kwargs):
if most_recent:
matching_indices = index_list[-kwargs['most_recent']:]
elif older_than:
matching_indices = filter_by_timestamp(object_list=index_list, **kwargs)
matching_indices = list(matching_indices)
matching_indices = list(filter_by_timestamp(object_list=index_list, **kwargs))
else:
logger.error(kwargs['prepend'] + 'Missing argument: Must provide one of: older_than, most_recent, all_indices, delete_older_than')
return
else:
matching_indices = '_all'
logger.info(kwargs['prepend'] + 'Snapshot will capture indices: {0}'.format(', '.join(matching_indices)))
if not dry_run:
# Default `create_snapshot` behavior is to snap `_all` into a
# snapshot named `snapshot_name` or `curator-%Y-%m-%dT%H:%M:%S`
Expand Down

0 comments on commit 7b2e009

Please sign in to comment.