Skip to content

Commit ae0f3bc

Browse files
authored
V2.1.0 (#170)
* V2.1.0 * V2.1.0 #163
1 parent 97ce659 commit ae0f3bc

File tree

144 files changed

+13828
-3606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+13828
-3606
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ tags
3636
/web/src/.umi-production
3737
/web/src/.umi-test
3838
/web/.env.local
39+
/web/.must.config.js

_cmd.py

Lines changed: 331 additions & 39 deletions
Large diffs are not rendered by default.

_environ.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@
3636
ENV_DISABLE_RSYNC = "OBD_DISABLE_RSYNC"
3737

3838
ENV_DISABLE_PARALLER_EXTRACT = "OBD_DISALBE_PARALLER_EXTRACT"
39+
40+
# telemetry mode. 0 - disable, 1 - enable.
41+
TELEMETRY_MODE = "TELEMETRY_MODE"
42+
43+
# telemetry log mode. 0 - disable, 1 - enable.
44+
TELEMETRY_LOG_MODE = "TELEMETRY_LOG_MODE"

_errno.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,15 @@ class InitDirFailedErrorMessage(object):
174174
EC_OCP_EXPRESS_META_DB_NOT_ENOUGH_LOG_DISK_AVAILABLE = OBDErrorCodeTemplate(4305, 'There is not enough log disk for ocp meta tenant. (Avail: {avail}, Need: {need})')
175175
EC_OCP_EXPRESS_META_DB_NOT_ENOUGH_LOG_DISK = OBDErrorCodeTemplate(4305, 'There is not enough log disk for ocp meta tenant.')
176176
EC_OCP_EXPRESS_META_DB_NOT_ENOUGH_MEM = OBDErrorCodeTemplate(4305, 'There is not enough memory for ocp meta tenant')
177+
EC_OCP_EXPRESS_ADMIN_PASSWD_ERROR = OBDErrorCodeTemplate(4306, '({ip}) ocp-express admin_passwd invalid.(Current :{current})')
177178
# sql
178179
EC_SQL_EXECUTE_FAILED = OBDErrorCodeTemplate(5000, "{sql} execute failed")
179180

181+
# obdiag
182+
EC_OBDIAG_NOT_FOUND = OBDErrorCodeTemplate(6000, 'Failed to executable obdiag command, you may not have obdiag installed')
183+
EC_OBDIAG_NOT_CONTAIN_DEPEND_COMPONENT = OBDErrorCodeTemplate(6001, 'obdiag must contain depend components {components}')
184+
EC_OBDIAG_OPTIONS_FORMAT_ERROR = OBDErrorCodeTemplate(6002, 'obdiag options {option} format error, please check the value : {value}')
185+
180186
# WARN CODE
181187
WC_ULIMIT_CHECK = OBDErrorCodeTemplate(1007, '({server}) The recommended number of {key} is {need} (Current value: {now})')
182188
WC_AIO_NOT_ENOUGH = OBDErrorCodeTemplate(1011, '({ip}) The recommended value of fs.aio-max-nr is 1048576 (Current value: {current})')
@@ -221,4 +227,5 @@ class InitDirFailedErrorMessage(object):
221227
SUG_OCP_EXPRESS_REDUCE_DISK = OBDErrorSuggestionTemplate('Please reduce the `logging_file_total_size_cap`', fix_eval=[FixEval(FixEval.DEL, 'logging_file_total_size_cap')])
222228
SUG_OCP_EXPRESS_COMP_VERSION = OBDErrorSuggestionTemplate('Please use {comp} with version {version} or above')
223229
SUG_OCP_EXPRESS_REDUCE_META_DB_MEM = OBDErrorSuggestionTemplate('Please reduce the `ocp_meta_tenant_memory_size`', fix_eval=[FixEval(FixEval.DEL, 'ocp_meta_tenant_memory_size')])
224-
SUG_OCP_EXPRESS_REDUCE_META_DB_LOG_DISK = OBDErrorSuggestionTemplate('Please reduce the `ocp_meta_tenant_log_disk_size`', fix_eval=[FixEval(FixEval.DEL, 'ocp_meta_tenant_log_disk_size')])
230+
SUG_OCP_EXPRESS_REDUCE_META_DB_LOG_DISK = OBDErrorSuggestionTemplate('Please reduce the `ocp_meta_tenant_log_disk_size`', fix_eval=[FixEval(FixEval.DEL, 'ocp_meta_tenant_log_disk_size')])
231+
SUG_OCP_EXPRESS_EDIT_ADMIN_PASSWD_ERROR = OBDErrorSuggestionTemplate('Please edit the `admin_passwd`, must be 8 to 32 characters in length, and must contain at least two digits, two uppercase letters, two lowercase letters, and two of the following special characters:~!@#%^&*_-+=|(){{}}[]:;,.?/)', fix_eval=[FixEval(FixEval.DEL, 'admin_passwd')], auto_fix=True)

_plugin.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import os
2424
import re
2525
import sys
26+
import time
2627
from enum import Enum
2728
from glob import glob
2829
from copy import deepcopy, copy
@@ -78,8 +79,8 @@ def __init__(self, spacename):
7879
def variables(self):
7980
return self._variables
8081

81-
def get_variable(self, name):
82-
return self._variables.get(name)
82+
def get_variable(self, name, default=None):
83+
return self._variables.get(name, default)
8384

8485
def set_variable(self, name, value):
8586
self._variables[name] = value
@@ -177,12 +178,12 @@ def return_false(self, *args, **kwargs):
177178
self._return.return_false(*args, **kwargs)
178179
self.namespace.set_return(self.plugin_name, self._return)
179180

180-
def get_variable(self, name, spacename=None):
181+
def get_variable(self, name, spacename=None, default=None):
181182
if spacename:
182183
namespace = self.namespaces.get(spacename)
183184
else:
184185
namespace = self.namespace
185-
return namespace.get_variable(name) if namespace else None
186+
return namespace.get_variable(name, default) if namespace else None
186187

187188
def set_variable(self, name, value):
188189
self.namespace.set_variable(name, value)
@@ -270,8 +271,11 @@ def _new_func(
270271
self.before_do(self.name, namespace, namespaces, deploy_name,
271272
repositories, components, clients, cluster_config, cmd,
272273
options, stdio, *arg, **kwargs)
274+
method_name = self.PLUGIN_NAME
275+
run_result = self.context.get_variable('run_result', default={})
276+
run_result[method_name] = {'result': True}
277+
start_time = time.time()
273278
if self.module:
274-
method_name = func.__name__
275279
method = getattr(self.module, method_name, False)
276280
namespace_vars = copy(self.context.namespace.variables)
277281
namespace_vars.update(kwargs)
@@ -280,10 +284,15 @@ def _new_func(
280284
try:
281285
ret = method(self.context, *arg, **kwargs)
282286
if ret is None and self.context and self.context.get_return() is None:
287+
run_result[method_name]['result'] = False
283288
self.context.return_false()
284289
except Exception as e:
290+
run_result[method_name]['result'] = False
285291
self.context.return_false(exception=e)
286292
stdio and getattr(stdio, 'exception', print)('%s RuntimeError: %s' % (self, e))
293+
end_time = time.time()
294+
run_result[method_name]['time'] = end_time - start_time
295+
self.context.set_variable('run_result', run_result)
287296
ret = self.context.get_return() if self.context else PluginReturn()
288297
self.after_do(stdio, *arg, **kwargs)
289298
return ret

_stdio.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,9 @@ def __init__(self,
379379
):
380380
self.level = level
381381
self.msg_lv = msg_lv
382-
self.log_path = None
383-
self.trace_id = None
384-
self.log_name = 'default'
385-
self.log_path = None
382+
self._log_path = None
383+
self._trace_id = None
384+
self._log_name = 'default'
386385
self._trace_logger = None
387386
self._log_cache = [] if use_cache else None
388387
self._root_io = root_io
@@ -419,13 +418,18 @@ def set_output_stream(self, output_stream):
419418
self._output_is_tty = output_stream.isatty()
420419
return True
421420

422-
def init_trace_logger(self, log_path, log_name=None, trace_id=None):
423-
if self._trace_logger is None:
424-
self.log_path = log_path
425-
if trace_id:
426-
self.trace_id = trace_id
421+
def init_trace_logger(self, log_path, log_name=None, trace_id=None, recreate=False):
422+
if self._root_io:
423+
return False
424+
if self._trace_logger is None or recreate:
425+
self._log_path = log_path
427426
if log_name:
428-
self.log_name = log_name
427+
self._log_name = log_name
428+
if trace_id:
429+
self._trace_id = trace_id
430+
self._trace_logger = None
431+
return True
432+
return False
429433

430434
def __getstate__(self):
431435
state = {}
@@ -437,6 +441,8 @@ def __getstate__(self):
437441

438442
@property
439443
def trace_logger(self):
444+
if self._root_io:
445+
return self._root_io.trace_logger
440446
if self.log_path and self._trace_logger is None:
441447
self._trace_logger = Logger(self.log_name)
442448
handler = handlers.TimedRotatingFileHandler(self.log_path, when='midnight', interval=1, backupCount=30)
@@ -447,6 +453,24 @@ def trace_logger(self):
447453
self._trace_logger.addHandler(handler)
448454
return self._trace_logger
449455

456+
@property
457+
def trace_id(self):
458+
if self._root_io:
459+
return self._root_io.trace_id
460+
return self._trace_id
461+
462+
@property
463+
def log_path(self):
464+
if self._root_io:
465+
return self._root_io.log_path
466+
return self._log_path
467+
468+
@property
469+
def log_name(self):
470+
if self._root_io:
471+
return self._root_io.log_name
472+
return self._log_name
473+
450474
@property
451475
def log_cache(self):
452476
if self._root_io:
@@ -618,10 +642,6 @@ def sub_io(self, pid=None, msg_lv=None):
618642
track_limit=self.track_limit,
619643
root_io=self._root_io if self._root_io else self
620644
)
621-
sub_io.log_name = self.log_name
622-
sub_io.log_path = self.log_path
623-
sub_io.trace_id = self.trace_id
624-
sub_io._trace_logger = self.trace_logger
625645
self.sub_ios[key] = sub_io
626646
return self.sub_ios[key]
627647

const.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# coding: utf-8
2+
# OceanBase Deploy.
3+
# Copyright (C) 2021 OceanBase
4+
#
5+
# This file is part of OceanBase Deploy.
6+
#
7+
# OceanBase Deploy is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# OceanBase Deploy is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with OceanBase Deploy. If not, see <https://www.gnu.org/licenses/>.
19+
20+
# OceanBase official website
21+
OB_OFFICIAL_WEBSITE = 'https://www.oceanbase.com/'
22+
23+
# post telemetry data to OceanBase official
24+
TELEMETRY_URL = 'http://openwebapi.dev.alipay.net/api/web/oceanbase/report'
25+
26+
# obdeploy version
27+
VERSION = '<VERSION>'
28+
# obdeploy build commit
29+
REVISION = '<CID>'
30+
# obdeploy build branch
31+
BUILD_BRANCH = '<B_BRANCH>'
32+
# obdeploy build time
33+
BUILD_TIME = '<B_TIME>'
34+
35+
# obdeploy home path
36+
CONST_OBD_HOME = "OBD_HOME"
37+
# obdeploy install pre path
38+
CONST_OBD_INSTALL_PRE = "OBD_INSTALL_PRE"
39+
# obdeploy install path
40+
CONST_OBD_INSTALL_PATH = "OBD_INSTALL_PATH"
41+
# obdeploy forbidden variable
42+
FORBIDDEN_VARS = (CONST_OBD_HOME, CONST_OBD_INSTALL_PRE, CONST_OBD_INSTALL_PATH)

0 commit comments

Comments
 (0)