vultr / ansible-collection-vultr

GNU General Public License v3.0
28 stars 17 forks source link

fix wait for state to be more strict #89

Closed resmo closed 1 year ago

resmo commented 1 year ago

We see a failing integration tests while trying to delete an instance. The code should have waited for a server_state not in "locked", "none" but did not, this is unexpected.

Description

a task before we got:

"server_status": "none"

after we got:

fatal: [testhost]: FAILED! => {"changed": false, "fetch_url_info": {"body": "{\"error\":\"Unable to destroy server: Unable to remove VM: Server is currently locked\",\"status\":500}", "connection": "close", "content-type": "application/json", "date": "Tue, 26 Sep 2023 04:15:10 GMT", "msg": "HTTP Error 500: Internal Server Error", "server": "nginx", "status": 500, "strict-transport-security": "max-age=63072000", "transfer-encoding": "chunked", "url": "https://api.vultr.com/v2/instances/8ba702b8-ddf2-4e18-9e0f-c288f3c66569", "x-content-type-options": "nosniff", "x-frame-options": "DENY", "x-robots-tag": "noindex,noarchive", "x-user": "ansible+opensource@vultr.com"}, "msg": "Failure while calling the Vultr API v2 with DELETE for \"/instances/8ba702b8-ddf2-4e18-9e0f-c288f3c66569\"."}

so I assume the api returned locked but if we had one of these states, why is the code not waiting? was the key not returned? resource was not queries?

That is why I refactored the code a bit to be more strict for these cases and also wait

Related Issues

Checklist:

codecov-commenter commented 1 year ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (0ca525d) 90.42% compared to head (5ca5c47) 91.58%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #89 +/- ## ========================================== + Coverage 90.42% 91.58% +1.16% ========================================== Files 31 33 +2 Lines 898 1141 +243 Branches 147 168 +21 ========================================== + Hits 812 1045 +233 - Misses 36 44 +8 - Partials 50 52 +2 ``` [see 3 files with indirect coverage changes](https://app.codecov.io/gh/vultr/ansible-collection-vultr/pull/89/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vultr)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.