Skip to content

Commit

Permalink
check update (#590)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wayyoungboy authored Dec 2, 2024
1 parent a513212 commit e692585
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 27 deletions.
59 changes: 32 additions & 27 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
67 changes: 67 additions & 0 deletions example/all-components-with-oms.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e692585

Please sign in to comment.