From e692585c7591f30b3178e10c242b98701707d4b9 Mon Sep 17 00:00:00 2001 From: xuyan wang <35394786+wayyoungboy@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:41:57 +0800 Subject: [PATCH] check update (#590) * support check list * support check list * support check list * support check list * support check list * support check list * build test package * build test package * update GatherComponentLogHandler * update tar_gz_to_zip * delete zip on gather * delete zip on gather * delete zip on gather * delete zip on gather * delete zip on gather * gather use find to get remote log * rca add oms_full_trans * rca add oms_full_trans * update * fix core options * add oms config * check list add --all --- core.py | 59 +++++++++++++------------ example/all-components-with-oms.yml | 67 +++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 example/all-components-with-oms.yml diff --git a/core.py b/core.py index a682f3cf..7cd2114a 100644 --- a/core.py +++ b/core.py @@ -468,32 +468,37 @@ def check(self, opts): self._call_stdio('error', 'No such custum config') return ObdiagResult(ObdiagResult.INPUT_ERROR_CODE, error_data='No such custum config') else: - self.stdio.print("check start ...") - self.update_obcluster_nodes(config) - self.set_context('check', 'check', config) - obproxy_check_handler = None - observer_check_handler = None - result_data = {} - - if self.context.obproxy_config.get("servers") is not None and len(self.context.obproxy_config.get("servers")) > 0: - obproxy_check_handler = CheckHandler(self.context, check_target_type="obproxy") - obproxy_result = obproxy_check_handler.handle() - result_data['obproxy'] = obproxy_result - if self.context.cluster_config.get("servers") is not None and len(self.context.cluster_config.get("servers")) > 0: - observer_check_handler = CheckHandler(self.context, check_target_type="observer") - observer_result = observer_check_handler.handle() - result_data['observer'] = observer_result - if obproxy_check_handler is not None: - obproxy_report_path = os.path.expanduser(obproxy_check_handler.report.get_report_path()) - if os.path.exists(obproxy_report_path): - result_data['obproxy_report_path'] = os.path.abspath(obproxy_report_path) - self.stdio.print("Check obproxy finished. For more details, please run cmd '" + Fore.YELLOW + " cat {0} ".format(obproxy_check_handler.report.get_report_path()) + Style.RESET_ALL + "'") - if observer_check_handler is not None: - observer_report_path = os.path.expanduser(observer_check_handler.report.get_report_path()) - if os.path.exists(observer_report_path): - result_data['observer_report_path'] = os.path.abspath(observer_report_path) - self.stdio.print("Check observer finished. For more details, please run cmd'" + Fore.YELLOW + " cat {0} ".format(observer_check_handler.report.get_report_path()) + Style.RESET_ALL + "'") - return ObdiagResult(ObdiagResult.SUCCESS_CODE, data=result_data) + try: + self.stdio.print("check start ...") + self.update_obcluster_nodes(config) + self.set_context('check', 'check', config) + obproxy_check_handler = None + observer_check_handler = None + result_data = {} + + if self.context.obproxy_config.get("servers") is not None and len(self.context.obproxy_config.get("servers")) > 0: + obproxy_check_handler = CheckHandler(self.context, check_target_type="obproxy") + obproxy_result = obproxy_check_handler.handle() + result_data['obproxy'] = obproxy_result + if self.context.cluster_config.get("servers") is not None and len(self.context.cluster_config.get("servers")) > 0: + observer_check_handler = CheckHandler(self.context, check_target_type="observer") + observer_result = observer_check_handler.handle() + result_data['observer'] = observer_result + if obproxy_check_handler is not None: + obproxy_report_path = os.path.expanduser(obproxy_check_handler.report.get_report_path()) + if os.path.exists(obproxy_report_path): + result_data['obproxy_report_path'] = os.path.abspath(obproxy_report_path) + self.stdio.print("Check obproxy finished. For more details, please run cmd '" + Fore.YELLOW + " cat {0} ".format(obproxy_check_handler.report.get_report_path()) + Style.RESET_ALL + "'") + if observer_check_handler is not None: + observer_report_path = os.path.expanduser(observer_check_handler.report.get_report_path()) + if os.path.exists(observer_report_path): + result_data['observer_report_path'] = os.path.abspath(observer_report_path) + self.stdio.print("Check observer finished. For more details, please run cmd'" + Fore.YELLOW + " cat {0} ".format(observer_check_handler.report.get_report_path()) + Style.RESET_ALL + "'") + return ObdiagResult(ObdiagResult.SUCCESS_CODE, data=result_data) + except Exception as e: + self.stdio.error("check Exception: {0}".format(e)) + self.stdio.verbose(traceback.format_exc()) + return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data="check Exception: {0}".format(e)) def check_list(self, opts): config = self.config_manager @@ -540,7 +545,7 @@ def update(self, opts): self.stdio.print("update start ...") self.set_offline_context('update', 'update') handler = UpdateHandler(self.context) - return handler.handle() + return handler.execute() def config(self, opt): config = self.config_manager diff --git a/example/all-components-with-oms.yml b/example/all-components-with-oms.yml new file mode 100644 index 00000000..f4743908 --- /dev/null +++ b/example/all-components-with-oms.yml @@ -0,0 +1,67 @@ +ocp: + login: + url: http://xx.xx.xx.xx:xx + user: admin + password: '' +obcluster: + ob_cluster_name: test + db_host: 192.168.1.1 + db_port: 2881 # default 2881 + tenant_sys: + user: root@sys # default root@sys + password: "" + servers: + nodes: + - ip: 192.168.1.1 + - ip: 192.168.1.2 + - ip: 192.168.1.3 + global: + ssh_username: '' # your username + ssh_password: '' # password if need + # ssh_port: 22 # your ssh port, default 22 + # ssh_key_file: "" # your ssh-key file path if need + # ssh_type: remote # ssh_type choice [remote, docker, kube] default remote + # container_name: xxx # container_name for ssh_type is docker + # The directory for oceanbase installed + home_path: /root/observer + # The directory for data storage. The default value is $home_path/store. + # data_dir: /root/observer/store + # The directory for clog, ilog, and slog. The default value is the same as the data_dir value. + # redo_dir: /root/observer/store +obproxy: + obproxy_cluster_name: obproxy + servers: + nodes: + - ip: 192.168.1.4 + - ip: 192.168.1.5 + - ip: 192.168.1.6 + global: + ssh_username: admin # your username + ssh_password: '' # password if need + # ssh_port: 22 # your ssh port, default 22 + # ssh_key_file: "" # your ssh-key file path if need + # ssh_type: remote # ssh_type choice [remote, docker, kube] default remote + # container_name: xxx # container_name for ssh_type is docker + # The directory for obproxy installed + home_path: /root/obproxy +oms: + oms_name: oms_cluster + servers: + nodes: + - ip: 192.168.1.4 + - ip: 192.168.1.5 + - ip: 192.168.1.6 + global: + ssh_username: admin # your username + ssh_password: '' # password if need + # ssh_port: 22 # your ssh port, default 22 + # ssh_key_file: "" # your ssh-key file path if need + # ssh_type: remote # ssh_type choice [remote, docker, kube] default remote + # container_name: xxx # container_name for ssh_type is docker + # The directory for oms log + log_path: /home/admin/logs + # The directory for oms task's run path + run_path: /home/admin/run + # The directory for oms task's store path + store_path: /home/admin/store +