Skip to content
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

filter_by_age doesn't throw Exception curator.exceptions.NoIndices #1561

Open
jourdan-west opened this issue Oct 21, 2020 · 6 comments
Open

Comments

@jourdan-west
Copy link

jourdan-west commented Oct 21, 2020

Expected Behavior

When filter_by_age() results in an empty list, the exception curator.exceptions.NoIndices should be thrown, same as is done for filter_by_regex().

Actual Behavior

When filter_by_age() is called, there is no empty list check as seen here in filter_by_regex(). Therefore, no exception is thrown if the filter results in an empty list.

Steps to Reproduce the Problem

I would expect the following exception to be caught since I have no index older than unit_count. After this, ilo.indices is an empty list.

try:
    ilo = curator.IndexList(client)
    ilo.filter_by_age(source='name', direction='older', timestring='%Y_%m', unit='days', unit_count=999999)
except curator.exceptions.NoIndices:
    return

Specifications

  • Version: elasticsearch-curator==5.8.1
  • Platform: Mac OS

Detailed Description

Put a call to empty_list_check() in filter_by_age() so that the proper exception is thrown.

@jourdan-west
Copy link
Author

The fix should be obvious but if you need me to write reproducible steps, i can.

@untergeek
Copy link
Member

So which exception is being thrown?

@jourdan-west
Copy link
Author

jourdan-west commented Oct 21, 2020

There is no exception being thrown at all (updated description).

@jourdan-west
Copy link
Author

I just added steps to reproduce for clarity.

@untergeek
Copy link
Member

It's been a while since I went through the code, but there may have been a reason I did not do this here. I will follow up when I can.

@myscl123
Copy link

myscl123 commented Feb 7, 2021

curator --version
curator, version 5.8.3
curator_cli --host 192.168.100.199 --port 9200 --username elastic --password 123456 show_indices
2021-02-07 15:46:57,337 INFO Instantiating client object
2021-02-07 15:46:57,338 INFO Testing client connectivity
2021-02-07 15:46:57,341 INFO Successfully created Elasticsearch client object with provided settings
.apm-agent-configuration
.apm-custom-link
.async-search
.items-default-000001
.kibana-event-log-7.10.2-000001
.kibana_1
.kibana_2
.kibana_task_manager_1
.lists-default-000001
.security-7
.tasks
.transform-internal-005
filebeat-7.10.2-2021.02.04-000001
kibana_sample_data_ecommerce
kibana_sample_data_flights
kibana_sample_data_logs
logs-index_pattern_placeholder
logstash-2021.02.01
logstash-testapi_access_2021.02.01
logstash-testapi_access_2021.02.02
logstash-testapi_access_2021.02.07
logstash-testapi_error_2021.02.07
metrics-endpoint.metadata_current_default
metrics-index_pattern_placeholder

action.yml

actions:
1:
action: delete_indices
description: >-
Delete indices older than 45 days (based on index name), for logstash-
prefixed indices. Ignore the error if the filter does not result in an
actionable list of indices (ignore_empty_list) and exit cleanly.
options:
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: prefix
value: logstash-
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 1

result:

2021-02-07 15:47:24,045 INFO Preparing Action ID: 1, "delete_indices"
2021-02-07 15:47:24,045 INFO Creating client object and testing connection
2021-02-07 15:47:24,046 INFO Instantiating client object
2021-02-07 15:47:24,046 INFO Testing client connectivity
2021-02-07 15:47:24,050 INFO Successfully created Elasticsearch client object with provided settings
2021-02-07 15:47:24,051 INFO Trying Action ID: 1, "delete_indices": Delete indices older than 20 days (based on index name), for logstash- prefixed indices. Ignore the error if the filter does not result in an actionable list of indices (ignore_empty_list) and exit cleanly.
2021-02-07 15:47:24,101 INFO Skipping action "delete_indices" due to empty list: <class 'curator.exceptions.NoIndices'>
2021-02-07 15:47:24,101 INFO Action ID: 1, "delete_indices" completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants