From fedba4dddf48cb5136ec56e0e88b8b871c3a67f1 Mon Sep 17 00:00:00 2001 From: Huangsm Date: Fri, 7 Apr 2017 21:51:08 -0400 Subject: [PATCH] ForceDelete Instance If nova config 'reclaim_instance_interval', a instance will be soft-deleted, that will cause a error, that volumes or other attached with the instance will cann't be deleted for its 'in-use' status. Now force_delete the instance, the error no longer occurs. Closes-Bug: #1564265 Change-Id: I4d1dd33b23d5882481f4d2c06107c3fb8c08cb93 --- heat/engine/clients/os/nova.py | 7 +++++-- heat/tests/openstack/nova/fakes.py | 2 ++ .../force-delete-nova-instance-6ed5d7fbd5b6f5fe.yaml | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/force-delete-nova-instance-6ed5d7fbd5b6f5fe.yaml diff --git a/heat/engine/clients/os/nova.py b/heat/engine/clients/os/nova.py index e0ccc44b17..02ccb7d7dc 100644 --- a/heat/engine/clients/os/nova.py +++ b/heat/engine/clients/os/nova.py @@ -445,9 +445,12 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers return False status = self.get_status(server) - if status in ("DELETED", "SOFT_DELETED"): + if status == 'DELETED': return True - if status == 'ERROR': + + if status == 'SOFT_DELETED': + self.client().servers.force_delete(server_id) + elif status == 'ERROR': fault = getattr(server, 'fault', {}) message = fault.get('message', 'Unknown') code = fault.get('code') diff --git a/heat/tests/openstack/nova/fakes.py b/heat/tests/openstack/nova/fakes.py index 0934dffc89..73825bf5af 100644 --- a/heat/tests/openstack/nova/fakes.py +++ b/heat/tests/openstack/nova/fakes.py @@ -287,6 +287,8 @@ class FakeSessionClient(base_client.SessionClient): assert set(body[action].keys()) == set(['host', 'block_migration', 'disk_over_commit']) + elif action == 'forceDelete': + assert body is not None else: raise AssertionError("Unexpected server action: %s" % action) return (resp, _body) diff --git a/releasenotes/notes/force-delete-nova-instance-6ed5d7fbd5b6f5fe.yaml b/releasenotes/notes/force-delete-nova-instance-6ed5d7fbd5b6f5fe.yaml new file mode 100644 index 0000000000..42c2c751ed --- /dev/null +++ b/releasenotes/notes/force-delete-nova-instance-6ed5d7fbd5b6f5fe.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - Force delete the nova instance. + If a resource is related with a nova instance which + is in 'SOFT_DELETED' status, the resource can't be + deleted, when nova config 'reclaim_instance_interval'. + so, force-delete the nova instance, and then all the + resources are related with the instance would be + processed properly.