# Delete old indexes via Index lifecycle policy doesn't work because of shards error

**URL:** <https://discuss.elastic.co/t/delete-old-indexes-via-index-lifecycle-policy-doesnt-work-because-of-shards-error/262619>\
**Category:** Kibana\
**Tags:** ilm-index-lifecycle-management\
**Created:** [January 29, 2021, 9:20am UTC](https://discuss.elastic.co/t/delete-old-indexes-via-index-lifecycle-policy-doesnt-work-because-of-shards-error/262619 "2021-01-29T09:20:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mfa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mfa/32/87041_2.png) [@mfa](https://discuss.elastic.co/u/mfa)\
**Post date:** [January 29, 2021, 9:20am UTC](https://discuss.elastic.co/t/delete-old-indexes-via-index-lifecycle-policy-doesnt-work-because-of-shards-error/262619/1 "2021-01-29T09:20:25Z")

</div>

I have read through the docs and some posts here, however my delete policy is not working as expected. Here is my policy:

```auto
    PUT _ilm/policy/deleting_policy
    {
      "policy": {
        "phases": {
          "hot": {
            "min_age": "0ms",
            "actions": {
              "rollover": {
                "max_size": "50gb"
              },
              "set_priority": {
                "priority": 100
              }
            }
          },
          "delete": {
            "min_age": "30d",
            "actions": {
              "delete": {
                "delete_searchable_snapshot": true
              }
            }
          }
        }
      }
    }

```

And the index setting is as following:

```auto
    {
      "index.blocks.read_only_allow_delete": "false",
      "index.query.default_field": [
        "*"
      ],
      "index.refresh_interval": "1s",
      "index.write.wait_for_active_shards": "1",
      "index.lifecycle.name": "deleting_policy",
      "index.lifecycle.rollover_alias": "myindex-alias",
      "index.priority": "100",
      "index.number_of_replicas": "1"
    }

```

Here is some parts of the index settings regarding shards (which was the default setting):

```auto
{
  "settings": {
    "index": {
      "lifecycle": {
        "name": "deleting_policy",
        "rollover_alias": "trafficinfo-alias"
      },
      "number_of_shards": "1",
      "provided_name": "trafficinfo-000001",
      "creation_date": "1605959828528",
      "priority": "100",
      "number_of_replicas": "1",
      "uuid": "qc0PGsh-TTmcXSN-LMW6XQ",
      "version": {
        "created": "7090399"
      }
    }
  },
####
"number_of_routing_shards": "1",
      "write": {
        "wait_for_active_shards": "1"
      },
####
"allocation": {
          "enable": "all",
          "total_shards_per_node": "-1"
        }
####
"allocation": {
        "max_retries": "5",
        "existing_shards_allocator": "gateway_allocator"
      }

```

The delete-policy started to apply on an index (myindex1-000001) with size:357gb and it has created a rollover index: myindex1-000002 with status " **index is red; not all primary shards are active**"  
and myindex1-000001 lifecycle action status became "**waiting for [DEFAULT] shards to become active, but only [0] are active**"

I also see under elastic-cloud deployment this error:  
**"Unhealthy deployment**  
**7 Elasticsearch shards unavailable"**  
what is it missing here?

The java application is pointing to index name: myindex1-000001 how it's gonna know about the rollover index with name "myindex1-000002"?

I'm wondering what I am missing here that the deleting policy doesn't work well?

My instance went out of the storage so I need to remove some data as soon as possible in order to get back my instance to healthy status.  
Any help would be appreciated.

---

<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:** [January 29, 2021, 4:24pm UTC](https://discuss.elastic.co/t/delete-old-indexes-via-index-lifecycle-policy-doesnt-work-because-of-shards-error/262619/2 "2021-01-29T16:24:03Z")

</div>

Could you share the output of `GET /<your-index>/_ilm/explain?human` here?

---

<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 26, 2021, 4:24pm UTC](https://discuss.elastic.co/t/delete-old-indexes-via-index-lifecycle-policy-doesnt-work-because-of-shards-error/262619/3 "2021-02-26T16:24:13Z")

</div>

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