Skip to content

Commit 4883c72

Browse files
authored
Prep for 8.0.22 release (#1786)
* Fix singleton show_indices Addresses #1775 Fixed some Pylance errors with re-doing how CLIAction.get_list_object() works (return the value now instead of setting the attribute), and instead of setting self.list_object = None in the early lines of `__init__`, move it to the end so all of the dependencies needed by get_list_object() are addressed. Added a bit of typing to object_class.py as well. In show.py, the missing step was ```python action.list_object.get_index_stats() ``` This was missed when the IndexList class was updated to change how and when stats were collected. * Added a few more index patterns for de-facto omission ```diff diff --git a/curator/defaults/settings.py b/curator/defaults/settings.py index 800febf..bc0f298 100644 --- a/curator/defaults/settings.py +++ b/curator/defaults/settings.py @@ -12,8 +12,9 @@ CLICK_DRYRUN = { } DATA_NODE_ROLES = ['data', 'data_content', 'data_hot', 'data_warm'] EXCLUDE_SYSTEM = ( - '-.kibana*,-.security*,-.watch*,-.triggered_watch*,' - '-.ml*,-.geoip_databases*,-.logstash*,-.tasks*' + '-.apm-agent-configuration,-.apm-custom-link,-.async-search,-.fleet*,' + '-.geoip_databases*,-.inference,-.kibana*,-.logstash*,-.ml*,-.secrets-inference,' + '-.security*,-.slo-*,-.tasks*,-.transform-telemetry,-.watch*' ) VERSION_MIN = (7, 14, 0) VERSION_MAX = (8, 99, 99) ``` * Correct inverted ILM allow behavior * Add tiered-debug module, address index inclusion issues Fixes #1770
1 parent 7dd6914 commit 4883c72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1454
-619
lines changed

curator/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Curator Version"""
22

3-
__version__ = '8.0.21'
3+
__version__ = '8.0.22'

curator/actions/alias.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import logging
44

55
# pylint: disable=import-error
6+
from curator.debug import debug, begin_end
67
from curator.exceptions import ActionError, MissingArgument, NoIndices
78
from curator.helpers.date_ops import parse_date_pattern, parse_datemath
89
from curator.helpers.testers import verify_index_list
910
from curator.helpers.utils import report_failure
1011

12+
logger = logging.getLogger(__name__)
13+
1114

1215
class Alias:
1316
"""Alias Action Class"""
@@ -34,17 +37,22 @@ def __init__(self, name=None, extra_settings=None, **kwargs):
3437
#: :py:meth:`~.curator.actions.Alias.add` and
3538
#: :py:meth:`~.curator.actions.Alias.remove`
3639
self.actions = []
37-
#: The :py:class:`~.elasticsearch.Elasticsearch` client object which will
38-
#: later be set by :py:meth:`~.curator.actions.Alias.add` or
39-
#: :py:meth:`~.curator.actions.Alias.remove`
40-
self.client = None
4140
#: Any extra things to add to the alias, like filters, or routing. Gets
4241
#: the value from param ``extra_settings``.
4342
self.extra_settings = extra_settings
44-
self.loggit = logging.getLogger('curator.actions.alias')
4543
#: Preset default value to ``False``.
4644
self.warn_if_no_indices = False
4745

46+
@property
47+
def client(self):
48+
"""The :py:class:`~.elasticsearch.Elasticsearch` client object"""
49+
return self._client
50+
51+
@client.setter
52+
def client(self, value):
53+
self._client = value
54+
55+
@begin_end()
4856
def add(self, ilo, warn_if_no_indices=False):
4957
"""
5058
Create ``add`` statements for each index in ``ilo`` for :py:attr:`name`, then
@@ -55,25 +63,24 @@ def add(self, ilo, warn_if_no_indices=False):
5563
:type ilo: :py:class:`~.curator.indexlist.IndexList`
5664
"""
5765
verify_index_list(ilo)
58-
self.loggit.debug('ADD -> ILO = %s', ilo.indices)
59-
if not self.client:
60-
self.client = ilo.client
66+
debug.lv5('ADD -> ILO = %s', ilo.indices)
67+
self.client = ilo.client
6168
self.name = parse_datemath(self.client, self.name)
6269
try:
6370
ilo.empty_list_check()
6471
except NoIndices as exc:
6572
# Add a warning if there are no indices to add, if so set in options
6673
if warn_if_no_indices:
6774
self.warn_if_no_indices = True
68-
self.loggit.warning(
75+
logger.warning(
6976
'No indices found after processing filters. Nothing to add to %s',
7077
self.name,
7178
)
7279
return
7380
# Re-raise the exceptions.NoIndices so it will behave as before
7481
raise NoIndices('No indices to add to alias') from exc
7582
for index in ilo.working_list():
76-
self.loggit.debug(
83+
debug.lv1(
7784
'Adding index %s to alias %s with extra settings %s',
7885
index,
7986
self.name,
@@ -83,6 +90,7 @@ def add(self, ilo, warn_if_no_indices=False):
8390
add_dict['add'].update(self.extra_settings)
8491
self.actions.append(add_dict)
8592

93+
@begin_end()
8694
def remove(self, ilo, warn_if_no_indices=False):
8795
"""
8896
Create ``remove`` statements for each index in ``ilo`` for :py:attr:`name`,
@@ -92,17 +100,16 @@ def remove(self, ilo, warn_if_no_indices=False):
92100
:type ilo: :py:class:`~.curator.indexlist.IndexList`
93101
"""
94102
verify_index_list(ilo)
95-
self.loggit.debug('REMOVE -> ILO = %s', ilo.indices)
96-
if not self.client:
97-
self.client = ilo.client
103+
debug.lv5('REMOVE -> ILO = %s', ilo.indices)
104+
self.client = ilo.client
98105
self.name = parse_datemath(self.client, self.name)
99106
try:
100107
ilo.empty_list_check()
101108
except NoIndices as exc:
102109
# Add a warning if there are no indices to add, if so set in options
103110
if warn_if_no_indices:
104111
self.warn_if_no_indices = True
105-
self.loggit.warning(
112+
logger.warning(
106113
'No indices found after processing filters. '
107114
'Nothing to remove from %s',
108115
self.name,
@@ -114,22 +121,21 @@ def remove(self, ilo, warn_if_no_indices=False):
114121
aliases = self.client.indices.get_alias(expand_wildcards=['open', 'closed'])
115122
for index in ilo.working_list():
116123
if index in aliases:
117-
self.loggit.debug('Index %s in get_aliases output', index)
124+
debug.lv3('Index %s in get_aliases output', index)
118125
# Only remove if the index is associated with the alias
119126
if self.name in aliases[index]['aliases']:
120-
self.loggit.debug(
121-
'Removing index %s from alias %s', index, self.name
122-
)
127+
debug.lv1('Removing index %s from alias %s', index, self.name)
123128
self.actions.append(
124129
{'remove': {'index': index, 'alias': self.name}}
125130
)
126131
else:
127-
self.loggit.debug(
132+
debug.lv2(
128133
'Can not remove: Index %s is not associated with alias %s',
129134
index,
130135
self.name,
131136
)
132137

138+
@begin_end()
133139
def check_actions(self):
134140
"""
135141
:returns: :py:attr:`actions` for use with the
@@ -140,13 +146,13 @@ def check_actions(self):
140146
if not self.warn_if_no_indices:
141147
raise ActionError('No "add" or "remove" operations')
142148
raise NoIndices('No "adds" or "removes" found. Taking no action')
143-
self.loggit.debug('Alias actions: %s', self.actions)
149+
debug.lv5('Alias actions: %s', self.actions)
144150

145151
return self.actions
146152

147153
def do_dry_run(self):
148154
"""Log what the output would be, but take no action."""
149-
self.loggit.info('DRY-RUN MODE. No changes will be made.')
155+
logger.info('DRY-RUN MODE. No changes will be made.')
150156
for item in self.check_actions():
151157
job = list(item.keys())[0]
152158
index = item[job]['index']
@@ -157,15 +163,16 @@ def do_dry_run(self):
157163
f"DRY-RUN: alias: {job.rstrip('e')}ing index \"{index}\" "
158164
f"{'to' if job == 'add' else 'from'} alias \"{alias}\""
159165
)
160-
self.loggit.info(msg)
166+
logger.info(msg)
161167

168+
@begin_end()
162169
def do_action(self):
163170
"""
164171
:py:meth:`~.elasticsearch.client.IndicesClient.update_aliases` for
165172
:py:attr:`name` with :py:attr:`actions`
166173
"""
167-
self.loggit.info('Updating aliases...')
168-
self.loggit.info('Alias actions: %s', self.actions)
174+
logger.info('Updating aliases...')
175+
debug.lv3('Alias actions: %s', self.actions)
169176
try:
170177
self.client.indices.update_aliases(actions=self.actions)
171178
# pylint: disable=broad-except

curator/actions/allocation.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import logging
44

55
# pylint: disable=import-error
6+
from curator.debug import debug, begin_end
67
from curator.exceptions import MissingArgument
78
from curator.helpers.testers import verify_index_list
89
from curator.helpers.waiters import wait_for_it
910
from curator.helpers.utils import chunk_index_list, report_failure, show_dry_run, to_csv
1011

12+
logger = logging.getLogger(__name__)
13+
1114

1215
class Allocation:
1316
"""Allocation Action Class"""
@@ -58,7 +61,6 @@ def __init__(
5861
#: The :py:class:`~.elasticsearch.Elasticsearch` client object derived from
5962
#: :py:attr:`index_list`
6063
self.client = ilo.client
61-
self.loggit = logging.getLogger('curator.actions.allocation')
6264
bkey = f'index.routing.allocation.{allocation_type}.{key}'
6365
#: Populated at instance creation time. Value is built from the passed params
6466
#: ``allocation_type``, ``key``, and ``value``, e.g.
@@ -75,31 +77,32 @@ def do_dry_run(self):
7577
"""Log what the output would be, but take no action."""
7678
show_dry_run(self.index_list, 'allocation', settings=self.settings)
7779

80+
@begin_end()
7881
def do_action(self):
7982
"""
8083
:py:meth:`~.elasticsearch.client.IndicesClient.put_settings` to indices in
8184
:py:attr:`index_list` with :py:attr:`settings`.
8285
"""
83-
self.loggit.debug(
86+
debug.lv3(
8487
'Cannot get change shard routing allocation of closed indices. '
8588
'Omitting any closed indices.'
8689
)
8790
self.index_list.filter_closed()
8891
self.index_list.empty_list_check()
89-
self.loggit.info(
92+
logger.info(
9093
'Updating %s selected indices: %s',
9194
len(self.index_list.indices),
9295
self.index_list.indices,
9396
)
94-
self.loggit.info('Updating index setting %s', self.settings)
97+
debug.lv1('Updating index setting %s', self.settings)
9598
try:
9699
index_lists = chunk_index_list(self.index_list.indices)
97100
for lst in index_lists:
98101
self.client.indices.put_settings(
99102
index=to_csv(lst), settings=self.settings
100103
)
101104
if self.wfc:
102-
self.loggit.debug(
105+
debug.lv3(
103106
'Waiting for shards to complete relocation for indices: %s',
104107
to_csv(lst),
105108
)

curator/actions/close.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
import logging
44
import warnings
55
from elasticsearch8.exceptions import ElasticsearchWarning
6+
from curator.debug import begin_end, debug
67
from curator.helpers.testers import verify_index_list
78
from curator.helpers.utils import chunk_index_list, report_failure, show_dry_run, to_csv
89

10+
logger = logging.getLogger(__name__)
11+
912

1013
class Close:
1114
"""Close Action Class"""
@@ -31,22 +34,22 @@ def __init__(self, ilo, delete_aliases=False, skip_flush=False):
3134
#: The :py:class:`~.elasticsearch.Elasticsearch` client object derived from
3235
#: :py:attr:`index_list`
3336
self.client = ilo.client
34-
self.loggit = logging.getLogger('curator.actions.close')
3537

3638
def do_dry_run(self):
3739
"""Log what the output would be, but take no action."""
3840
show_dry_run(
3941
self.index_list, 'close', **{'delete_aliases': self.delete_aliases}
4042
)
4143

44+
@begin_end()
4245
def do_action(self):
4346
"""
4447
:py:meth:`~.elasticsearch.client.IndicesClient.close` open indices in
4548
:py:attr:`index_list`
4649
"""
4750
self.index_list.filter_closed()
4851
self.index_list.empty_list_check()
49-
self.loggit.info(
52+
logger.info(
5053
'Closing %s selected indices: %s',
5154
len(self.index_list.indices),
5255
self.index_list.indices,
@@ -55,16 +58,16 @@ def do_action(self):
5558
index_lists = chunk_index_list(self.index_list.indices)
5659
for lst in index_lists:
5760
lst_as_csv = to_csv(lst)
58-
self.loggit.debug('CSV list of indices to close: %s', lst_as_csv)
61+
debug.lv3('CSV list of indices to close: %s', lst_as_csv)
5962
if self.delete_aliases:
60-
self.loggit.info('Deleting aliases from indices before closing.')
61-
self.loggit.debug('Deleting aliases from: %s', lst)
63+
debug.lv1('Deleting aliases from indices before closing.')
64+
debug.lv3('Deleting aliases from: %s', lst)
6265
try:
6366
self.client.indices.delete_alias(index=lst_as_csv, name='*')
64-
self.loggit.debug('Deleted aliases from: %s', lst)
67+
debug.lv3('Deleted aliases from: %s', lst)
6568
# pylint: disable=broad-except
6669
except Exception as err:
67-
self.loggit.warning(
70+
logger.warning(
6871
'Some indices may not have had aliases. Exception: %s', err
6972
)
7073
if not self.skip_flush:

curator/actions/cluster_routing.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import logging
44

55
# pylint: disable=import-error
6+
from curator.debug import debug, begin_end
67
from curator.helpers.testers import verify_client_object
78
from curator.helpers.utils import report_failure
89
from curator.helpers.waiters import wait_for_it
910

11+
logger = logging.getLogger(__name__)
12+
1013

1114
class ClusterRouting:
1215
"""ClusterRouting Action Class"""
@@ -49,7 +52,6 @@ def __init__(
4952
verify_client_object(client)
5053
#: An :py:class:`~.elasticsearch.Elasticsearch` client object
5154
self.client = client
52-
self.loggit = logging.getLogger('curator.actions.cluster_routing')
5355
#: Object attribute that gets the value of param ``wait_for_completion``
5456
self.wfc = wait_for_completion
5557
#: Object attribute that gets the value of param ``wait_interval``
@@ -81,22 +83,21 @@ def __init__(
8183

8284
def do_dry_run(self):
8385
"""Log what the output would be, but take no action."""
84-
self.loggit.info('DRY-RUN MODE. No changes will be made.')
86+
logger.info('DRY-RUN MODE. No changes will be made.')
8587
msg = f'DRY-RUN: Update cluster routing transient settings: {self.settings}'
86-
self.loggit.info(msg)
88+
logger.info(msg)
8789

90+
@begin_end()
8891
def do_action(self):
8992
"""
9093
:py:meth:`~.elasticsearch.client.ClusterClient.put_settings` to the cluster with
9194
:py:attr:`settings`.
9295
"""
93-
self.loggit.info('Updating cluster settings: %s', self.settings)
96+
logger.info('Updating cluster settings: %s', self.settings)
9497
try:
9598
self.client.cluster.put_settings(transient=self.settings)
9699
if self.wfc:
97-
self.loggit.debug(
98-
'Waiting for shards to complete routing and/or rebalancing'
99-
)
100+
debug.lv3('Waiting for shards to complete routing and/or rebalancing')
100101
wait_for_it(
101102
self.client,
102103
'cluster_routing',

0 commit comments

Comments
 (0)