Curator: continue_if_exception does not work as expected

Created on 22 Oct 2016  路  2Comments  路  Source: elastic/curator

Curator Version: 4.1.2
Elasticsearch: 2.4.0

Even though I have continue_if_exception set to True for all 3 actions, curator exits if there are no actionable items in list for an action.

Details

2016-10-21 15:46:10,154 INFO      Preparing Action ID: 1, "allocation"
2016-10-21 15:46:10,154 INFO      Trying Action ID: 1, "allocation": Apply shard allocation routing to 'include' 'tag=warm' for hot/warm node setup for indices older than x, based on index_creation date.
2016-10-21 15:46:10,607 ERROR     Unable to complete action "allocation".  No actionable items in list: <class 'curator.exceptions.NoIndices'>

Curator would continue only after I added ignore_empty_list: True to each action. I wonder if this is a bug or an expected behavior?

Full curator action file

# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True.  If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
  1:
    action: allocation
    description: >-
      Apply shard allocation routing to 'include' 'tag=warm' for hot/warm node
      setup for indices older than x, based on index_creation date.
    options:
      key: tag
      value: warm
      allocation_type: include
      wait_for_completion: False
      timeout_override:
      continue_if_exception: True
      ignore_empty_list: True
      disable_action: False
    filters:
    - filtertype: age
      source: creation_date
      direction: older
      unit: months
      unit_count: 1
      exclude:
    - filtertype: closed
      exclude: True
    - filtertype: pattern
      kind: prefix
      value: '\.'
      exclude: True
    - filtertype: allocated
      key: tag
      value: warm
      allocation_type: include
      exclude: True
  2:
    action: close
    description: >-
      Close indices older than x.
    options:
      delete_aliases: False
      timeout_override:
      continue_if_exception: True
      ignore_empty_list: True
      disable_action: False
    filters:
    - filtertype: age
      source: creation_date
      direction: older
      unit: months
      unit_count: 3
      exclude:
    - filtertype: closed
      exclude: True
    - filtertype: pattern
      kind: prefix
      value: '\.'
      exclude: True
  3:
    action: forcemerge
    description: >-
      forceMerge prefixed indices older than x (based on index
      creation_date) to 1 segments per shard.  Delay 120 seconds between each
      forceMerge operation to allow the cluster to quiesce.
      This action will ignore indices already forceMerged to the same or fewer
      number of segments per shard, so the 'forcemerged' filter is unneeded.
    options:
      max_num_segments: 1
      delay: 120
      timeout_override:
      continue_if_exception: True
      ignore_empty_list: True
      disable_action: False
    filters:
    - filtertype: age
      source: creation_date
      direction: older
      unit: days
      unit_count: 35
      exclude:
    - filtertype: closed
      exclude: True
    - filtertype: pattern
      kind: prefix
      value: '\.'
      exclude: True
    - filtertype: allocated
      key: tag
      value: warm
      allocation_type: include
      exclude: False   

Most helpful comment

Long story short: Yes, the different exceptions are acted on differently.

The exceptions caught are acted on differently. First, Curator catches _all_ exceptions. Then it tests to see if it was an empty list exception. If it is an empty list exception, it will act according to the conditionals. Otherwise, regardless of exception, it will test for continue_if_exception and act accordingly.

So if your case is not fatal from an empty list, you should use ignore_empty_list: True, rather than continue_if_exception: True, as the two are mutually exclusive.

All 2 comments

Long story short: Yes, the different exceptions are acted on differently.

The exceptions caught are acted on differently. First, Curator catches _all_ exceptions. Then it tests to see if it was an empty list exception. If it is an empty list exception, it will act according to the conditionals. Otherwise, regardless of exception, it will test for continue_if_exception and act accordingly.

So if your case is not fatal from an empty list, you should use ignore_empty_list: True, rather than continue_if_exception: True, as the two are mutually exclusive.

Thanks for the clarification.

Was this page helpful?
0 / 5 - 0 ratings