From 6e3f741ace5993598985b8fb01e0ab6ddf0a84db Mon Sep 17 00:00:00 2001
From: Jeffrey Zhang <zhang.lei.fly@gmail.com>
Date: Tue, 14 Dec 2021 09:04:59 +0800
Subject: [PATCH] Continue to run all actions if one action failed in curator

This patch also configure delete indices action before close indices.
more info check curator source code[0].

[0] https://github.com/elastic/curator/blob/ac5db911a1b4266908540bbaf44f697be85bb028/curator/cli.py#L217-L224

Change-Id: I9fb4b25514f5890adfac2f4007ec4a819fc9f566
Closes-Bug: #1954720
---
 .../elasticsearch-curator-actions.yml.j2      | 34 ++++++++++---------
 .../notes/bug-1954720-4fc48610a56f3e98.yaml   |  6 ++++
 2 files changed, 24 insertions(+), 16 deletions(-)
 create mode 100644 releasenotes/notes/bug-1954720-4fc48610a56f3e98.yaml

diff --git a/ansible/roles/elasticsearch/templates/elasticsearch-curator-actions.yml.j2 b/ansible/roles/elasticsearch/templates/elasticsearch-curator-actions.yml.j2
index 0ef452874b..3da7c5a722 100644
--- a/ansible/roles/elasticsearch/templates/elasticsearch-curator-actions.yml.j2
+++ b/ansible/roles/elasticsearch/templates/elasticsearch-curator-actions.yml.j2
@@ -1,26 +1,11 @@
 actions:
   1:
-    action: close
-    description: >-
-      Closes indices
-    options:
-      ignore_empty_list: True
-    filters:
-    - filtertype: pattern
-      kind: prefix
-      value: "{{ elasticsearch_curator_index_pattern }}"
-    - filtertype: age
-      source: name
-      direction: older
-      timestring: '%Y.%m.%d'
-      unit: days
-      unit_count: "{{ elasticsearch_curator_soft_retention_period_days }}"
-  2:
     action: delete_indices
     description: >-
       Delete indicies
     options:
       ignore_empty_list: True
+      continue_if_exception: True
     filters:
     - filtertype: pattern
       kind: prefix
@@ -31,3 +16,20 @@ actions:
       timestring: '%Y.%m.%d'
       unit: days
       unit_count: "{{ elasticsearch_curator_hard_retention_period_days }}"
+  2:
+    action: close
+    description: >-
+      Closes indices
+    options:
+      ignore_empty_list: True
+      continue_if_exception: True
+    filters:
+    - filtertype: pattern
+      kind: prefix
+      value: "{{ elasticsearch_curator_index_pattern }}"
+    - filtertype: age
+      source: name
+      direction: older
+      timestring: '%Y.%m.%d'
+      unit: days
+      unit_count: "{{ elasticsearch_curator_soft_retention_period_days }}"
diff --git a/releasenotes/notes/bug-1954720-4fc48610a56f3e98.yaml b/releasenotes/notes/bug-1954720-4fc48610a56f3e98.yaml
new file mode 100644
index 0000000000..61c42fadd4
--- /dev/null
+++ b/releasenotes/notes/bug-1954720-4fc48610a56f3e98.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Continue to run all actions if one action failed in Elasticsearch
+    curator.
+    `LP#1954720 <https://bugs.launchpad.net/kolla/+bug/1954720>`__