Skip to content

Commit

Permalink
Update pooler provider to throw an exception if the API returns non-OK
Browse files Browse the repository at this point in the history
Prior to this commit the API could fail and return `ok: false` but
floaty wouldn't recognize that as a failure.
This commit updates the pooler code to check for `ok` and raise and
error with the body of what the api returns if it's non-truthy.
  • Loading branch information
Brandon High committed Dec 5, 2019
1 parent 6954321 commit 17c1867
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/vmfloaty/pooler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ def self.modify(verbose, url, hostname, token, modify_hash)
end

res_body = JSON.parse(response.body)
res_body

if res_body['ok']
res_body
elsif response.status == 401
raise AuthError, "HTTP #{response.status}: The token provided could not authenticate to the pooler.\n#{res_body}"
else
raise ModifyError, "HTTP #{response.status}: Failed to modify VMs from the pooler vm/#{hostname}. #{res_body}"
end
end

def self.disk(verbose, url, hostname, token, disk)
Expand Down

0 comments on commit 17c1867

Please sign in to comment.