Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mamercad authored May 22, 2024
2 parents 461a87a + 6f7269b commit 1136ea4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
19 changes: 11 additions & 8 deletions plugins/modules/digital_ocean_droplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ def wait_action(self, droplet_id, desired_action_data):
json_data = response.json
status_code = response.status_code
message = json_data.get("message", "no error message")

# action and other fields may not be available in case of error, check first
# will catch Not Authorized due to restrictive Scopes
if status_code >= 400:
self.module.fail_json(
changed=False,
msg=DODroplet.failure_message["failed_to"].format(
"post", "action", status_code, message
),
)

action = json_data.get("action", None)
action_id = action.get("id", None)
action_status = action.get("status", None)
Expand All @@ -633,14 +644,6 @@ def wait_action(self, droplet_id, desired_action_data):
),
)

if status_code >= 400:
self.module.fail_json(
changed=False,
msg=DODroplet.failure_message["failed_to"].format(
"post", "action", status_code, message
),
)

# Keep checking till it is done or times out
self.wait_check_action(droplet_id, action_id)

Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1136ea4

Please sign in to comment.