Skip to content

Commit

Permalink
V3.0 dev (#567)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wayyoungboy authored Nov 21, 2024
1 parent ce0eb2e commit 2a64229
Show file tree
Hide file tree
Showing 10 changed files with 394 additions and 148 deletions.
10 changes: 2 additions & 8 deletions common/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,20 +682,14 @@ def tar_gz_to_zip(temp_dir, tar_gz_file, output_zip, password, stdio):
base_paths.append(base_path)
stdio.verbose("start pyminizip compress_multiple")
# 3. Compress the extracted files into a (possibly) encrypted zip file
zip_process = None
if password:
# Use pyminizip to create the encrypted zip file
zip_process = mp.Process(target=pyminizip.compress_multiple, args=(files_to_compress, base_paths, output_zip, password, 5))
# pyminizip.compress_multiple(files_to_compress, base_paths, output_zip, password, 5) # 5 is the compression level
pyminizip.compress_multiple(files_to_compress, base_paths, output_zip, password, 5) # 5 is the compression level
stdio.verbose("extracted files compressed into encrypted {0}".format(output_zip))
else:
# Create an unencrypted zip file
zip_process = mp.Process(target=pyminizip.compress_multiple, args=(files_to_compress, base_paths, output_zip, None, 5))
# pyminizip.compress_multiple(files_to_compress, base_paths, output_zip, None, 5)
pyminizip.compress_multiple(files_to_compress, base_paths, output_zip, None, 5)
stdio.verbose("extracted files compressed into unencrypted {0}".format(output_zip))
zip_process.start()
if zip_process is not None:
zip_process.join()

# 4. Remove the extracted directory
shutil.rmtree(extract_dir)
Expand Down
32 changes: 32 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,38 @@ def create_ob_proxy_node(node_config, global_config):
'servers': ob_proxy_nodes,
}

@property
def get_oms_config(self):
oms = self.config_data.get('oms', {})
nodes = oms.get('servers', {}).get('nodes', [])

def create_oms_node(node_config, global_config):
return {
'ip': node_config.get('ip'),
'ssh_username': node_config.get('ssh_username', global_config.get('ssh_username', '')),
'ssh_password': node_config.get('ssh_password', global_config.get('ssh_password', '')),
'ssh_port': node_config.get('ssh_port', global_config.get('ssh_port', 22)),
'home_path': node_config.get('home_path', global_config.get('home_path', '/root/obproxy')),
'log_path': node_config.get('log_path', global_config.get('log_path', '/home/admin/logs')),
'run_path': node_config.get('run_path', global_config.get('run_path', '/home/admin/run')),
'store_path': node_config.get('store_path', global_config.get('store_path', '/home/admin/store')),
'ssh_key_file': node_config.get('ssh_key_file', global_config.get('ssh_key_file', '')),
'ssh_type': node_config.get('ssh_type', global_config.get('ssh_type', 'remote')),
'container_name': node_config.get('container_name', global_config.get('container_name')),
'namespace': node_config.get('namespace', global_config.get('namespace', '')),
'pod_name': node_config.get('pod_name', global_config.get('pod_name', '')),
"kubernetes_config_file": node_config.get('kubernetes_config_file', global_config.get('kubernetes_config_file', '')),
'host_type': 'OMS',
}

global_config = oms.get('servers', {}).get('global', {})
oms_nodes = [create_oms_node(node, global_config) for node in nodes]

return {
'oms_cluster_name': oms.get('oms_cluster_name'),
'servers': oms_nodes,
}

@property
def get_node_config(self, type, node_ip, config_item):
if type == 'ob_cluster':
Expand Down
3 changes: 2 additions & 1 deletion context.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ def return_false(self, *args, **kwargs):

class HandlerContext(object):

def __init__(self, handler_name=None, namespace=None, namespaces=None, cluster_config=None, obproxy_config=None, ocp_config=None, inner_config=None, cmd=None, options=None, stdio=None):
def __init__(self, handler_name=None, namespace=None, namespaces=None, cluster_config=None, obproxy_config=None, oms_config=None, ocp_config=None, inner_config=None, cmd=None, options=None, stdio=None):
self.namespace = HandlerContextNamespace(namespace)
self.namespaces = namespaces
self.handler_name = handler_name
self.cluster_config = cluster_config
self.obproxy_config = obproxy_config
self.oms_config = oms_config
self.ocp_config = ocp_config
self.inner_config = inner_config
self.cmds = cmd
Expand Down
2 changes: 2 additions & 0 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def set_context(self, handler_name, namespace, config):
namespace=namespace,
cluster_config=config.get_ob_cluster_config,
obproxy_config=config.get_obproxy_config,
oms_config=config.get_oms_config,
ocp_config=config.get_ocp_config,
cmd=self.cmds,
options=self.options,
Expand All @@ -147,6 +148,7 @@ def set_context_skip_cluster_conn(self, handler_name, namespace, config):
namespace=namespace,
cluster_config=config.get_ob_cluster_config,
obproxy_config=config.get_obproxy_config,
oms_config=config.get_oms_config,
ocp_config=config.get_ocp_config,
cmd=self.cmds,
options=self.options,
Expand Down
4 changes: 4 additions & 0 deletions handler/gather/gather_ash_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""
import datetime
import os
import traceback

from common.command import get_observer_version
from common.ob_connector import OBConnector
Expand Down Expand Up @@ -74,6 +75,7 @@ def version_check(self):
try:
observer_version = get_observer_version(self.context)
except Exception as e:
self.stdio.verbose(traceback.format_exc())
self.stdio.warn("RCAHandler Failed to get observer version:{0}".format(e))
return False
self.stdio.verbose("RCAHandler.init get observer version: {0}".format(observer_version))
Expand Down Expand Up @@ -108,6 +110,7 @@ def execute(self):
f.write(self.ash_report_file_name)

except Exception as e:
self.stdio.verbose(traceback.format_exc())
self.stdio.error("ash report gather failed, error message: {0}".format(e))

def __init_report_path(self):
Expand All @@ -116,6 +119,7 @@ def __init_report_path(self):
self.stdio.verbose("Use {0} as pack dir.".format(self.report_path))
DirectoryUtil.mkdir(path=self.report_path, stdio=self.stdio)
except Exception as e:
self.stdio.verbose(traceback.format_exc())
self.stdio.error("init_report_path failed, error:{0}".format(e))

def init_option(self):
Expand Down
Loading

0 comments on commit 2a64229

Please sign in to comment.