Skip to content

Commit 26c2f37

Browse files
committed
Merge branch 'master' into 8.x
2 parents a40706f + b471204 commit 26c2f37

File tree

274 files changed

+13685
-10206
lines changed

Some content is hidden

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

274 files changed

+13685
-10206
lines changed

.github/workflows/docs-build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: docs-build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request_target: ~
8+
merge_group: ~
9+
10+
jobs:
11+
docs-preview:
12+
uses: elastic/docs-builder/.github/workflows/preview-build.yml@main
13+
with:
14+
path-pattern: docs/**
15+
permissions:
16+
deployments: write
17+
id-token: write
18+
contents: read
19+
pull-requests: read

.github/workflows/docs-cleanup.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: docs-cleanup
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
8+
jobs:
9+
docs-preview:
10+
uses: elastic/docs-builder/.github/workflows/preview-cleanup.yml@main
11+
permissions:
12+
contents: none
13+
id-token: write
14+
deployments: write

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
localhost.es
33
oneliners.py
44
cacert.pem
5-
docs/
5+
docs/asciidoc.bak
66
docker_test/.env
77
docker_test/repo/
88
docker_test/curatortestenv
9-
docker_test/scripts/Dockerfile
109
html_docs/
1110

1211
# Byte-compiled / optimized / DLL files

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.17'
3+
__version__ = '8.0.18'

curator/actions/alias.py

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
"""Alias action"""
2+
23
import logging
4+
35
# pylint: disable=import-error
46
from curator.exceptions import ActionError, MissingArgument, NoIndices
57
from curator.helpers.date_ops import parse_date_pattern, parse_datemath
68
from curator.helpers.testers import verify_index_list
79
from curator.helpers.utils import report_failure
810

11+
912
class Alias:
1013
"""Alias Action Class"""
14+
1115
# pylint: disable=unused-argument
1216
def __init__(self, name=None, extra_settings=None, **kwargs):
1317
"""
1418
:param name: The alias name
15-
:param extra_settings: Extra settings, including filters and routing. For more information
16-
see `here </https://www.elastic.co/guide/en/elasticsearch/reference/8.6/indices-aliases.html>`_.
19+
:param extra_settings: Extra settings, including filters and routing.
20+
For more information see `here
21+
</https://www.elastic.co/guide/en/elasticsearch/reference/8.6/indices-aliases.html>`_.
1722
1823
:type name: str
1924
:type extra_settings: dict
@@ -25,14 +30,16 @@ def __init__(self, name=None, extra_settings=None, **kwargs):
2530
#: The :py:func:`~.curator.helpers.date_ops.parse_date_pattern` rendered
2631
#: version of what was passed by param ``name``.
2732
self.name = parse_date_pattern(name)
28-
#: The list of actions to perform. Populated by :py:meth:`~.curator.actions.Alias.add` and
33+
#: The list of actions to perform. Populated by
34+
#: :py:meth:`~.curator.actions.Alias.add` and
2935
#: :py:meth:`~.curator.actions.Alias.remove`
3036
self.actions = []
31-
#: The :py:class:`~.elasticsearch.Elasticsearch` client object which will later be set by
32-
#: :py:meth:`~.curator.actions.Alias.add` or :py:meth:`~.curator.actions.Alias.remove`
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`
3340
self.client = None
34-
#: Any extra things to add to the alias, like filters, or routing. Gets the value from
35-
#: param ``extra_settings``.
41+
#: Any extra things to add to the alias, like filters, or routing. Gets
42+
#: the value from param ``extra_settings``.
3643
self.extra_settings = extra_settings
3744
self.loggit = logging.getLogger('curator.actions.alias')
3845
#: Preset default value to ``False``.
@@ -41,7 +48,8 @@ def __init__(self, name=None, extra_settings=None, **kwargs):
4148
def add(self, ilo, warn_if_no_indices=False):
4249
"""
4350
Create ``add`` statements for each index in ``ilo`` for :py:attr:`name`, then
44-
append them to :py:attr:`actions`. Add any :py:attr:`extra_settings` that may be there.
51+
append them to :py:attr:`actions`. Add any :py:attr:`extra_settings` that
52+
may be there.
4553
4654
:param ilo: An IndexList Object
4755
:type ilo: :py:class:`~.curator.indexlist.IndexList`
@@ -58,16 +66,20 @@ def add(self, ilo, warn_if_no_indices=False):
5866
if warn_if_no_indices:
5967
self.warn_if_no_indices = True
6068
self.loggit.warning(
61-
'No indices found after processing filters. Nothing to add to %s', self.name)
69+
'No indices found after processing filters. Nothing to add to %s',
70+
self.name,
71+
)
6272
return
6373
# Re-raise the exceptions.NoIndices so it will behave as before
6474
raise NoIndices('No indices to add to alias') from exc
6575
for index in ilo.working_list():
6676
self.loggit.debug(
67-
'Adding index %s to alias %s with extra settings '
68-
'%s', index, self.name, self.extra_settings
77+
'Adding index %s to alias %s with extra settings %s',
78+
index,
79+
self.name,
80+
self.extra_settings,
6981
)
70-
add_dict = {'add' : {'index' : index, 'alias': self.name}}
82+
add_dict = {'add': {'index': index, 'alias': self.name}}
7183
add_dict['add'].update(self.extra_settings)
7284
self.actions.append(add_dict)
7385

@@ -92,7 +104,8 @@ def remove(self, ilo, warn_if_no_indices=False):
92104
self.warn_if_no_indices = True
93105
self.loggit.warning(
94106
'No indices found after processing filters. '
95-
'Nothing to remove from %s', self.name
107+
'Nothing to remove from %s',
108+
self.name,
96109
)
97110
return
98111

@@ -104,19 +117,24 @@ def remove(self, ilo, warn_if_no_indices=False):
104117
self.loggit.debug('Index %s in get_aliases output', index)
105118
# Only remove if the index is associated with the alias
106119
if self.name in aliases[index]['aliases']:
107-
self.loggit.debug('Removing index %s from alias %s', index, self.name)
120+
self.loggit.debug(
121+
'Removing index %s from alias %s', index, self.name
122+
)
108123
self.actions.append(
109-
{'remove' : {'index' : index, 'alias': self.name}})
124+
{'remove': {'index': index, 'alias': self.name}}
125+
)
110126
else:
111127
self.loggit.debug(
112-
'Can not remove: Index %s is not associated with alias %s', index, self.name
128+
'Can not remove: Index %s is not associated with alias %s',
129+
index,
130+
self.name,
113131
)
114132

115133
def check_actions(self):
116134
"""
117135
:returns: :py:attr:`actions` for use with the
118-
:py:meth:`~.elasticsearch.client.IndicesClient.update_aliases` API call if actions
119-
exist, otherwise an exception is raised.
136+
:py:meth:`~.elasticsearch.client.IndicesClient.update_aliases` API
137+
call if actions exist, otherwise an exception is raised.
120138
"""
121139
if not self.actions:
122140
if not self.warn_if_no_indices:
@@ -143,8 +161,8 @@ def do_dry_run(self):
143161

144162
def do_action(self):
145163
"""
146-
:py:meth:`~.elasticsearch.client.IndicesClient.update_aliases` for :py:attr:`name` with
147-
:py:attr:`actions`
164+
:py:meth:`~.elasticsearch.client.IndicesClient.update_aliases` for
165+
:py:attr:`name` with :py:attr:`actions`
148166
"""
149167
self.loggit.info('Updating aliases...')
150168
self.loggit.info('Alias actions: %s', self.actions)

curator/actions/allocation.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
"""Allocation action class"""
2+
23
import logging
4+
35
# pylint: disable=import-error
46
from curator.exceptions import MissingArgument
57
from curator.helpers.testers import verify_index_list
68
from curator.helpers.waiters import wait_for_it
79
from curator.helpers.utils import chunk_index_list, report_failure, show_dry_run, to_csv
810

11+
912
class Allocation:
1013
"""Allocation Action Class"""
14+
1115
def __init__(
12-
self, ilo, key=None, value=None, allocation_type='require', wait_for_completion=False,
13-
wait_interval=3, max_wait=-1
14-
):
16+
self,
17+
ilo,
18+
key=None,
19+
value=None,
20+
allocation_type='require',
21+
wait_for_completion=False,
22+
wait_interval=3,
23+
max_wait=-1,
24+
):
1525
"""
1626
:param ilo: An IndexList Object
17-
:param key: An arbitrary metadata attribute key. Must match the key assigned to at least
18-
:param value: An arbitrary metadata attribute value. Must correspond to values associated
27+
:param key: An arbitrary metadata attribute key. Must match the key
28+
assigned to at least one node.
29+
:param value: An arbitrary metadata attribute value. Must correspond to
30+
values associated with at least one node.
1931
:param allocation_type: Type of allocation to apply. Default is ``require``
2032
:param wait_for_completion: Wait for completion before returning.
2133
:param wait_interval: Seconds to wait between completion checks.
@@ -30,15 +42,16 @@ def __init__(
3042
:type max_wait: int
3143
3244
.. note::
33-
See more about `shard allocation filtering </https://www.elastic.co/guide/en/elasticsearch/reference/8.6/shard-allocation-filtering.html>`_.
45+
See more about `shard allocation filtering
46+
</https://www.elastic.co/guide/en/elasticsearch/reference/8.6/shard-allocation-filtering.html>`_.
3447
"""
3548
verify_index_list(ilo)
3649
if not key:
3750
raise MissingArgument('No value for "key" provided')
3851
if allocation_type not in ['require', 'include', 'exclude']:
3952
raise ValueError(
40-
f'{allocation_type} is an invalid allocation_type. Must be one of "require", '
41-
'"include", "exclude".'
53+
f'{allocation_type} is an invalid allocation_type. Must be one of '
54+
f'"require", "include", "exclude".'
4255
)
4356
#: The :py:class:`~.curator.indexlist.IndexList` object passed as ``ilo``
4457
self.index_list = ilo
@@ -50,7 +63,7 @@ def __init__(
5063
#: Populated at instance creation time. Value is built from the passed params
5164
#: ``allocation_type``, ``key``, and ``value``, e.g.
5265
#: ``index.routing.allocation.allocation_type.key.value``
53-
self.settings = {bkey : value}
66+
self.settings = {bkey: value}
5467
#: Object attribute that gets the value of param ``wait_for_completion``
5568
self.wfc = wait_for_completion
5669
#: Object attribute that gets the value of param ``wait_interval``
@@ -74,8 +87,9 @@ def do_action(self):
7487
self.index_list.filter_closed()
7588
self.index_list.empty_list_check()
7689
self.loggit.info(
77-
'Updating %s selected indices: %s', len(self.index_list.indices),
78-
self.index_list.indices
90+
'Updating %s selected indices: %s',
91+
len(self.index_list.indices),
92+
self.index_list.indices,
7993
)
8094
self.loggit.info('Updating index setting %s', self.settings)
8195
try:
@@ -86,10 +100,14 @@ def do_action(self):
86100
)
87101
if self.wfc:
88102
self.loggit.debug(
89-
'Waiting for shards to complete relocation for indices: %s', to_csv(lst))
103+
'Waiting for shards to complete relocation for indices: %s',
104+
to_csv(lst),
105+
)
90106
wait_for_it(
91-
self.client, 'allocation',
92-
wait_interval=self.wait_interval, max_wait=self.max_wait
107+
self.client,
108+
'allocation',
109+
wait_interval=self.wait_interval,
110+
max_wait=self.max_wait,
93111
)
94112
# pylint: disable=broad-except
95113
except Exception as err:

curator/actions/close.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
"""Close index action class"""
2+
23
import logging
4+
import warnings
5+
from elasticsearch8.exceptions import ElasticsearchWarning
36
from curator.helpers.testers import verify_index_list
47
from curator.helpers.utils import chunk_index_list, report_failure, show_dry_run, to_csv
58

9+
610
class Close:
711
"""Close Action Class"""
12+
813
def __init__(self, ilo, delete_aliases=False, skip_flush=False):
914
"""
1015
:param ilo: An IndexList Object
@@ -16,7 +21,8 @@ def __init__(self, ilo, delete_aliases=False, skip_flush=False):
1621
:type skip_flush: bool
1722
"""
1823
verify_index_list(ilo)
19-
#: The :py:class:`~.curator.indexlist.IndexList` object passed from param ``ilo``
24+
#: The :py:class:`~.curator.indexlist.IndexList` object passed from
25+
#: param ``ilo``
2026
self.index_list = ilo
2127
#: The value passed as ``delete_aliases``
2228
self.delete_aliases = delete_aliases
@@ -29,17 +35,21 @@ def __init__(self, ilo, delete_aliases=False, skip_flush=False):
2935

3036
def do_dry_run(self):
3137
"""Log what the output would be, but take no action."""
32-
show_dry_run(self.index_list, 'close', **{'delete_aliases':self.delete_aliases})
38+
show_dry_run(
39+
self.index_list, 'close', **{'delete_aliases': self.delete_aliases}
40+
)
3341

3442
def do_action(self):
3543
"""
36-
:py:meth:`~.elasticsearch.client.IndicesClient.close` open indices in :py:attr:`index_list`
44+
:py:meth:`~.elasticsearch.client.IndicesClient.close` open indices in
45+
:py:attr:`index_list`
3746
"""
3847
self.index_list.filter_closed()
3948
self.index_list.empty_list_check()
4049
self.loggit.info(
4150
'Closing %s selected indices: %s',
42-
len(self.index_list.indices), self.index_list.indices
51+
len(self.index_list.indices),
52+
self.index_list.indices,
4353
)
4454
try:
4555
index_lists = chunk_index_list(self.index_list.indices)
@@ -50,14 +60,24 @@ def do_action(self):
5060
self.loggit.info('Deleting aliases from indices before closing.')
5161
self.loggit.debug('Deleting aliases from: %s', lst)
5262
try:
53-
self.client.indices.delete_alias(index=lst_as_csv, name='_all')
63+
self.client.indices.delete_alias(index=lst_as_csv, name='*')
5464
self.loggit.debug('Deleted aliases from: %s', lst)
5565
# pylint: disable=broad-except
5666
except Exception as err:
5767
self.loggit.warning(
58-
'Some indices may not have had aliases. Exception: %s', err)
68+
'Some indices may not have had aliases. Exception: %s', err
69+
)
5970
if not self.skip_flush:
60-
self.client.indices.flush(index=lst_as_csv, ignore_unavailable=True, force=True)
71+
self.client.indices.flush(
72+
index=lst_as_csv, ignore_unavailable=True, force=True
73+
)
74+
# ElasticsearchWarning: the default value for the
75+
# wait_for_active_shards parameter will change from '0' to
76+
# 'index-setting' in version 8;
77+
# specify 'wait_for_active_shards=index-setting' to adopt the
78+
# future default behaviour, or
79+
# 'wait_for_active_shards=0' to preserve today's behaviour
80+
warnings.filterwarnings("ignore", category=ElasticsearchWarning)
6181
self.client.indices.close(index=lst_as_csv, ignore_unavailable=True)
6282
# pylint: disable=broad-except
6383
except Exception as err:

0 commit comments

Comments
 (0)