From 45e8f235882508a032df0321ecf66d54c9b6242f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Fri, 5 Jul 2024 15:30:57 +0800 Subject: [PATCH 01/12] fix KubernetesClient --- common/ssh_client/kubernetes_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/ssh_client/kubernetes_client.py b/common/ssh_client/kubernetes_client.py index d6bc6ea9..14c169de 100644 --- a/common/ssh_client/kubernetes_client.py +++ b/common/ssh_client/kubernetes_client.py @@ -30,7 +30,7 @@ def __init__(self, context=None, node=None): self.container_name = self.node.get("container_name") or "observer" config_file = self.node.get("kubernetes_config_file") if config_file is None or config_file == "": - config.kube_config.load_kube_config() + config.load_kube_config() else: config.kube_config.load_kube_config(config_file=config_file) self.client = client.CoreV1Api() From 92b89048bf4874ee8a8aa8da0c306883c50fec78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Fri, 5 Jul 2024 18:09:26 +0800 Subject: [PATCH 02/12] fix KubernetesClient --- common/ssh_client/kubernetes_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/ssh_client/kubernetes_client.py b/common/ssh_client/kubernetes_client.py index 14c169de..878f8611 100644 --- a/common/ssh_client/kubernetes_client.py +++ b/common/ssh_client/kubernetes_client.py @@ -30,8 +30,10 @@ def __init__(self, context=None, node=None): self.container_name = self.node.get("container_name") or "observer" config_file = self.node.get("kubernetes_config_file") if config_file is None or config_file == "": + context.stdio.verbose("KubernetesClient load_kube_config from default config file in cluster.") config.load_kube_config() else: + context.stdio.verbose("KubernetesClient load_kube_config from {0}".format(config_file)) config.kube_config.load_kube_config(config_file=config_file) self.client = client.CoreV1Api() except Exception as e: From 2cec320f47d71bba6c9d434b2e99ab135404be33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Tue, 9 Jul 2024 10:33:27 +0800 Subject: [PATCH 03/12] fix KubernetesClient --- .github/workflows/build_package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index d1af9938..55bf36e4 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -7,6 +7,7 @@ on: push: branches: - master + - 2.3.0-qulei env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true From fecc4043d124a8dbb6a4296bee3ea99044d0a98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Tue, 9 Jul 2024 10:56:41 +0800 Subject: [PATCH 04/12] fix KubernetesClient --- common/ssh_client/kubernetes_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/ssh_client/kubernetes_client.py b/common/ssh_client/kubernetes_client.py index 878f8611..251ab839 100644 --- a/common/ssh_client/kubernetes_client.py +++ b/common/ssh_client/kubernetes_client.py @@ -31,7 +31,7 @@ def __init__(self, context=None, node=None): config_file = self.node.get("kubernetes_config_file") if config_file is None or config_file == "": context.stdio.verbose("KubernetesClient load_kube_config from default config file in cluster.") - config.load_kube_config() + config.load_incluster_config() else: context.stdio.verbose("KubernetesClient load_kube_config from {0}".format(config_file)) config.kube_config.load_kube_config(config_file=config_file) From bfa4c30e966e698764809fbf7ec2bca312d6ad40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Tue, 9 Jul 2024 14:46:30 +0800 Subject: [PATCH 05/12] fix "nodename nor servname provided" --- common/ssh_client/ssh.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/ssh_client/ssh.py b/common/ssh_client/ssh.py index a78e9e6f..92fa949e 100644 --- a/common/ssh_client/ssh.py +++ b/common/ssh_client/ssh.py @@ -35,10 +35,13 @@ def __init__(self, context=None, node=None): def local_ip(self): local_ip_list = [] - hostname = socket.gethostname() - addresses = socket.getaddrinfo(hostname, None) - for address in addresses: - local_ip_list.append(address[4][0]) + try: + hostname = socket.gethostname() + addresses = socket.getaddrinfo(hostname, None) + for address in addresses: + local_ip_list.append(address[4][0]) + except Exception as e: + self.stdio.watn("get local ip warn: {} . Set local_ip is 127.0.0.1".format(e)) local_ip_list.append('127.0.0.1') return list(set(local_ip_list)) From b1b9f64fb9ebf723d1b108e48564b8ee5d730f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Tue, 9 Jul 2024 15:21:54 +0800 Subject: [PATCH 06/12] delete build tag --- .github/workflows/build_package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index 55bf36e4..d6a8be8c 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -7,7 +7,7 @@ on: push: branches: - master - - 2.3.0-qulei + env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true From d77d3c5a9e36959ccccaf4fa1886bb09d8051c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Tue, 9 Jul 2024 17:56:23 +0800 Subject: [PATCH 07/12] fix ssh stdio print --- common/ssh_client/ssh.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/ssh_client/ssh.py b/common/ssh_client/ssh.py index 92fa949e..d39c8a63 100644 --- a/common/ssh_client/ssh.py +++ b/common/ssh_client/ssh.py @@ -29,6 +29,9 @@ def __init__(self, context=None, node=None): raise Exception("SshHelper init error: node is None") self.node = node self.context = context + self.stdio = None + if self.context is not None: + self.stdio = self.context.stdio self.ssh_type = node.get("ssh_type") or "remote" self.client = None self.init() @@ -41,7 +44,8 @@ def local_ip(self): for address in addresses: local_ip_list.append(address[4][0]) except Exception as e: - self.stdio.watn("get local ip warn: {} . Set local_ip is 127.0.0.1".format(e)) + if self.stdio is not None: + self.stdio.warn("get local ip warn: {} . Set local_ip Is 127.0.0.1".format(e)) local_ip_list.append('127.0.0.1') return list(set(local_ip_list)) From d66ebf91960abb069d38a224f3269b3bab85def2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Wed, 10 Jul 2024 16:38:53 +0800 Subject: [PATCH 08/12] fix remote_client --- common/ssh_client/remote_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/ssh_client/remote_client.py b/common/ssh_client/remote_client.py index a24146fd..6bcfdaf6 100644 --- a/common/ssh_client/remote_client.py +++ b/common/ssh_client/remote_client.py @@ -42,7 +42,7 @@ def __init__(self, context, node): self._sftp_client = None self._disabled_rsa_algorithms = None self.host_ip = self.node.get("ip") - self.username = self.node.get("username") + self.username = self.node.get("ssh_username") self.ssh_port = self.node.get("ssh_port") self.need_password = True self.password = self.node.get("ssh_password") From 9d77f25da1e0390e406bf671d1822c677431a108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Wed, 10 Jul 2024 20:26:22 +0800 Subject: [PATCH 09/12] fix example operator.yml --- example/operator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/operator.yml b/example/operator.yml index 05c997ee..3409639f 100644 --- a/example/operator.yml +++ b/example/operator.yml @@ -29,7 +29,7 @@ obcluster: container_name: observer home_path: /home/admin/oceanbase data_dir: /home/admin/oceanbase/store - redo_Dir: /home/admin/oceanbase/store + redo_dir: /home/admin/oceanbase/store ip: xx.xx.xx.xx global: # if running obdiag in kubernetes, please delete the kubernetes_config_file From 848531e17ea7555e3ba1d375aed24ae4f9bab3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Mon, 15 Jul 2024 15:02:28 +0800 Subject: [PATCH 10/12] fix get_obproxy_version on rca --- handler/rca/rca_handler.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/handler/rca/rca_handler.py b/handler/rca/rca_handler.py index 51da1a95..993bd173 100644 --- a/handler/rca/rca_handler.py +++ b/handler/rca/rca_handler.py @@ -99,12 +99,7 @@ def __init__(self, context): obproxy_version = "" try: if len(context_obproxy_nodes) > 0: - obproxy_version = get_obproxy_version( - True, - context_obproxy_nodes[0]["ssher"], - context_obproxy_nodes[0]["home_path"], - self.stdio, - ) + obproxy_version = get_obproxy_version(context) except Exception as e: self.stdio.warn("RCAHandler.init Failed to get obproxy version. Error:{0}".format(e)) if obproxy_version != "": From f9d808025188a719cb1a8a453e57092a718603cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Mon, 15 Jul 2024 19:28:51 +0800 Subject: [PATCH 11/12] fix : cat with grep >> grep -e --- handler/gather/gather_log.py | 7 ++++--- handler/gather/gather_obproxy_log.py | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/handler/gather/gather_log.py b/handler/gather/gather_log.py index f368cab5..6001296a 100644 --- a/handler/gather/gather_log.py +++ b/handler/gather/gather_log.py @@ -304,7 +304,6 @@ def __pharse_log(self, ssh_client, home_path, log_name, gather_path): if type(self.grep_options) == str: grep_cmd = "grep -e '{grep_options}' {log_dir}/{log_name} >> {gather_path}/{log_name} ".format(grep_options=self.grep_options, gather_path=gather_path, log_name=log_name, log_dir=log_path) elif type(self.grep_options) == list and len(self.grep_options) > 0: - grep_litter_cmd = "" for grep_option in self.grep_options: if type(grep_option) != str: self.stdio.error('The grep args must be string or list of strings, but got {0}'.format(type(grep_option))) @@ -312,8 +311,10 @@ def __pharse_log(self, ssh_client, home_path, log_name, gather_path): elif grep_option == "": self.stdio.warn('The grep args must be string or list of strings, but got ""') continue - grep_litter_cmd += "| grep -e '{0}'".format(grep_option) - grep_cmd = "cat {log_dir}/{log_name} {grep_options} >> {gather_path}/{log_name} ".format(grep_options=grep_litter_cmd, gather_path=gather_path, log_name=log_name, log_dir=log_path) + if grep_cmd == "": + grep_cmd = "grep -e '{0}' ".format(grep_option) + "{log_dir}/{log_name}".format(log_name=log_name, log_dir=log_path) + grep_cmd += "| grep -e '{0}'".format(grep_option) + grep_cmd += " >> {gather_path}/{log_name} ".format(gather_path=gather_path, log_name=log_name, log_dir=log_path) self.stdio.verbose('grep files, run cmd = [{0}]'.format(grep_cmd)) ssh_client.exec_cmd(grep_cmd) else: diff --git a/handler/gather/gather_obproxy_log.py b/handler/gather/gather_obproxy_log.py index efd54b37..9f7b60fd 100644 --- a/handler/gather/gather_obproxy_log.py +++ b/handler/gather/gather_obproxy_log.py @@ -263,7 +263,6 @@ def __pharse_log(self, ssh_client, home_path, log_name, gather_path): if type(self.grep_args) == str: grep_cmd = "grep -e '{grep_args}' {log_dir}/{log_name} >> {gather_path}/{log_name} ".format(grep_args=self.grep_args, gather_path=gather_path, log_name=log_name, log_dir=log_path) elif type(self.grep_args) == list and len(self.grep_args) > 0: - grep_litter_cmd = "" for grep_arg in self.grep_args: if type(grep_arg) != str: self.stdio.error('The grep args must be string or list of strings, but got {0}'.format(type(grep_arg))) @@ -271,9 +270,11 @@ def __pharse_log(self, ssh_client, home_path, log_name, gather_path): elif grep_arg == "": self.stdio.warn('The grep args must be string or list of strings, but got ""') continue - grep_litter_cmd += "| grep -e '{0}'".format(grep_arg) - - grep_cmd = "cat {log_dir}/{log_name} {grep_args} >> {gather_path}/{log_name} ".format(grep_args=grep_litter_cmd, gather_path=gather_path, log_name=log_name, log_dir=log_path) + if grep_cmd == "": + grep_cmd = "grep -e '{0}' ".format(grep_arg) + "{log_dir}/{log_name}".format(log_name=log_name, log_dir=log_path) + continue + grep_cmd += "| grep -e '{0}'".format(grep_arg) + grep_cmd += " >> {log_dir}/{log_name}".format(log_name=log_name, log_dir=log_path) self.stdio.verbose("grep files, run cmd = [{0}]".format(grep_cmd)) ssh_client.exec_cmd(grep_cmd) else: From 07e2dce2b199c1d1281743eb1f3e2bd3873d6c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Tue, 16 Jul 2024 11:20:57 +0800 Subject: [PATCH 12/12] fix stack --- common/command.py | 2 +- handler/gather/gather_obstack2.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/command.py b/common/command.py index a045a6ae..2af96419 100644 --- a/common/command.py +++ b/common/command.py @@ -99,7 +99,7 @@ def upload_file(ssh_client, local_path, remote_path, stdio=None): """ stdio.verbose("Please wait a moment, upload file to server {0}, local file path {1}, remote file path {2}".format(ssh_client.get_name(), local_path, remote_path)) try: - ssh_client.upload(local_path, remote_path) + ssh_client.upload(remote_path, local_path) except Exception as e: stdio.error("Upload File Failed error: {0}".format(e)) diff --git a/handler/gather/gather_obstack2.py b/handler/gather/gather_obstack2.py index 2ca09f70..9b0e8084 100644 --- a/handler/gather/gather_obstack2.py +++ b/handler/gather/gather_obstack2.py @@ -201,7 +201,7 @@ def __chmod_obstack2(self, ssh_client): def __is_obstack_exists(self, ssh_client): cmd = "test -e {file} && echo exists".format(file=const.OBSTACK2_DEFAULT_INSTALL_PATH) - stdout = ssh_client.exec_cmd(cmd)[0] + stdout = ssh_client.exec_cmd(cmd) if stdout == 'exists': return False else: