Skip to content

Commit bca935a

Browse files
committed
PullRequest: 59 fix: verification failed when cluster join single
Merge branch fix_join of git@code.alipay.com:oceanbase/OBShell-SDK-Python.git into master https://code.alipay.com/oceanbase/OBShell-SDK-Python/pull_requests/59 Signed-off-by: 雪染 <xin.sunhx@oceanbase.com> * fix: verification failed when cluster join single * chore: deep copy auth
1 parent fc54d25 commit bca935a

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

obshell/service/client_v1.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,21 @@ def join(self, ip: str, port: int, zone: str, agent_password: str = None) -> tas
196196
Raises:
197197
OBShellHandleError: Error message return by OBShell server.
198198
"""
199-
if self.server == f"{ip}:{port}":
200-
c = self
201-
else:
202-
c = ClientV1(ip, port, PasswordAuth(agent_password=agent_password))
203-
req = c.create_request("/api/v1/agent/join", "POST",
204-
data={
205-
"agentInfo": {"ip": self.host, "port": self.port},
206-
"zoneName": zone,
207-
"masterPassword": self._auth.agent_password
208-
})
209-
dag = c.__handle_task_ret_request(req)
210-
self._auth.reset_method()
199+
try:
200+
c = ClientV1(ip, port)
201+
auth = self._get_auth()
202+
c._set_auth(copy.deepcopy(auth))
203+
if agent_password is not None:
204+
c._set_auth(PasswordAuth(agent_password=agent_password))
205+
req = c.create_request("/api/v1/agent/join", "POST",
206+
data={
207+
"agentInfo": {"ip": self.host, "port": self.port},
208+
"zoneName": zone,
209+
"masterPassword": self._auth.agent_password
210+
})
211+
dag = c.__handle_task_ret_request(req)
212+
finally:
213+
auth.reset_method()
211214
return dag
212215

213216
def join_sync(self, ip: str, port: int, zone: str, agent_password: str = None) -> task.DagDetailDTO:

0 commit comments

Comments
 (0)