Skip to content

Commit 5165184

Browse files
committed
PullRequest: 40 fix: return None when delete non-exist resource
Merge branch fix_delete of [email protected]:oceanbase/OBShell-SDK-Python.git into master https://code.alipay.com/oceanbase/OBShell-SDK-Python/pull_requests/40 Signed-off-by: 阿绿 <[email protected]> * fix: return None when delete non-exist resource
1 parent 670e75d commit 5165184

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

obshell/service/client_v1.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ def remove(self, ip: str, port: int) -> task.DagDetailDTO:
236236
237237
Returns:
238238
Task detail as task.DagDetailDTO.
239+
return None if the agent is not in the uninitialized cluster.
239240
240241
Raises:
241242
OBShellHandleError: error message return by OBShell server.
@@ -256,7 +257,7 @@ def remove_sync(self, ip: str, port: int) -> task.DagDetailDTO:
256257
include the failed task detail and logs.
257258
"""
258259
dag = self.remove(ip, port)
259-
return self.wait_dag_succeed(dag.generic_id)
260+
return None if dag is None else self.wait_dag_succeed(dag.generic_id)
260261

261262
def config_observer(self,
262263
configs: dict,
@@ -1138,6 +1139,7 @@ def drop_tenant_sync(self, tenant_name: str, need_recycle: bool = False) -> task
11381139
11391140
Returns:
11401141
Task detail as task.DagDetailDTO.
1142+
Return None if tenant not exist.
11411143
11421144
Raises:
11431145
OBShellHandleError: error message return by OBShell server.
@@ -1237,14 +1239,15 @@ def delete_tenant_replica_sync(self, tenant_name: str, zones: List[str]) -> task
12371239
12381240
Returns:
12391241
Task detail as task.DagDetailDTO.
1242+
Return None if there is no replica on zones.
12401243
12411244
Raises:
12421245
OBShellHandleError: error message return by OBShell server.
12431246
TaskExecuteFailedError: raise when the task failed,
12441247
include the failed task detail and logs.
12451248
"""
12461249
dag = self.delete_tenant_replica(tenant_name, zones)
1247-
return self.wait_dag_succeed(dag.generic_id)
1250+
return None if dag is None else self.wait_dag_succeed(dag.generic_id)
12481251

12491252
def modify_tenant_replica(self, tenant_name: str, zone_list: List[tenant.ModifyReplicaParam]) -> task.DagDetailDTO:
12501253
"""Modifies tenant replicas.
@@ -1423,7 +1426,7 @@ def purge_recyclebin_tenant(self, object_or_original_name: str) -> task.DagDetai
14231426
f"/api/v1/recyclebin/tenant/{object_or_original_name}", "DELETE")
14241427
return self.__handle_task_ret_request(req)
14251428

1426-
def purge_recyclebin_tenant_sync(self, object_or_original_name: str) -> bool:
1429+
def purge_recyclebin_tenant_sync(self, object_or_original_name: str) -> task.DagDetailDTO:
14271430
"""Purges the tenant in recyclebin synchronously.
14281431
14291432
Args:
@@ -1433,7 +1436,8 @@ def purge_recyclebin_tenant_sync(self, object_or_original_name: str) -> bool:
14331436
The resource of the tenant won't be recycled.
14341437
14351438
Returns:
1436-
bool: True if success.
1439+
Task detail as task.DagDetailDTO.
1440+
Return None if the tenant not exist in recyclebin.
14371441
14381442
Raises:
14391443
OBShellHandleError: Error message return by OBShell server.

0 commit comments

Comments
 (0)