Skip to content

Commit

Permalink
Merge branch 'master' into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
untergeek committed Dec 22, 2016
2 parents ee7e605 + 1792db1 commit 57cb667
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 75 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=2.2.2
- ES_VERSION=2.3.5
- ES_VERSION=2.4.2
- ES_VERSION=5.0.0
- ES_VERSION=5.0.2
- ES_VERSION=5.1.1

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__ = '4.2.4'
__version__ = '4.2.5'
47 changes: 19 additions & 28 deletions curator/singletons.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ def _actionator(action, action_obj, dry_run=True):
sys.exit(1)
logger.info('Singleton "{0}" action completed.'.format(action))

def _check_empty_list(list_object, ignore=False):
def _do_filters(list_object, filters, ignore=False):
logger = logging.getLogger(__name__)
logger.debug('Testing for empty list object')
logger.debug('Running filters and testing for empty list object')
try:
list_object.iterate_filters(filters)
list_object.empty_list_check()
except (NoIndices, NoSnapshots) as e:
if str(type(e)) == "<class 'curator.exceptions.NoIndices'>":
Expand Down Expand Up @@ -192,8 +193,7 @@ def allocation_singleton(
'filters': filter_schema_check(action, filter_list)
}
ilo = IndexList(client)
ilo.iterate_filters(clean_filters)
_check_empty_list(ilo, ignore_empty_list)
_do_filters(ilo, clean_filters, ignore_empty_list)
action_obj = action_class(ilo, **mykwargs)
### Do the action
_actionator(action, action_obj, dry_run=ctx.parent.params['dry_run'])
Expand Down Expand Up @@ -231,8 +231,7 @@ def close_singleton(
'filters': filter_schema_check(action, filter_list)
}
ilo = IndexList(client)
ilo.iterate_filters(clean_filters)
_check_empty_list(ilo, ignore_empty_list)
_do_filters(ilo, clean_filters, ignore_empty_list)
action_obj = action_class(ilo, **mykwargs)
### Do the action
_actionator(action, action_obj, dry_run=ctx.parent.params['dry_run'])
Expand Down Expand Up @@ -265,8 +264,7 @@ def delete_indices_singleton(ctx, ignore_empty_list, filter_list):
'filters': filter_schema_check(action, filter_list)
}
ilo = IndexList(client)
ilo.iterate_filters(clean_filters)
_check_empty_list(ilo, ignore_empty_list)
_do_filters(ilo, clean_filters, ignore_empty_list)
action_obj = action_class(ilo, **mykwargs)
### Do the action
_actionator(action, action_obj, dry_run=ctx.parent.params['dry_run'])
Expand Down Expand Up @@ -315,8 +313,7 @@ def delete_snapshots_singleton(
'filters': filter_schema_check(action, filter_list)
}
slo = SnapshotList(client, repository=repository)
slo.iterate_filters(clean_filters)
_check_empty_list(slo, ignore_empty_list)
_do_filters(slo, clean_filters, ignore_empty_list)
action_obj = action_class(slo, **mykwargs)
### Do the action
_actionator(action, action_obj, dry_run=ctx.parent.params['dry_run'])
Expand Down Expand Up @@ -347,8 +344,7 @@ def open_singleton(
'filters': filter_schema_check(action, filter_list)
}
ilo = IndexList(client)
ilo.iterate_filters(clean_filters)
_check_empty_list(ilo, ignore_empty_list)
_do_filters(ilo, clean_filters, ignore_empty_list)
action_obj = action_class(ilo)
### Do the action
_actionator(action, action_obj, dry_run=ctx.parent.params['dry_run'])
Expand Down Expand Up @@ -393,8 +389,7 @@ def forcemerge_singleton(
'filters': filter_schema_check(action, filter_list)
}
ilo = IndexList(client)
ilo.iterate_filters(clean_filters)
_check_empty_list(ilo, ignore_empty_list)
_do_filters(ilo, clean_filters, ignore_empty_list)
action_obj = action_class(ilo, **mykwargs)
### Do the action
_actionator(action, action_obj, dry_run=ctx.parent.params['dry_run'])
Expand Down Expand Up @@ -437,8 +432,7 @@ def replicas_singleton(
'filters': filter_schema_check(action, filter_list)
}
ilo = IndexList(client)
ilo.iterate_filters(clean_filters)
_check_empty_list(ilo, ignore_empty_list)
_do_filters(ilo, clean_filters, ignore_empty_list)
action_obj = action_class(ilo, **mykwargs)
### Do the action
_actionator(action, action_obj, dry_run=ctx.parent.params['dry_run'])
Expand Down Expand Up @@ -478,8 +472,8 @@ def replicas_singleton(
help='Do not raise exception if there are no actionable indices'
)
@click.option(
'--filter_list', callback=validate_filter_json,
help='JSON string representing an array of filters.', required=True
'--filter_list', callback=validate_filter_json, default='{"filtertype":"none"}',
help='JSON string representing an array of filters.'
)
@click.pass_context
def snapshot_singleton(
Expand Down Expand Up @@ -509,8 +503,7 @@ def snapshot_singleton(
'filters': filter_schema_check(action, filter_list)
}
ilo = IndexList(client)
ilo.iterate_filters(clean_filters)
_check_empty_list(ilo, ignore_empty_list)
_do_filters(ilo, clean_filters, ignore_empty_list)
action_obj = action_class(ilo, **mykwargs)
### Do the action
_actionator(action, action_obj, dry_run=ctx.parent.params['dry_run'])
Expand All @@ -525,8 +518,8 @@ def snapshot_singleton(
help='Do not raise exception if there are no actionable indices'
)
@click.option(
'--filter_list', callback=validate_filter_json,
help='JSON string representing an array of filters.', required=True
'--filter_list', callback=validate_filter_json, default='{"filtertype":"none"}',
help='JSON string representing an array of filters.'
)
@click.pass_context
def show_indices_singleton(
Expand All @@ -547,8 +540,7 @@ def show_indices_singleton(
'filters': filter_schema_check(action, filter_list)
}
ilo = IndexList(client)
ilo.iterate_filters(clean_filters)
_check_empty_list(ilo, ignore_empty_list)
_do_filters(ilo, clean_filters, ignore_empty_list)
indices = sorted(ilo.indices)
# Do some calculations to figure out the proper column sizes
allbytes = []
Expand Down Expand Up @@ -606,8 +598,8 @@ def show_indices_singleton(
help='Do not raise exception if there are no actionable snapshots'
)
@click.option(
'--filter_list', callback=validate_filter_json,
help='JSON string representing an array of filters.', required=True
'--filter_list', callback=validate_filter_json, default='{"filtertype":"none"}',
help='JSON string representing an array of filters.'
)
@click.pass_context
def show_snapshots_singleton(
Expand All @@ -624,8 +616,7 @@ def show_snapshots_singleton(
'filters': filter_schema_check(action, filter_list)
}
slo = SnapshotList(client, repository=repository)
slo.iterate_filters(clean_filters)
_check_empty_list(slo, ignore_empty_list)
_do_filters(slo, clean_filters, ignore_empty_list)
snapshots = sorted(slo.snapshots)
for idx in snapshots:
click.secho('{0}'.format(idx))
Expand Down
24 changes: 24 additions & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
Changelog
=========

4.2.5 (22 December 2016)
------------------------

**General**

* Add and increment test versions for Travis CI. #839 (untergeek)
* Make `filter_list` optional in snapshot, show_snapshot and show_indices
singleton actions. #853 (alexef)

**Bug Fixes**

* Fix cli integration test when different host/port are specified. Reported
in #843 (untergeek)
* Catch empty list condition during filter iteration in singleton actions.
Reported in #848 (untergeek)

**Documentation**

* Add docs regarding how filters are ANDed together, and how to do an OR with
the regex pattern filter type. Requested in #842 (untergeek)
* Fix typo in Click version in docs. #850 (breml)
* Where applicable, replace `[source,text]` with `[source,yaml]` for better
formatting in the resulting docs.

4.2.4 (7 December 2016)
-----------------------

Expand Down
30 changes: 15 additions & 15 deletions docs/asciidoc/actions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ once created, can only be deleted.
[[alias]]
== Alias

[source,text]
[source,yaml]
-------------
action: alias
description: "Add/Remove selected indices to or from the specified alias"
Expand Down Expand Up @@ -57,7 +57,7 @@ The <<option_extra_settings,extra_settings>> option allows the addition of extra
settings with the `add` directive. These settings are ignored for `remove`. An
example of how these settings can be used to create a filtered alias might be:

[source,text]
[source,yaml]
-------------
extra_settings:
filter:
Expand Down Expand Up @@ -95,7 +95,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[allocation]]
== Allocation

[source,text]
[source,yaml]
-------------
action: allocation
description: "Apply shard allocation filtering rules to the specified indices"
Expand Down Expand Up @@ -154,7 +154,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[close]]
== Close

[source,text]
[source,yaml]
-------------
action: close
description: "Close selected indices"
Expand Down Expand Up @@ -193,7 +193,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[cluster_routing]]
== Cluster Routing

[source,text]
[source,yaml]
-------------
action: cluster_routing
description: "Apply routing rules to the entire cluster"
Expand Down Expand Up @@ -250,7 +250,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[create_index]]
== Create Index

[source,text]
[source,yaml]
-------------
action: create_index
description: "Create index as named"
Expand All @@ -272,7 +272,7 @@ The <<option_extra_settings,extra_settings>> option allows the addition of extra
settings, such as index settings and mappings. An example of how these settings
can be used to create an index might be:

[source,text]
[source,yaml]
-------------
extra_settings:
settings:
Expand Down Expand Up @@ -311,7 +311,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[delete_indices]]
== Delete Indices

[source,text]
[source,yaml]
-------------
action: delete_indices
description: "Delete selected indices"
Expand Down Expand Up @@ -347,7 +347,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[delete_snapshots]]
== Delete Snapshots

[source,text]
[source,yaml]
-------------
action: delete_snapshots
description: "Delete selected snapshots from 'repository'"
Expand Down Expand Up @@ -399,7 +399,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[open]]
== Open

[source,text]
[source,yaml]
-------------
action: open
description: "open selected indices"
Expand Down Expand Up @@ -435,7 +435,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[forcemerge]]
== Forcemerge

[source,text]
[source,yaml]
-------------
action: forcemerge
description: "Perform a forceMerge on selected indices to 'max_num_segments' per shard"
Expand Down Expand Up @@ -483,7 +483,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[replicas]]
== Replicas

[source,text]
[source,yaml]
-------------
action: replicas
description: >- Set the number of replicas per shard for selected
Expand Down Expand Up @@ -534,7 +534,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[restore]]
== Restore

[source,text]
[source,yaml]
-------------
actions:
1:
Expand Down Expand Up @@ -584,7 +584,7 @@ The <<option_extra_settings,extra_settings>> option allows the addition of extra
settings, such as index settings and mappings. An example of how these settings
can be used to change settings for an index being restored might be:

[source,text]
[source,yaml]
-------------
extra_settings:
settings:
Expand Down Expand Up @@ -639,7 +639,7 @@ TIP: See an example of this action in an <<actionfile,actionfile>>
[[snapshot]]
== Snapshot

[source,text]
[source,yaml]
-------------
action: snapshot
description: >-
Expand Down
2 changes: 1 addition & 1 deletion docs/asciidoc/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ documentation.
This is an optional description which can help describe what the action and its
filters are supposed to do.

[source,text]
[source,yaml]
-------------
description: >- I can make the description span multiple
lines by putting ">-" at the beginning of the line,
Expand Down
Loading

0 comments on commit 57cb667

Please sign in to comment.