deploy fix bug

This commit is contained in:
ZuoZuo 2026-04-07 17:18:59 +08:00
parent e69c17592e
commit b8905eaa3a

View File

@ -52,6 +52,12 @@ def sdk_body(resp: Any) -> dict[str, Any]:
return body return body
def should_retry_without_output_cos(exc: TencentCloudSDKException) -> bool:
code = str(getattr(exc, "code", "") or "")
message = str(getattr(exc, "message", "") or "")
return code == "ResourceNotFound.RoleNotFound" and "TAT_QCSLinkedRoleInUploadInvocation" in message
class CloudOperator: class CloudOperator:
def __init__(self, config: dict[str, Any], service_name: str, instance_id: str, release_id: str | None) -> None: def __init__(self, config: dict[str, Any], service_name: str, instance_id: str, release_id: str | None) -> None:
self.config = config self.config = config
@ -201,9 +207,25 @@ class CloudOperator:
payload["OutputCOSBucketUrl"] = self.cos_bucket_url() payload["OutputCOSBucketUrl"] = self.cos_bucket_url()
payload["OutputCOSKeyPrefix"] = f"{output_prefix}/{self.release_id or 'adhoc'}/{self.service_name}/{self.instance_id}" payload["OutputCOSKeyPrefix"] = f"{output_prefix}/{self.release_id or 'adhoc'}/{self.service_name}/{self.instance_id}"
return self._run_tat_command(payload, allow_retry_without_output_cos=bool(output_prefix))
def _run_tat_command(self, payload: dict[str, Any], allow_retry_without_output_cos: bool) -> str:
req = tat_models.RunCommandRequest() req = tat_models.RunCommandRequest()
req.from_json_string(json.dumps(payload)) req.from_json_string(json.dumps(payload))
resp = self.tat.RunCommand(req) try:
resp = self.tat.RunCommand(req)
except TencentCloudSDKException as exc:
if allow_retry_without_output_cos and should_retry_without_output_cos(exc):
log(
"TAT missing linked role TAT_QCSLinkedRoleInUploadInvocation, "
"retrying RunCommand without OutputCOSBucketUrl"
)
retry_payload = dict(payload)
retry_payload.pop("OutputCOSBucketUrl", None)
retry_payload.pop("OutputCOSKeyPrefix", None)
return self._run_tat_command(retry_payload, allow_retry_without_output_cos=False)
raise
body = sdk_body(resp) body = sdk_body(resp)
return str(body["InvocationId"]) return str(body["InvocationId"])