Skip to content

Commit 26479c6

Browse files
author
Brandon High
committed
Update pooler provider to throw an exception if the API returns non-OK
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.
1 parent d8dd088 commit 26479c6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/vmfloaty/pooler.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ def self.modify(verbose, url, hostname, token, modify_hash)
7272
end
7373

7474
res_body = JSON.parse(response.body)
75-
res_body
75+
76+
if res_body['ok']
77+
res_body
78+
elsif response.status == 401
79+
raise AuthError, "HTTP #{response.status}: The token provided could not authenticate to the pooler.\n#{res_body}"
80+
else
81+
raise ModifyError, "HTTP #{response.status}: Failed to modify VMs from the pooler vm/#{hostname}. #{res_body}"
82+
end
7683
end
7784

7885
def self.disk(verbose, url, hostname, token, disk)

0 commit comments

Comments
 (0)