Skip to content

Commit d5a1a8f

Browse files
committed
Merge branch '8.x' into 8.0
2 parents 41c6f49 + e5d4460 commit d5a1a8f

31 files changed

+291
-137
lines changed

curator/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Curator Version"""
2-
__version__ = '8.0.13'
2+
__version__ = '8.0.14'

curator/actions/alias.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def add(self, ilo, warn_if_no_indices=False):
4747
:type ilo: :py:class:`~.curator.indexlist.IndexList`
4848
"""
4949
verify_index_list(ilo)
50-
self.loggit.debug('ADD -> ILO = %s', ilo)
50+
self.loggit.debug('ADD -> ILO = %s', ilo.indices)
5151
if not self.client:
5252
self.client = ilo.client
5353
self.name = parse_datemath(self.client, self.name)
@@ -80,7 +80,7 @@ def remove(self, ilo, warn_if_no_indices=False):
8080
:type ilo: :py:class:`~.curator.indexlist.IndexList`
8181
"""
8282
verify_index_list(ilo)
83-
self.loggit.debug('REMOVE -> ILO = %s', ilo)
83+
self.loggit.debug('REMOVE -> ILO = %s', ilo.indices)
8484
if not self.client:
8585
self.client = ilo.client
8686
self.name = parse_datemath(self.client, self.name)

curator/actions/cold2frozen.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Snapshot and Restore action classes"""
22
import logging
3-
from curator.helpers.getters import get_alias_actions, get_frozen_prefix, get_tier_preference
3+
from curator.helpers.getters import get_alias_actions, get_tier_preference, meta_getter
44
from curator.helpers.testers import has_lifecycle_name, is_idx_partial, verify_index_list
55
from curator.helpers.utils import report_failure
66
from curator.exceptions import CuratorException, FailedExecution, SearchableSnapshotException
@@ -76,7 +76,8 @@ def action_generator(self):
7676
:rtype: dict
7777
"""
7878
for idx in self.index_list.indices:
79-
idx_settings = self.client.indices.get(index=idx)[idx]['settings']['index']
79+
idx_settings = meta_getter(self.client, idx, get='settings')
80+
self.loggit.debug('Index %s has settings: %s', idx, idx_settings)
8081
if has_lifecycle_name(idx_settings):
8182
self.loggit.critical(
8283
'Index %s is associated with an ILM policy and this action will never work on '
@@ -85,13 +86,16 @@ def action_generator(self):
8586
if is_idx_partial(idx_settings):
8687
self.loggit.critical('Index %s is already in the frozen tier', idx)
8788
raise SearchableSnapshotException('Index is already in frozen tier')
89+
8890
snap = idx_settings['store']['snapshot']['snapshot_name']
8991
snap_idx = idx_settings['store']['snapshot']['index_name']
9092
repo = idx_settings['store']['snapshot']['repository_name']
91-
aliases = self.client.indices.get(index=idx)[idx]['aliases']
93+
msg = f'Index {idx} Snapshot name: {snap}, Snapshot index: {snap_idx}, repo: {repo}'
94+
self.loggit.debug(msg)
95+
96+
aliases = meta_getter(self.client, idx, get='alias')
9297

93-
prefix = get_frozen_prefix(snap_idx, idx)
94-
renamed = f'{prefix}{snap_idx}'
98+
renamed = f'partial-{idx}'
9599

96100
if not self.index_settings:
97101
self.index_settings = {
@@ -187,7 +191,7 @@ def cleanup(self, current_idx, newidx):
187191
def do_action(self):
188192
"""
189193
Do the actions outlined:
190-
194+
Extract values from generated kwargs
191195
Mount
192196
Verify
193197
Update Aliases

curator/cli.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,22 @@ def process_action(client, action_def, dry_run=False):
8686
logger = logging.getLogger(__name__)
8787
logger.debug('Configuration dictionary: %s', action_def.action_dict)
8888
mykwargs = {}
89+
search_pattern = '_all'
8990

91+
logger.critical('INITIAL Action kwargs: %s', mykwargs)
9092
# Add some settings to mykwargs...
9193
if action_def.action == 'delete_indices':
9294
mykwargs['master_timeout'] = 30
9395

9496
### Update the defaults with whatever came with opts, minus any Nones
9597
mykwargs.update(prune_nones(action_def.options))
98+
99+
# Pop out the search_pattern option, if present.
100+
if 'search_pattern' in mykwargs:
101+
search_pattern = mykwargs.pop('search_pattern')
102+
96103
logger.debug('Action kwargs: %s', mykwargs)
104+
logger.critical('Post search_pattern Action kwargs: %s', mykwargs)
97105

98106
### Set up the action ###
99107
logger.debug('Running "%s"', action_def.action.upper())
@@ -120,8 +128,9 @@ def process_action(client, action_def, dry_run=False):
120128
mykwargs.pop('repository') # We don't need to send this value to the action
121129
action_def.instantiate('list_obj', client, repository=action_def.options['repository'])
122130
else:
123-
action_def.instantiate('list_obj', client)
131+
action_def.instantiate('list_obj', client, search_pattern=search_pattern)
124132
action_def.list_obj.iterate_filters({'filters': action_def.filters})
133+
logger.critical('Pre Instantiation Action kwargs: %s', mykwargs)
125134
action_def.instantiate('action_cls', action_def.list_obj, **mykwargs)
126135
### Do the action
127136
if dry_run:

curator/cli_singletons/allocation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from curator.cli_singletons.utils import validate_filter_json
55

66
@click.command()
7+
@click.option('--search_pattern', type=str, default='_all', help='Elasticsearch Index Search Pattern')
78
@click.option('--key', type=str, required=True, help='Node identification tag')
89
@click.option('--value', type=str, default=None, help='Value associated with --key')
910
@click.option('--allocation_type', type=click.Choice(['require', 'include', 'exclude']))
@@ -47,6 +48,7 @@
4748
@click.pass_context
4849
def allocation(
4950
ctx,
51+
search_pattern,
5052
key,
5153
value,
5254
allocation_type,
@@ -61,6 +63,7 @@ def allocation(
6163
Shard Routing Allocation
6264
"""
6365
manual_options = {
66+
'search_pattern': search_pattern,
6467
'key': key,
6568
'value': value,
6669
'allocation_type': allocation_type,

curator/cli_singletons/close.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from curator.cli_singletons.utils import validate_filter_json
55

66
@click.command()
7+
@click.option('--search_pattern', type=str, default='_all', help='Elasticsearch Index Search Pattern')
78
@click.option('--delete_aliases', is_flag=True, help='Delete all aliases from indices to be closed')
89
@click.option('--skip_flush', is_flag=True, help='Skip flush phase for indices to be closed')
910
@click.option(
@@ -24,11 +25,14 @@
2425
required=True
2526
)
2627
@click.pass_context
27-
def close(ctx, delete_aliases, skip_flush, ignore_empty_list, allow_ilm_indices, filter_list):
28+
def close(
29+
ctx, search_pattern, delete_aliases, skip_flush, ignore_empty_list, allow_ilm_indices,
30+
filter_list):
2831
"""
2932
Close Indices
3033
"""
3134
manual_options = {
35+
'search_pattern': search_pattern,
3236
'skip_flush': skip_flush,
3337
'delete_aliases': delete_aliases,
3438
'allow_ilm_indices': allow_ilm_indices,

curator/cli_singletons/delete.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#### Indices ####
77
@click.command()
8+
@click.option('--search_pattern', type=str, default='_all', help='Elasticsearch Index Search Pattern')
89
@click.option(
910
'--ignore_empty_list',
1011
is_flag=True,
@@ -23,15 +24,15 @@
2324
required=True
2425
)
2526
@click.pass_context
26-
def delete_indices(ctx, ignore_empty_list, allow_ilm_indices, filter_list):
27+
def delete_indices(ctx, search_pattern, ignore_empty_list, allow_ilm_indices, filter_list):
2728
"""
2829
Delete Indices
2930
"""
3031
# ctx.info_name is the name of the function or name specified in @click.command decorator
3132
action = CLIAction(
3233
'delete_indices',
3334
ctx.obj['configdict'],
34-
{'allow_ilm_indices':allow_ilm_indices},
35+
{'search_pattern': search_pattern, 'allow_ilm_indices':allow_ilm_indices},
3536
filter_list,
3637
ignore_empty_list
3738
)

curator/cli_singletons/forcemerge.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from curator.cli_singletons.utils import validate_filter_json
55

66
@click.command()
7+
@click.option('--search_pattern', type=str, default='_all', help='Elasticsearch Index Search Pattern')
78
@click.option(
89
'--max_num_segments',
910
type=int,
@@ -32,11 +33,14 @@
3233
help='JSON array of filters selecting indices to act on.',
3334
required=True)
3435
@click.pass_context
35-
def forcemerge(ctx, max_num_segments, delay, ignore_empty_list, allow_ilm_indices, filter_list):
36+
def forcemerge(
37+
ctx, search_pattern, max_num_segments, delay, ignore_empty_list, allow_ilm_indices,
38+
filter_list):
3639
"""
3740
forceMerge Indices (reduce segment count)
3841
"""
3942
manual_options = {
43+
'search_pattern': search_pattern,
4044
'max_num_segments': max_num_segments,
4145
'delay': delay,
4246
'allow_ilm_indices': allow_ilm_indices,

curator/cli_singletons/object_class.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ def __init__(self, action, configdict, option_dict, filter_list, ignore_empty_li
7676
self.check_options(option_dict)
7777
else:
7878
self.options = option_dict
79+
80+
# Pop out search_pattern if it's there
81+
self.search_pattern = '_all'
82+
if 'search_pattern' in self.options:
83+
self.search_pattern = self.options.pop('search_pattern')
84+
7985
# Extract allow_ilm_indices so it can be handled separately.
8086
if 'allow_ilm_indices' in self.options:
8187
self.allow_ilm = self.options.pop('allow_ilm_indices')

curator/cli_singletons/open_indices.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from curator.cli_singletons.utils import validate_filter_json
55

66
@click.command(name='open')
7+
@click.option('--search_pattern', type=str, default='_all', help='Elasticsearch Index Search Pattern')
78
@click.option(
89
'--ignore_empty_list',
910
is_flag=True,
@@ -22,15 +23,15 @@
2223
required=True
2324
)
2425
@click.pass_context
25-
def open_indices(ctx, ignore_empty_list, allow_ilm_indices, filter_list):
26+
def open_indices(ctx, search_pattern, ignore_empty_list, allow_ilm_indices, filter_list):
2627
"""
2728
Open Indices
2829
"""
2930
# ctx.info_name is the name of the function or name specified in @click.command decorator
3031
action = CLIAction(
3132
ctx.info_name,
3233
ctx.obj['configdict'],
33-
{'allow_ilm_indices':allow_ilm_indices},
34+
{'search_pattern': search_pattern, 'allow_ilm_indices':allow_ilm_indices},
3435
filter_list,
3536
ignore_empty_list
3637
)

0 commit comments

Comments
 (0)