|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | import json |
| 16 | +import time |
16 | 17 | from typing import Any |
17 | 18 | from uuid import uuid4 |
18 | 19 |
|
@@ -60,9 +61,11 @@ def __init__( |
60 | 61 | if not vefaas_endpoint: |
61 | 62 | self.vefaas_endpoint = self._get_vefaas_endpoint() |
62 | 63 |
|
63 | | - if not self.vefaas_endpoint.startswith( |
64 | | - "http" |
65 | | - ) and not self.vefaas_endpoint.startswith("https"): |
| 64 | + if ( |
| 65 | + self.vefaas_endpoint |
| 66 | + and not self.vefaas_endpoint.startswith("http") |
| 67 | + and not self.vefaas_endpoint.startswith("https") |
| 68 | + ): |
66 | 69 | raise ValueError( |
67 | 70 | f"Invalid endpoint: {vefaas_endpoint}. The endpoint must start with `http` or `https`." |
68 | 71 | ) |
@@ -92,12 +95,13 @@ def _get_vefaas_endpoint( |
92 | 95 | raise ValueError( |
93 | 96 | f"VeFaaS CloudAPP with application_id `{self.vefaas_application_id}` or application_name `{self.vefaas_application_name}` not found." |
94 | 97 | ) |
95 | | - cloud_resource = json.loads(app["CloudResource"]) |
96 | 98 |
|
97 | 99 | try: |
| 100 | + cloud_resource = json.loads(app["CloudResource"]) |
98 | 101 | vefaas_endpoint = cloud_resource["framework"]["url"]["system_url"] |
99 | 102 | except Exception as e: |
100 | | - raise ValueError(f"VeFaaS cloudAPP could not get endpoint. Error: {e}") |
| 103 | + logger.warning(f"VeFaaS cloudAPP could not get endpoint. Error: {e}") |
| 104 | + vefaas_endpoint = "" |
101 | 105 | return vefaas_endpoint |
102 | 106 |
|
103 | 107 | def _get_vefaas_application_id_by_name(self) -> str: |
@@ -167,7 +171,18 @@ def delete_self( |
167 | 171 |
|
168 | 172 | vefaas_client = VeFaaS(access_key=volcengine_ak, secret_key=volcengine_sk) |
169 | 173 | vefaas_client.delete(self.vefaas_application_id) |
170 | | - print(f"Cloud app {self.vefaas_application_id} is deleting...") |
| 174 | + print( |
| 175 | + f"Cloud app {self.vefaas_application_id} delete request has been sent to VeFaaS" |
| 176 | + ) |
| 177 | + while True: |
| 178 | + try: |
| 179 | + id = self._get_vefaas_application_id_by_name() |
| 180 | + if not id: |
| 181 | + break |
| 182 | + time.sleep(3) |
| 183 | + except Exception as _: |
| 184 | + break |
| 185 | + print("Delete application done.") |
171 | 186 |
|
172 | 187 | async def message_send( |
173 | 188 | self, message: str, session_id: str, user_id: str, timeout: float = 600.0 |
|
0 commit comments