Skip to content

Commit

Permalink
fix cleanup case where vm is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
osallou committed Mar 6, 2019
1 parent ce45cf0 commit 93240eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions os_vm_expire/cmd/cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ def delete_vm(instance_id, project_id, token):
'Accept': 'application/json'
}
r = requests.delete(nova_url + '/servers/' + instance_id, headers=headers)
if r.status_code == 404:
LOG.info('DELETE:VmNotFound:' + str(instance_id) + ':' + str(project_id))
return True
if r.status_code != 204:
LOG.error('Failed to delete instance ' + str(instance_id))
LOG.error('DELETE:Error:Failed to delete instance ' + str(instance_id))
return False
else:
LOG.info('DELETE:' + str(instance_id) + ':' + str(project_id))
LOG.info('DELETE:deleted:' + str(instance_id) + ':' + str(project_id))
return True


Expand Down Expand Up @@ -272,7 +275,7 @@ def check(started_at):
except Exception as e:
LOG.exception("expiration deletion error: " + str(e))
repositories.rollback()
send_email(entity, token, delete=True)
send_email(entity, token, delete=True)


class CleanerServer(service.Service):
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/fix_vm_notfound-2bdd03e6b0f1ceb4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fix case where VM is not found, email was sent anyway
If VM does not exists anymore (error case), consider deletion as ok

0 comments on commit 93240eb

Please sign in to comment.