From 538461b69826dbf1a3b8bcaae394fd94240ae0ca Mon Sep 17 00:00:00 2001 From: Ali Naqvi Date: Wed, 22 May 2024 00:11:05 +0800 Subject: [PATCH] chore: fix build service return code validation --- src/placeos-core/driver_manager.cr | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/placeos-core/driver_manager.cr b/src/placeos-core/driver_manager.cr index e6b7619d..4086e3a2 100644 --- a/src/placeos-core/driver_manager.cr +++ b/src/placeos-core/driver_manager.cr @@ -190,12 +190,13 @@ module PlaceOS::Core Log.debug { {message: "Invoked request: URI: #{link} . Server response: #{rep.status_code}", server_resp: rep.body} } rep end + raise "Returned invalid response code: #{resp.status_code}, #{link}, resp: #{resp.body}" unless resp.success? || resp.status_code == 303 task = JSON.parse(resp.body).as_h - break if task["state"] != "pending" + break if task["state"].in?("cancelled", "error", "done") sleep 5 end - if resp.success? && task["state"] == "error" + if resp.success? && task["state"].in?("cancelled", "error") raise task["message"].to_s end raise "Build API end-point #{link} returned invalid response code #{resp.status_code}, expected 303" unless resp.status_code == 303