Skip to content

Commit 873085e

Browse files
committed
V 4.2.0
1 parent a3e8c47 commit 873085e

File tree

8 files changed

+82
-12
lines changed

8 files changed

+82
-12
lines changed

_cmd.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,11 @@ def __init__(self):
872872
self.parser.add_option('-c', '--components', type='string', help="List the components. Multiple components are separated with commas. [oceanbase-ce,obproxy-ce,obagent,prometheus,grafana,ob-configserver]\nExample: \nstart oceanbase-ce: obd demo -c oceanbase-ce\n"
873873
+ "start -c oceanbase-ce V3.2.3: obd perf -c oceanbase-ce --oceanbase-ce.version=3.2.3\n"
874874
+ "start oceanbase-ce and obproxy-ce: obd perf -c oceanbase-ce,obproxy-ce", default='oceanbase-ce,obproxy-ce,obagent,prometheus,grafana')
875+
self.parser.add_option('--server', type='string', help="The IP address of the server to deploy on.")
876+
self.parser.add_option('--username', type='string', help="The username for SSH connection.", default=None)
877+
self.parser.add_option('--password', type='string', help="The password for SSH connection.", default='')
878+
self.parser.add_option('--port', type='int', help="The port for SSH connection.", default=22)
879+
self.parser.add_option('--key-file', type='string', help="The path to the private key file for SSH connection.", default='')
875880
self.parser.allow_undefine = True
876881
self.parser.undefine_warn = False
877882

@@ -1733,7 +1738,7 @@ def __init__(self):
17331738
self.parser.add_option('--slb-host', type='string', help='The host of soft load balance.')
17341739
self.parser.add_option('--exec-id', type='string', help='The unique execute id.')
17351740
self.parser.add_option('--case-filter', type='string', help='The case filter file for mysqltest.')
1736-
self.parser.add_option('--psmall-test', type='string', help='The file maintain psmall cases.', default='./mysql_test/psmalltest.py')
1741+
self.parser.add_option('--psmall-test', type='string', help='The file maintain psmall cases.', default='mysqltest_config.yaml')
17371742
self.parser.add_option('--psmall-source', type='string', help='The file maintain psmall source control.', default='./mysql_test/psmallsource.py')
17381743
self.parser.add_option('--ps', action='store_true', help='Run in ps mode.', default=False)
17391744
self.parser.add_option('--test-tags', type='string', help='The file maintain basic tags.', default='./mysql_test/test_tags.py')
@@ -2564,6 +2569,7 @@ def __init__(self):
25642569
self.parser.add_option('--replicate-num', type='int', help="Number of copies", default=1)
25652570
self.parser.add_option('-d', '--obproxy-deployname', '--odp', type='string', help='Obproxy deploy name')
25662571
self.parser.add_option('-p', '--cdcro-password', type='string', help='Password of user `cdcro`.If user already been created manually, you need to enter the password here.')
2572+
self.parser.add_option('--rs', '--root-server-list', type='string', help="The list of machines where the rootservice resides, in the format 'server_ip:server_rpc_port:server_sql_port'")
25672573

25682574
def init(self, cmd, args):
25692575
super(BinlogCreateCommand, self).init(cmd, args)

_errno.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class InitDirFailedErrorMessage(object):
261261

262262
# obbinlog
263263
EC_OBBINLOG_DEPENDS_COMP_MIN_VERSION = OBDErrorCodeTemplate(4601, 'OBBinlog {obbinlog_version} needs to use {comp} with version {min_version} or above.')
264-
EC_OBBINLOG_TARGET_DEPLOY_NEED_CONFIGSERVER = OBDErrorCodeTemplate(4602, 'Deploy {target_oceanbase_deploy} need depends ob-configserver. You could use `obd cluster component add {target_oceanbase_deploy} -c <ob-configserver.config>` to add.')
264+
EC_OBBINLOG_TARGET_DEPLOY_NEED_CONFIGSERVER = OBDErrorCodeTemplate(4602, 'Deploy {target_oceanbase_deploy} need depends ob-configserver. You could use `obd cluster component add {target_oceanbase_deploy} -c <ob-configserver.config>` to add or set `--rs` paramater')
265265
EC_OBBINLOG_CE_WITH_OCENABASE_CE = OBDErrorCodeTemplate(4603, 'The Binlog service for the community version can only be used with the community version of the OceanBase database.')
266266
EC_OBBINLOG_WITH_OCENABASE = OBDErrorCodeTemplate(4604, 'The Binlog service for the enterprise version can only be used with the enterprise version of the OceanBase database.')
267267

core.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,11 +1798,38 @@ def demo(self, name='demo'):
17981798
if not components:
17991799
self._call_stdio('error', 'Use `-c/--components` to set in the components to be deployed')
18001800
return
1801-
1801+
1802+
configs = OrderedDict()
18021803
global_key = 'global'
18031804
home_path_key = 'home_path'
1804-
global_config = {home_path_key: os.getenv('HOME')}
1805+
username = getattr(self.options, 'username', None)
1806+
if not username:
1807+
home_path_prefix = os.getenv('HOME')
1808+
elif username == 'root':
1809+
home_path_prefix = '/root'
1810+
else:
1811+
home_path_prefix = '/home/{}'.format(username)
1812+
global_config = {home_path_key: home_path_prefix}
18051813
opt_config = {}
1814+
target_ip = getattr(self.options, 'server', None)
1815+
if target_ip:
1816+
configs['user'] = {}
1817+
user_config = configs['user']
1818+
target_ip_list = [target_ip]
1819+
if username:
1820+
user_config['username'] = username
1821+
password = getattr(self.options, 'password', None)
1822+
if password is not None:
1823+
user_config['password'] = password
1824+
port = getattr(self.options, 'port', 22)
1825+
if port:
1826+
user_config['port'] = port
1827+
key_file = getattr(self.options, 'key_file', '')
1828+
if key_file:
1829+
user_config['key_file'] = key_file
1830+
else:
1831+
target_ip_list = ['127.0.0.1']
1832+
18061833
for key in self.options.__dict__:
18071834
tmp = key.split('.', 1)
18081835
if len(tmp) == 1:
@@ -1820,10 +1847,9 @@ def demo(self, name='demo'):
18201847
_config = opt_config[component_name][global_key]
18211848
_config[tmp[1]] = self.options.__dict__[key]
18221849

1823-
configs = OrderedDict()
18241850
for component_name in components:
18251851
configs[component_name] = {
1826-
'servers': ['127.0.0.1'],
1852+
'servers': deepcopy(target_ip_list),
18271853
global_key: deepcopy(global_config)
18281854
}
18291855
configs[component_name][global_key][home_path_key] = os.path.join(configs[component_name][global_key][home_path_key], component_name)

plugins/mysqltest/3.1.0/check_test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import os
1919
import sys
2020
import re
21+
import yaml
2122
from glob import glob
2223

2324
import tool
@@ -86,8 +87,13 @@ def check_test(plugin_context, env, *args, **kwargs):
8687
if 'all' in opt and opt['all'] and os.path.isdir(os.path.realpath(opt['suite_dir'])):
8788
opt['suite'] = ','.join(os.listdir(os.path.realpath(opt['suite_dir'])))
8889
if 'psmall' in opt and opt['psmall']:
89-
test_set = get_variable_from_python_file(
90-
opt.get('psmall_test'), 'psmall_test', default_file='psmalltest.py', default_value=[], stdio=stdio)
90+
if os.path.exists(opt.get('psmall_test')):
91+
with open(opt.get('psmall_test'), 'r') as f:
92+
config = yaml.safe_load(f)
93+
test_set = config.get('runtime_configs', {}).get('psmall', {}).get('test-set', [])
94+
opt['reboot_after_run_count'] = config.get('runtime_configs', {}).get('psmall', {}).get('reboot-after-run-count', 0)
95+
else:
96+
test_set = []
9197
opt['source_limit'] = get_variable_from_python_file(
9298
opt.get('psmall_source'), 'psmall_source', default_file='psmallsource.py', default_value={}, stdio=stdio)
9399
has_test_point = True

plugins/mysqltest/3.1.0/run_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def return_true(**kw):
201201
auto_retry = env.get('auto_retry')
202202
is_retry = env.get('is_retry', False)
203203
reboot_cases = env.get('reboot_cases', [])
204+
reboot_after_run_count = env.get('reboot_after_run_count', 0)
204205
need_reboot = env.get('need_reboot', False)
205206
collect_all = env.get('collect_all', False)
206207
collect_log = False
@@ -444,6 +445,8 @@ def return_true(**kw):
444445
case_results.append(result)
445446
index += 1
446447
is_retry = False
448+
if reboot_after_run_count > 0 and index % reboot_after_run_count == 0:
449+
need_reboot = True
447450
elif is_retry or not auto_retry:
448451
# failed and no chance to retry
449452
case_results.append(result)

plugins/obbinlog-ce/4.0.1/create_binlog.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ def create_binlog(plugin_context, ob_deploy, tenant_name, ob_cluster_repositori
3535
cluster_name = plugin_context.get_variable('cluster_name')
3636
obconfig_url = plugin_context.get_variable('obconfig_url')
3737
replicate_num = getattr(plugin_context.options, 'replicate_num')
38-
sql = f"CREATE BINLOG FOR TENANT `{cluster_name}`.`{tenant_name}` TO USER `cdcro` PASSWORD `{ob_global_config.get('cdcro_password')}` WITH CLUSTER URL `{obconfig_url}`, REPLICATE NUM {replicate_num};"
38+
if obconfig_url:
39+
sql = f"CREATE BINLOG FOR TENANT `{cluster_name}`.`{tenant_name}` TO USER `cdcro` PASSWORD `{ob_global_config.get('cdcro_password')}` WITH CLUSTER URL `{obconfig_url}`, REPLICATE NUM {replicate_num};"
40+
else:
41+
root_service_list = plugin_context.get_variable('root_service_list')
42+
sql = f"CREATE BINLOG FOR TENANT `{cluster_name}`.`{tenant_name}` TO USER `cdcro` PASSWORD `{ob_global_config.get('cdcro_password')}` WITH ROOTSERVER_LIST '{root_service_list}', REPLICATE NUM {replicate_num};"
3943
try:
4044
cursor.execute(sql, raise_exception=True)
4145
except Exception as e:

plugins/obbinlog-ce/4.0.1/create_env_check.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,28 @@ def create_env_check(plugin_context, ob_deploy, ob_cluster_repositories, *args,
9494
return plugin_context.return_false()
9595
ob_cluster_config.update_global_conf('cdcro_password', getattr(plugin_context.options, 'cdcro_password'), True)
9696
try:
97+
rs_lists = []
98+
rs_list = ''
99+
for comp in const.COMPS_OB:
100+
if comp in cluster_config.depends:
101+
ob_servers = cluster_config.get_depend_servers(comp)
102+
for ob_server in ob_servers:
103+
ob_server_conf = cluster_config.get_depend_config(comp, ob_server)
104+
rs_lists.append('{}:{}:{}'.format(ob_server.ip, ob_server_conf['rpc_port'], ob_server_conf['mysql_port']))
105+
if rs_lists:
106+
rs_list = ';'.join(rs_lists)
107+
108+
rs_list = rs_list if rs_list else (getattr(plugin_context.options, 'root_server_list', None) or getattr(plugin_context.options, 'rs', None))
97109
ret = cursor.fetchone("SHOW PARAMETERS LIKE 'obconfig_url';")
98110
obconfig_url = ret['value']
99-
if not obconfig_url:
111+
if not obconfig_url and not rs_list:
100112
stdio.error(EC_OBBINLOG_TARGET_DEPLOY_NEED_CONFIGSERVER.format(target_oceanbase_deploy=ob_deploy.name))
101113
stdio.stop_loading('fail')
102114
return plugin_context.return_false()
103-
plugin_context.set_variable('obconfig_url', obconfig_url)
115+
if obconfig_url:
116+
plugin_context.set_variable('obconfig_url', obconfig_url)
117+
else:
118+
plugin_context.set_variable('root_service_list', rs_list)
104119
except Exception as e:
105120
stdio.error(e)
106121
stdio.stop_loading('succeed')

ssh.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ def remote_transporter(self):
547547
self.stdio.verbose("current remote_transporter {}".format(self._remote_transporter))
548548
return self._remote_transporter
549549

550+
def set_remote_transporter(self, transporter, stdio=None):
551+
self._remote_transporter = transporter
552+
550553
def put_file(self, local_path, remote_path, stdio=None):
551554
if not os.path.isfile(local_path):
552555
stdio.error('path: %s is not file' % local_path)
@@ -555,7 +558,14 @@ def put_file(self, local_path, remote_path, stdio=None):
555558
return LocalClient.put_file(local_path, remote_path, stdio=stdio)
556559
if not self._open_sftp(stdio=stdio):
557560
return False
558-
return self._put_file(local_path, remote_path, stdio=stdio)
561+
ret = self._put_file(local_path, remote_path, stdio=stdio)
562+
if not ret:
563+
if self.remote_transporter == RemoteTransporter.RSYNC:
564+
COMMAND_ENV.set(ENV_DISABLE_RSYNC, '0', save=True)
565+
self.set_remote_transporter(RemoteTransporter.CLIENT)
566+
return self._put_file(local_path, remote_path, stdio=stdio)
567+
else:
568+
return True
559569

560570
def write_file(self, content, file_path, mode='w', stdio=None):
561571
if self._is_local:

0 commit comments

Comments
 (0)