From 5e8cea2596d68b2b140b7b0d886dd0367dab58f5 Mon Sep 17 00:00:00 2001 From: wayyoungboy <35394786+wayyoungboy@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:06:27 +0800 Subject: [PATCH] fix get_obproxy_version on rca (#330) * fix KubernetesClient * fix KubernetesClient * fix KubernetesClient * fix KubernetesClient * fix "nodename nor servname provided" * delete build tag * fix ssh stdio print * fix remote_client * fix example operator.yml * fix get_obproxy_version on rca * 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: