8000 curator_cli forcemerge exception · Issue #1704 · elastic/curator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

curator_cli forcemerge exception #1704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Daniel314 opened this issue Feb 27, 2024 · 1 comment · Fixed by #1757
Closed

curator_cli forcemerge exception #1704

Daniel314 opened this issue Feb 27, 2024 · 1 comment · Fixed by #1757
Assignees

Comments

@Daniel314
Copy link

This issue has already been discussed on the Elastic forum: https://discuss.elastic.co/t/curator-forcemerge-exception/354245

To submit a bug or report an issue

I've discovered that the current version of curator_cli (version 8.0.10) will throw an Exception on forcemerge when the index in question is already at/below the requested number of segments per shard.

Expected Behavior

The curator_cli program should filter out indices as candidates to forcemerge when they are already at/below the requested number of segments per shard.

Actual Behavior

The curator_cli program throws an exception and exits with a nonzero exit code when the specified index already has the requested number of segments per shard.

Steps to Reproduce the Problem

## Verify that the index in question only has one sesgment per shard
$ curl -sS -XGET http://localhost:9200/cmulogstash-2024.02.21/_segments | jq '[ .. | .shards? // empty | to_entries[] | { "key":"shard \(.key)", "value":.value[0].num_committed_segments }] | flatten | from_entries'
{
  "shard 0": 1,
  "shard 1": 1
}
## Try to perform a forcemerge on the index
$ curator_cli --loglevel DEBUG  --request_timeout 14400 forcemerge --ignore_empty_list --max_num_segments 1 --filter_list '[{"filtertype":"pattern","kind":"prefix","value":"cmulogstash-2024.02.21"}]'
[ ... ]
2024-02-27 10:00:45,867 DEBUG          curator.indexlist             needs_data:266  Indices: ['cmulogstash-2024.02.21'], Fields: ['age', 'number_of_replicas', 'number_of_shards', 'routing']
2024-02-27 10:00:45,867 DEBUG          curator.indexlist          indices_exist:201  BEGIN indices_exist
2024-02-27 10:00:45,874 DEBUG          curator.indexlist             needs_data:281  These indices need data in index_info: ['cmulogstash-2024.02.21']
2024-02-27 10:00:45,875 DEBUG          curator.indexlist            data_getter:224  BEGIN data_getter
2024-02-27 10:00:45,875 DEBUG          curator.indexlist          indices_exist:201  BEGIN indices_exist
2024-02-27 10:00:45,881 DEBUG          curator.indexlist     get_index_settings:310  Getting index settings -- END
2024-02-27 10:00:45,881 DEBUG          curator.indexlist          filter_closed:802  Filtering closed indices
2024-02-27 10:00:45,881 DEBUG          curator.indexlist        get_index_state:320  Getting index state -- BEGIN
2024-02-27 10:00:45,881 DEBUG          curator.indexlist       empty_list_check:400  Checking for empty list
2024-02-27 10:00:45,882 DEBUG          curator.indexlist             needs_data:266  Indices: ['cmulogstash-2024.02.21'], Fields: ['state']
2024-02-27 10:00:45,882 DEBUG          curator.indexlist          indices_exist:201  BEGIN indices_exist
2024-02-27 10:00:45,887 DEBUG          curator.indexlist             needs_data:279  Always check open/close for all passed indices
2024-02-27 10:00:45,887 DEBUG          curator.indexlist             needs_data:281  These indices need data in index_info: ['cmulogstash-2024.02.21']
2024-02-27 10:00:45,891 DEBUG          curator.indexlist       empty_list_check:400  Checking for empty list
2024-02-27 10:00:45,892 DEBUG          curator.indexlist           working_list:411  Generating working list of indices
2024-02-27 10:00:45,892 DEBUG          curator.indexlist          filter_closed:808  Index cmulogstash-2024.02.21 state: open
2024-02-27 10:00:45,892 DEBUG          curator.indexlist           __actionable:41   Index cmulogstash-2024.02.21 is actionable and remains in the list.
2024-02-27 10:00:45,892 DEBUG          curator.indexlist     get_segment_counts:387  Getting index segment counts
2024-02-27 10:00:45,892 DEBUG          curator.indexlist       empty_list_check:400  Checking for empty list
2024-02-27 10:00:45,892 DEBUG          curator.indexlist            data_getter:224  BEGIN data_getter
2024-02-27 10:00:45,892 DEBUG          curator.indexlist          indices_exist:201  BEGIN indices_exist
2024-02-27 10:00:45,898 DEBUG          curator.indexlist           working_list:411  Generating working list of indices
2024-02-27 10:00:45,898 DEBUG          curator.indexlist       __not_actionable:44   Index cmulogstash-2024.02.21 is not actionable, removing from list.
2024-02-27 10:00:45,898 DEBUG          curator.indexlist            __excludify:63   Removed from actionable list: cmulogstash-2024.02.21 has 2 shard(s) + 1 replica(s) with a sum total of 4 segments.
2024-02-27 10:00:45,899 DEBUG          curator.indexlist       empty_list_check:400  Checking for empty list
2024-02-27 10:00:45,899 CRITICAL  curator.cli_singletons.cli_action.forcemerge    do_singleton_action:224  Failed to complete action: forcemerge.  <class 'Exception'>:

Specifications

  • Version: 8.0.10
  • Platform: Ubuntu 22.04 (it shouldn't matter)
  • Subsystem: curator / forcemerge

Context (Environment)

I have a script that runs nightly to forcemerge cold indices down to a single segment. It depends on script exit codes to check for errors/issues with Elastic index processed. Per the discussion in the Elastic forum (see the link at the beginning of this issue), I'm putting in a feature request to ask that curator_cli not error out on indices that are already at or below the requested number of segments per shard.

@untergeek untergeek self-assigned this Aug 7, 2024
untergeek added a commit to untergeek/curator that referenced this issue Apr 1, 2025
Replace:

```
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
```

With:

```
    try:
        action.do_singleton_action(dry_run=ctx.obj['dry_run'])
    except NoIndices:  # Speficically to address elastic#1704
        action.logger.info('No indices in list after filtering. Skipping action.')
```
untergeek added a commit to untergeek/curator that referenced this issue Apr 1, 2025
This here addresses the problem in elastic#1704

```diff
--- a/curator/cli_singletons/object_class.py
+++ b/curator/cli_singletons/object_class.py
@@ -262,7 +262,11 @@ class CLIAction:
                 action_obj.do_dry_run()
             else:
                 action_obj.do_action()
-
+        except NoIndices:  # Speficically to address elastic#1704
+            if not self.ignore:
+                self.logger.critical('No indices in list after filtering. Exiting.')
+                sys.exit(1)
+            self.logger.info('No indices in list after filtering. Skipping action.')
         except Exception as exc:
             self.logger.critical(
                 'Failed to complete action: %s. Exception: %s', self.action, exc
```
untergeek added a commit to untergeek/curator that referenced this issue Apr 1, 2025
This also demonstrates what happened with elastic#1704 and that this resolves it.

Two extra tests. One to test with `--ignore_empty_list` and one without that flag.
untergeek added a commit to untergeek/curator that referenced this issue Apr 1, 2025
8.0.21 (1 April 2025)
---------------------

**Bugfix Release**

As was reported in elastic#1704, the ``--ignore_empty_list`` option was not being respected.
Code changes were made to each singleton that uses the ``--ignore_empty_list`` option
to ensure that the option is respected.

**Changes**

  * Fix ``--ignore_empty_list`` option to be respected in all singletons.
  * Add debug message to IndexList class when an empty list condition is encountered.
  * Dependency version bump: ``es_client`` to ``8.17.5``
@untergeek
Copy link
Member

I finally took the time to resolve this. A release should be out later today.

untergeek added a commit that referenced this issue Apr 1, 2025
* Add debug log message on empty index list

* Add NoIndices try/except catch block

This here addresses the problem in #1704

```diff
--- a/curator/cli_singletons/object_class.py
+++ b/curator/cli_singletons/object_class.py
@@ -262,7 +262,11 @@ class CLIAction:
                 action_obj.do_dry_run()
             else:
                 action_obj.do_action()
-
+        except NoIndices:  # Speficically to address #1704
+            if not self.ignore:
+                self.logger.critical('No indices in list after filtering. Exiting.')
+                sys.exit(1)
+            self.logger.info('No indices in list after filtering. Skipping action.')
         except Exception as exc:
             self.logger.critical(
                 'Failed to complete action: %s. Exception: %s', self.action, exc
```

* Add tests for forcemerge to test the fix

This also demonstrates what happened with #1704 and that this resolves it.

Two extra tests. One to test with `--ignore_empty_list` and one without that flag.

* Version bump for es_client

Now at 8.17.5

* Version bump to 8.0.21

* Update Changelog

8.0.21 (1 April 2025)
---------------------

**Bugfix Release**

As was reported in #1704, the ``--ignore_empty_list`` option was not being respected.
Code changes were made to each singleton that uses the ``--ignore_empty_list`` option
to ensure that the option is respected.

**Changes**

  * Fix ``--ignore_empty_list`` option to be respected in all singletons.
  * Add debug message to IndexList class when an empty list condition is encountered.
  * Dependency version bump: ``es_client`` to ``8.17.5``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0