deploy fix bug
This commit is contained in:
parent
e69c17592e
commit
b8905eaa3a
@ -52,6 +52,12 @@ def sdk_body(resp: Any) -> dict[str, Any]:
|
||||
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:
|
||||
def __init__(self, config: dict[str, Any], service_name: str, instance_id: str, release_id: str | None) -> None:
|
||||
self.config = config
|
||||
@ -201,9 +207,25 @@ class CloudOperator:
|
||||
payload["OutputCOSBucketUrl"] = self.cos_bucket_url()
|
||||
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.from_json_string(json.dumps(payload))
|
||||
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)
|
||||
return str(body["InvocationId"])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user