# ILM not executing DELETE phase

**URL:** <https://discuss.elastic.co/t/ilm-not-executing-delete-phase/254776>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [November 9, 2020, 3:20pm UTC](https://discuss.elastic.co/t/ilm-not-executing-delete-phase/254776 "2020-11-09T15:20:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![radw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radw/32/53012_2.png) [@radw](https://discuss.elastic.co/u/radw)\
**Post date:** [November 9, 2020, 3:20pm UTC](https://discuss.elastic.co/t/ilm-not-executing-delete-phase/254776/1 "2020-11-09T15:20:34Z")

</div>

Hi all!  
I'm using ELK stack v7.6.2 and v7.4.0. The same behaviour is happening on both versions.  
I've created an **ILM** policy together with timeseries indices and a template for an index.  
My **ILM** is rolling over my index at 40GB or 30 days, the template creates a new index afterwards and sets it as the write index.  
I use an index alias to write to these time series indices and all goes well.  
I'm trying to achieve the deletion of these indices 91 days after the rollover but this phase of the **ILM** never gets to be triggered.  
At first I've created the **ILM** without the delete phase and I've added it afterwards but I guess this should not be a problem as I've played around with the rollover phase multiple times and every time I've got the desired result(eg: changing **max\_size** or **max\_age** for rollover).  
My policy settings are as follows:

```auto
   {
   "policy_index_infra" : {
     "version" : 3,
     "modified_date" : "2020-10-02T04:53:07.209Z",
     "policy" : {
       "phases" : {
         "hot" : {
           "min_age" : "0ms",
           "actions" : {
             "rollover" : {
               "max_size" : "40gb",
               "max_age" : "30d"
             }
           }
         },
         "delete" : {
           "min_age" : "91d",
           "actions" : {
             "delete" : { }
           }
         }
       }
     }
   }
 }

```

The index **ILM** which should have been deleted after 91days from rollover is the following:

```auto
 {
   "indices" : {
     "index_infra-2020-07-30-000068" : {
       "index" : "index_infra-2020-07-30-000068",
       "managed" : true,
       "policy" : "policy_index_infra",
       "lifecycle_date_millis" : 1596303675069,
       "age" : "99.88d",
       "phase" : "completed",
       "phase_time_millis" : 1596303676222,
       "action" : "completed",
       "action_time_millis" : 1596303676222,
       "step" : "completed",
       "step_time_millis" : 1596303676222,
       "phase_execution" : {
         "policy" : "policy_index_infra",
         "version" : 2,
         "modified_date_in_millis" : 1583359226294
       }
     }
   }
 }

```

What I've tried:  
I've created a new **ILM** policy with only the delete phase and it triggered correctly after a few minutes but it was based on creation time not on rollover time since I didn't have the rollover set up in that **ILM** policy.  
I've waited even 112 days and still nothing happened so I've manually deleted the index.  
I'm at dead end here since I've read every article on this forum and I've come to no conclusion.  
Any help about where to look or what to test would be appreciated.

Cheers,  
Radu

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [November 9, 2020, 4:38pm UTC](https://discuss.elastic.co/t/ilm-not-executing-delete-phase/254776/2 "2020-11-09T16:38:36Z")

</div>

Hi Radu,

I notice that you mentioned:

> At first I've created the **ILM** without the delete phase and I've added it afterwards but I guess this should not be a problem ..

This is actually what happened, before the policy had the `delete` phase added, this index moved to the terminal step (completed/completed/completed). To fix this you can do:

```auto
POST /_ilm/move/index_infra-2020-07-30-000068
{
  "current_step": { 
    "phase": "completed",
    "action": "completed",
    "name": "completed"
  },
  "next_step": { 
    "phase": "delete",
    "action": "delete",
    "name": "delete"
  }
}

```

This behavior is understandably less than ideal, which is why this behavior has been rectified in [https://github.com/elastic/elasticsearch/pull/51631](https://github.com/elastic/elasticsearch/pull/51631) (7.7+), where policies will stop in the last configured phase, so a delete phase added after will always be executed.

Hope this helps.

---

<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:** [December 7, 2020, 4:38pm UTC](https://discuss.elastic.co/t/ilm-not-executing-delete-phase/254776/3 "2020-12-07T16:38:36Z")

</div>

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