# Curator with multiple actions isn't deleting all specified indices

**URL:** https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432
**Category:** Elasticsearch
**Created:** [January 3, 2017, 1:23pm UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432 "2017-01-03T13:23:48Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Cylindric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cylindric/32/5660_2.png) [@Cylindric](https://discuss.elastic.co/u/Cylindric)
#### Post date: [January 3, 2017, 1:23pm UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/1 "2017-01-03T13:23:48Z")

</div>

I am using Curator 4.0.0 to manage a bunch of indices, and when I try to specify several filters in a single actions.yml, it seems to do something odd.

I have four things going into ES: WinLogBeat, FileBeat, MetricBeat and PacketBeat. I want different timeouts for some of these, so I have the following actions.yml:

```
actions:
  1:
    action: delete_indices
    options:
      continue_if_exception: True
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: winlogbeat-
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: months
      unit_count: 1
  2:
    action: delete_indices
    options:
      continue_if_exception: True
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: filebeat-
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: months
      unit_count: 1
  3:
    action: delete_indices
    options:
      continue_if_exception: True
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: metricbeat-
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: months
      unit_count: 1
  4:
    action: delete_indices
    options:
      continue_if_exception: True
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: packetbeat-
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 6

```

And if I run curator with that config, I get the "nothing to delete" error.

If I run it just with the last section, I correctly get a bunch of deleted indices:

```
  1:
    action: delete_indices
    options:
      continue_if_exception: True
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: packetbeat-
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 6

```

Output:

```
2017-01-03 13:14:57,796 INFO DRY-RUN: delete_indices: packetbeat-2016.12.14 with arguments: {}
2017-01-03 13:14:57,796 INFO DRY-RUN: delete_indices: packetbeat-2016.12.15 with arguments: {}
2017-01-03 13:14:57,796 INFO DRY-RUN: delete_indices: packetbeat-2016.12.16 with arguments: {}
2017-01-03 13:14:57,796 INFO DRY-RUN: delete_indices: packetbeat-2016.12.17 with arguments: {}
2017-01-03 13:14:57,796 INFO DRY-RUN: delete_indices: packetbeat-2016.12.18 with arguments: {}
2017-01-03 13:14:57,796 INFO DRY-RUN: delete_indices: packetbeat-2016.12.19 with arguments: {}
2017-01-03 13:14:57,796 INFO DRY-RUN: delete_indices: packetbeat-2016.12.20 with arguments: {}
2017-01-03 13:14:57,796 INFO DRY-RUN: delete_indices: packetbeat-2016.12.21 with arguments: {}
2017-01-03 13:14:57,797 INFO DRY-RUN: delete_indices: packetbeat-2016.12.22 with arguments: {}
2017-01-03 13:14:57,797 INFO DRY-RUN: delete_indices: packetbeat-2016.12.23 with arguments: {}
2017-01-03 13:14:57,797 INFO DRY-RUN: delete_indices: packetbeat-2016.12.24 with arguments: {}
2017-01-03 13:14:57,797 INFO DRY-RUN: delete_indices: packetbeat-2016.12.25 with arguments: {}
2017-01-03 13:14:57,797 INFO DRY-RUN: delete_indices: packetbeat-2016.12.26 with arguments: {}
2017-01-03 13:14:57,797 INFO DRY-RUN: delete_indices: packetbeat-2016.12.27 with arguments: {}
```

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [January 3, 2017, 5:53pm UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/2 "2017-01-03T17:53:58Z")

</div>

You should upgrade to the latest version, which is currently 4.2.5, and use the `ignore_empty_list` option.

---

<div class="post-metadata">

### Author: ![Cylindric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cylindric/32/5660_2.png) [@Cylindric](https://discuss.elastic.co/u/Cylindric)
#### Post date: [January 4, 2017, 9:24am UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/3 "2017-01-04T09:24:50Z")

</div>

Ah, I didn't realise I was using an older version. I had an existing 4.0.0 installed, so the package version I installed was being ignored. I'll give that a go now.

---

<div class="post-metadata">

### Author: ![Cylindric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cylindric/32/5660_2.png) [@Cylindric](https://discuss.elastic.co/u/Cylindric)
#### Post date: [January 4, 2017, 9:36am UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/4 "2017-01-04T09:36:07Z")

</div>

That worked. For what it's worth, it's not made particularly clear anywhere that if one step "fails" due to no matching indices, none of the following ones are executed. Perhaps a note on the main page [about actions](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/actionfile.html) making it clear that they will only be executed if the preceding step did not fail, regardless of the "continue\_if\_exception" setting.  
I realise it makes sense for many other operations, but I suspect many people use curator for pruning old log-based indices, and wouldn't even think of "nothing to do" as an error condition.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [January 4, 2017, 12:50pm UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/5 "2017-01-04T12:50:48Z")

</div>

I apologize for the confusion. I will see about updating the documentation. It _is_ tricky. "Nothing to do" _might_ be an error. That's why the ignore\_empty\_list option was added.

---

<div class="post-metadata">

### Author: ![Cylindric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cylindric/32/5660_2.png) [@Cylindric](https://discuss.elastic.co/u/Cylindric)
#### Post date: [January 4, 2017, 2:26pm UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/6 "2017-01-04T14:26:45Z")

</div>

Oh yes - it wasn't a criticism, just a suggestion 🙂 It's a bit confusing at the moment how continue\_if\_exception and ignore\_empty\_list work together.

If ignore\_empty\_list is false, it seems to result in an error for empty lists (as fits the description), but then "continue\_if\_exception" doesn't make it continue as I would expect it to.

This is what happens if there is an empty list:

```
ignore_empty_list continue_if_exception behaviour
false false immediate abort, as expected
false true immediate abort, but should continue because we chose to ignore this?
true false continues, as there is no error. (I haven't tried this)
true true empty list continues, as there is no error.
```

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [January 4, 2017, 5:04pm UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/7 "2017-01-04T17:04:45Z")

</div>

An empty list is a special condition, and it is treated differently, as you found out under unfortunate circumstances.

Suppose my filter block removes any indices from consideration. A good example of this is setting up Curator to purge daily indices after 30 days, but I only have two weeks so far because it's a brand new installation. The action cannot continue because there's nothing to act on. This is an error, but it's not a normally fatal error, like being unable to connect, or getting a failed response from Elasticsearch. This action should work at "day 31," but that's not a reason to fail _now._

On the other hand, if I had `continue_if_exception` catch _all_ errors, including empty list ones, then I might move on to the next action even though the previous one had failed. Suppose I wanted to optimize indices after a hot -\> warm shard reallocation, but that failed because of some error reported by Elasticsearch (an example I heard last week was that there wasn't enough room on the warm nodes to accept the new shards). If `continue_if_exception` were true, then I would begin an I/O intensive optimize immediately after the failed relocation, and it would happen on my "hot" nodes, where I want every bit of I/O I can get.

This is why there are two separate exception types: one to catch only the empty-list exceptions, and one to catch everything else.

---

<div class="post-metadata">

### Author: ![Cylindric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cylindric/32/5660_2.png) [@Cylindric](https://discuss.elastic.co/u/Cylindric)
#### Post date: [January 4, 2017, 5:06pm UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/8 "2017-01-04T17:06:02Z")

</div>

Cool, thanks for the examples. At the moment I'm only using ES for log data, so don't quite have a handle on all the more fancy things that can be done with it 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 1, 2017, 5:06pm UTC](https://discuss.elastic.co/t/curator-with-multiple-actions-isnt-deleting-all-specified-indices/70432/9 "2017-02-01T17:06:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
