Skip to content

Commit 8907bac

Browse files
committed
add vefaas deploy fail log
1 parent d55009c commit 8907bac

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

veadk/integrations/ve_faas/ve_faas.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,18 @@ def _release_application(self, app_id: str):
195195
time.sleep(10)
196196
status, full_response = self._get_application_status(app_id)
197197

198-
assert status == "deploy_success", (
199-
f"Release application failed. Response: {full_response}"
200-
)
201-
202-
cloud_resource = full_response["Result"]["CloudResource"]
203-
cloud_resource = json.loads(cloud_resource)
204-
205-
url = cloud_resource["framework"]["url"]["system_url"]
206-
207-
return url
198+
if status == "deploy_success":
199+
cloud_resource = full_response["Result"]["CloudResource"]
200+
cloud_resource = json.loads(cloud_resource)
201+
url = cloud_resource["framework"]["url"]["system_url"]
202+
return url
203+
else:
204+
logger.error(f"Release application failed: {full_response}")
205+
logs = self._get_application_logs(app_id=app_id)
206+
log_text = ""
207+
for log_line in logs:
208+
log_text += log_line.strip() + "\n"
209+
raise Exception(f"Release application failed. Logs:\n{log_text}")
208210

209211
def _get_application_status(self, app_id: str):
210212
response = ve_request(
@@ -707,3 +709,21 @@ def deploy_image(
707709
logger.info(f"VeFaaS application {name} with ID {app_id} deployed on {url}.")
708710

709711
return url, app_id, function_id
712+
713+
def _get_application_logs(self, app_id: str) -> list[str]:
714+
response = _ = ve_request(
715+
request_body={"Id": app_id, "Limit": 99999, "RevisionNumber": 1},
716+
action="GetApplicationRevisionLog",
717+
ak=self.ak,
718+
sk=self.sk,
719+
service="vefaas",
720+
version="2021-03-03",
721+
region="cn-beijing",
722+
host="open.volcengineapi.com",
723+
)
724+
725+
try:
726+
logs = response["Result"]["LogLines"]
727+
return logs
728+
except Exception as _:
729+
raise ValueError(f"Get application log failed. Response: {response}")

0 commit comments

Comments
 (0)