# Unable to Delete Stacks Stuck in "DELETE\_FAILED" State

## Problem

Delete operation for OpenStack stack fails, leaving the stack in a **DELETE FAILED** state.

{% tabs %}
{% tab title="None" %}

```none
$ openstack stack list | grep DELETE_FAILED| c33fdc4b-36bb-431e-aa18-c8fa2ae60eef | demo_stack | DELETE_FAILED | 2019-08-16T07:55:26Z | 2019-08-17T15:15:06Z |
```

{% endtab %}
{% endtabs %}

## Environment

* Platform9 Managed OpenStack - v3.6.0 and Higher
* Heat

## Cause

OpenStack Heat fails to delete a stack, leaving it in a **DELETE\_FAILED** state, because the request timed out.

## Resolution

1. Verify that all the servers in the stack which failed to delete are in a **DELETING** state.

{% tabs %}
{% tab title="None" %}

```none
$ openstack stack list  --all  | grep -i DELETE_FAILED | awk '{ print $2 }' | while read i; do openstack stack resource list -n 2 $i | grep -i server | awk '{ print $4}' | while read s; do openstack server show $s -c OS-EXT-STS:task_state -f value ; done; done
```

{% endtab %}
{% endtabs %}

2. Perform a state reset for all the servers in these stacks.

{% tabs %}
{% tab title="None" %}

```none
$ openstack stack list  --all  | grep -i DELETE_FAILED | awk '{ print $2 }' | while read i; do openstack stack resource list -n 2 $i | grep -i server | awk '{ print $4}' | while read s; do openstack server set --state active $s ; done; done
```

{% endtab %}
{% endtabs %}

3. Verify that there are no more servers in the **DELETING** state.

{% tabs %}
{% tab title="None" %}

```none
$ openstack stack list  --all  | grep -i DELETE_FAILED | awk '{ print $2 }' | while read i; do openstack stack resource list -n 2 $i | grep -i server | awk '{ print $4}' | while read s; do STATE=$(openstack server show $s -c OS-EXT-STS:task_state -f value); if [ "$STATE" == "deleting" ]; then echo $n; fi; done; done
```

{% endtab %}
{% endtabs %}

4. Delete the **DELETE\_FAILED** stacks.

{% tabs %}
{% tab title="None" %}

```none
$ openstack stack list  --all  | grep -i DELETE_FAILED | awk '{ print $2 }' | while read i; do openstack stack delete $i --yes; done
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmo/how-to/unable-to-delete-stacks-stuck-in-delete_failed-state.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
