Skip to content

Commit 6ed10bd

Browse files
committed
Merge branch 'dev_4.1.0' into 'master'
Dev 4.1.0 e/ob-deploy!804
2 parents e6cc698 + 1c7ee18 commit 6ed10bd

File tree

296 files changed

+11716
-2459
lines changed

Some content is hidden

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

296 files changed

+11716
-2459
lines changed

_cmd.py

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import glob
2525
import datetime
2626
import copy
27+
import getpass
2728
from uuid import uuid1 as uuid, UUID
2829
from optparse import OptionParser, BadOptionError, Option, IndentedHelpFormatter
2930

@@ -906,6 +907,10 @@ def _do_command(self, obd):
906907
# white_ip_list = self.get_white_ip_list()
907908
url = '/#/updateWelcome' if self.cmds and self.cmds[0] in ('upgrade', 'update') else ''
908909

910+
if self.opts.port < 1024:
911+
ROOT_IO.error('The port number must be in the range of 1025-65535.')
912+
return False
913+
909914
ROOT_IO.print('start OBD WEB in 0.0.0.0:%s' % self.opts.port)
910915
ROOT_IO.print('please open http://{0}:{1}{2}'.format(NetUtil.get_host_ip(), self.opts.port, url))
911916
try:
@@ -930,7 +935,7 @@ def __init__(self):
930935
self.parser.add_option('-U', '--unuselibrepo', '--ulp', action='store_true', help="Disable OBD from installing the libs mirror automatically.")
931936
self.parser.add_option('-A', '--auto-create-tenant', '--act', action='store_true', help="Automatically create a tenant named `test` by using all the available resource of the cluster.")
932937
self.parser.add_option('--force-delete', action='store_true', help="Force delete, delete the registered cluster.")
933-
self.parser.add_option('-s', '--strict-check', action='store_true', help="Throw errors instead of warnings when check fails.")
938+
self.parser.add_option('-S', '--strict-check', action='store_true', help="Throw errors instead of warnings when check fails.")
934939

935940
def _do_command(self, obd):
936941
if self.cmds:
@@ -1047,7 +1052,8 @@ def __init__(self):
10471052
self.parser.add_option('-c', '--components', type='string', help="List of components to be started. Multiple components are separated with commas.")
10481053
self.parser.add_option('-f', '--force-delete', action='store_true', help="Force delete, delete the registered cluster.")
10491054
self.parser.add_option('-S', '--strict-check', action='store_true', help="Throw errors instead of warnings when check fails.")
1050-
self.parser.add_option('--without-parameter', '--wop', action='store_true', help='Start without parameters.')
1055+
self.parser.add_option('--with-parameter', '--wp', action='store_true', help='Start with parameters.')
1056+
self.parser.add_option('--service-names', '--sn', type='string', help='List of services to be started for PowerRAG. Multiple services are separated with commas.')
10511057

10521058
def _do_command(self, obd):
10531059
if self.cmds:
@@ -1065,6 +1071,7 @@ def __init__(self):
10651071
super(ClusterStopCommand, self).__init__('stop', 'Stop a started cluster.')
10661072
self.parser.add_option('-s', '--servers', type='string', help="List of servers to be stoped. Multiple servers are separated with commas.")
10671073
self.parser.add_option('-c', '--components', type='string', help="List of components to be stoped. Multiple components are separated with commas.")
1074+
self.parser.add_option('--service-names', '--sn', type='string', help='List of services to be stoped for PowerRAG. Multiple services are separated with commas.')
10681075

10691076
def _do_command(self, obd):
10701077
if self.cmds:
@@ -1128,8 +1135,8 @@ def __init__(self):
11281135

11291136
def _do_command(self, obd):
11301137
if self.cmds:
1131-
if not getattr(self.opts, 'with_parameter', False):
1132-
setattr(self.opts, 'without_parameter', True)
1138+
# if not getattr(self.opts, 'with_parameter', False):
1139+
# setattr(self.opts, 'without_parameter', True)
11331140
obd.set_options(self.opts)
11341141
res = obd.restart_cluster(self.cmds[0])
11351142
self.background_telemetry_task(obd)
@@ -1227,6 +1234,8 @@ def __init__(self):
12271234
self.parser.add_option('-e', '--executer-path', type='string', help="Executer path.", default=os.path.join(ObdCommand.OBD_INSTALL_PATH, 'lib/executer'))
12281235
self.parser.add_option('-t', '--script-query-timeout', type='string', help="The timeout(s) for executing sql in upgrade scripts. Supported since version 4.1.0", default='')
12291236
self.parser.add_option('--ignore-standby', '--igs', action='store_true', help="Force upgrade, before upgrade standby tenant`s cluster.")
1237+
self.parser.add_option('--oms-backup-path', type='string', help="Upgrade the OMS backup meta data directory", default=os.path.join(os.path.expanduser('~'), 'oms', 'meta_backup_data'))
1238+
self.parser.add_option('--disable-oms-backup', '--dob', action='store_true', help="disable OMS backup meta data.")
12301239

12311240
def _do_command(self, obd):
12321241
oms_upgrade_mode = None
@@ -1324,6 +1333,8 @@ def __init__(self):
13241333
super(ClusterTenantSwitchoverCommand, self).__init__('switchover', 'Switchover primary-standby tenant.')
13251334
self.parser.add_option('-p', '--tenant-root-password', type='string', help="tenant root password")
13261335
self.parser.add_option('--standbyro-password', type='string', help="standbyro user password.")
1336+
self.parser.add_option('--standby_archive_log_uri', type='string', help='The storage directory path for standby tenant archive logs.')
1337+
self.parser.add_option('--primary_archive_log_uri', type='string', help='The storage directory path for primary tenant archive logs.')
13271338

13281339
def init(self, cmd, args):
13291340
super(ClusterTenantSwitchoverCommand, self).init(cmd, args)
@@ -1485,21 +1496,21 @@ class ClusterTenantRestoreCommand(ClusterMirrorCommand):
14851496
def __init__(self):
14861497
super(ClusterTenantRestoreCommand, self).__init__('restore', 'Restore tenant from backup.')
14871498
self.parser.add_option('-z', '--zone', type='string', help='The zones of the tenant. example: zone1,zone2,zone3')
1488-
self.parser.add_option('--unit_num', type='int', help='The number of units in each zone. Default: 1.', default=1)
1489-
self.parser.add_option('--replica_type ', type='string', help='The replica type of the tenant.')
1490-
self.parser.add_option('-p', '--primary_zone', type='string', help="The primary zone of the tenant to be restored.")
1499+
self.parser.add_option('--unit-num', type='int', help='The number of units in each zone. Default: 1.', default=1)
1500+
self.parser.add_option('--replica-type ', type='string', help='The replica type of the tenant.')
1501+
self.parser.add_option('-p', '--primary-zone', type='string', help="The primary zone of the tenant to be restored.")
14911502
self.parser.add_option('-T', '--timestamp', type='string', help='The timestamp to restore to.')
14921503
self.parser.add_option('-S', '--scn', type='int', help="The SCN to restore to. Default: 0.")
1493-
self.parser.add_option('-s', '--ha_high_thread_score', type='int', help='The high thread score for HA. Range: [0, 100]')
1504+
self.parser.add_option('-s', '--ha-high-thread-score', type='int', help='The high thread score for HA. Range: [0, 100]')
14941505
self.parser.add_option('-c', '--concurrency', type='int', help='The number of threads to use for the restore operation.')
14951506
self.parser.add_option('-D', '--decryption', type='string', help='The decryption password for all backups. example: key1,key2,key3')
1496-
self.parser.add_option('-k', '--kms_encrypt_info', type='string', help='The KMS encryption information.')
1497-
self.parser.add_option('--memory_size', type='string', help='The memory size of the resource unit config')
1498-
self.parser.add_option('--max_cpu', type='int', help='The max cpu of the resource unit config, should be greater than 1.')
1499-
self.parser.add_option('--min_cpu', type='int', help='The min cpu of the resource unit config, should be greater than 1.If not set, the min cpu will be set to the max cpu.')
1500-
self.parser.add_option('--max_iops', type='int', help='The max iops of the resource unit config.If not set, the max iops will be set default value by observer.')
1501-
self.parser.add_option('--min_iops', type='int', help='The min iops of the resource unit config.If not set, the min iops will be set default value by observer.')
1502-
self.parser.add_option('--log_disk_size', type='string', help='The log disk size of the resource unit config.If not set, the log disk size will be set default value by observer.')
1507+
self.parser.add_option('-k', '--kms-encrypt-info', type='string', help='The KMS encryption information.')
1508+
self.parser.add_option('--memory-size', type='string', help='The memory size of the resource unit config')
1509+
self.parser.add_option('--max-cpu', type='int', help='The max cpu of the resource unit config, should be greater than 1.')
1510+
self.parser.add_option('--min-cpu', type='int', help='The min cpu of the resource unit config, should be greater than 1.If not set, the min cpu will be set to the max cpu.')
1511+
self.parser.add_option('--max-iops', type='int', help='The max iops of the resource unit config.If not set, the max iops will be set default value by observer.')
1512+
self.parser.add_option('--min-iops', type='int', help='The min iops of the resource unit config.If not set, the min iops will be set default value by observer.')
1513+
self.parser.add_option('--log-disk-size', type='string', help='The log disk size of the resource unit config.If not set, the log disk size will be set default value by observer.')
15031514

15041515
def init(self, cmd, args):
15051516
super(ClusterTenantRestoreCommand, self).init(cmd, args)
@@ -1660,6 +1671,7 @@ def __init__(self):
16601671
self.register_command(ClusterRedeployCommand())
16611672
self.register_command(ClusterEditConfigCommand())
16621673
self.register_command(ClusterReloadCommand())
1674+
self.register_command(ClusterReloadCommand())
16631675
self.register_command(CLusterUpgradeCommand())
16641676
self.register_command(ClusterChangeRepositoryCommand())
16651677
self.register_command(ClusterTenantCommand())
@@ -2656,18 +2668,22 @@ def __init__(self):
26562668

26572669
def init(self, cmd, args):
26582670
super(HostPrecheckCommand, self).init(cmd, args)
2659-
self.parser.set_usage('%s <ssh username> <server ip>' % self.prev_cmd)
2671+
self.parser.set_usage('%s [<ssh username>] [<server ip>]' % self.prev_cmd)
26602672
return self
26612673

26622674
def _do_command(self, obd):
2663-
if len(self.cmds) == 2:
2664-
return obd.precheck_host(self.cmds[0], self.cmds[1])
2665-
elif len(self.cmds) == 3:
2666-
if self.cmds[2] == 'code100':
2667-
cmd_ret = obd.precheck_host(self.cmds[0], self.cmds[1], dev=True)
2668-
if isinstance(cmd_ret, bool):
2669-
return cmd_ret
2670-
return CmdReturn(cmd_ret, cmd_ret)
2675+
# Set default values: username = current user, ip = 127.0.0.1
2676+
username = getpass.getuser() if len(self.cmds) == 0 else self.cmds[0]
2677+
ip = '127.0.0.1' if len(self.cmds) <= 1 else self.cmds[1]
2678+
2679+
if len(self.cmds) == 3 and self.cmds[2] == 'code100':
2680+
cmd_ret = obd.precheck_host(username, ip, dev=True)
2681+
if isinstance(cmd_ret, bool):
2682+
return cmd_ret
2683+
return CmdReturn(cmd_ret, cmd_ret)
2684+
elif len(self.cmds) <= 2:
2685+
# Normal case: 0, 1, or 2 arguments (defaults applied above)
2686+
return obd.precheck_host(username, ip)
26712687
else:
26722688
return self._show_help()
26732689

@@ -2682,18 +2698,22 @@ def __init__(self):
26822698

26832699
def init(self, cmd, args):
26842700
super(HostInitCommand, self).init(cmd, args)
2685-
self.parser.set_usage('%s <ssh username> <server ip>' % self.prev_cmd)
2701+
self.parser.set_usage('%s [<ssh username>] [<server ip>]' % self.prev_cmd)
26862702
return self
26872703

26882704
def _do_command(self, obd):
2689-
if len(self.cmds) == 2:
2690-
return obd.init_host(self.cmds[0], self.cmds[1])
2691-
elif len(self.cmds) == 3:
2692-
if self.cmds[2] == 'code101':
2693-
cmd_ret = obd.init_host(self.cmds[0], self.cmds[1], dev=True)
2694-
if isinstance(cmd_ret, bool):
2695-
return cmd_ret
2696-
return CmdReturn(cmd_ret, cmd_ret)
2705+
# Set default values: username = current user, ip = 127.0.0.1
2706+
username = getpass.getuser() if len(self.cmds) == 0 else self.cmds[0]
2707+
ip = '127.0.0.1' if len(self.cmds) <= 1 else self.cmds[1]
2708+
2709+
if len(self.cmds) == 3 and self.cmds[2] == 'code101':
2710+
cmd_ret = obd.init_host(username, ip, dev=True)
2711+
if isinstance(cmd_ret, bool):
2712+
return cmd_ret
2713+
return CmdReturn(cmd_ret, cmd_ret)
2714+
elif len(self.cmds) <= 2:
2715+
# Normal case: 0, 1, or 2 arguments (defaults applied above)
2716+
return obd.init_host(username, ip)
26972717
else:
26982718
return self._show_help()
26992719

@@ -2968,8 +2988,6 @@ def __init__(self):
29682988

29692989
def _do_command(self, obd):
29702990
if self.cmds:
2971-
if not getattr(self.opts, 'with_parameter', False):
2972-
setattr(self.opts, 'without_parameter', True)
29732991
obd.set_options(self.opts)
29742992
res = obd.restart_cluster(self.cmds[0])
29752993
self.background_telemetry_task(obd)

_deploy.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,12 @@ def _from_cluster_config(cls, conf, cluster_config):
482482
class ClusterConfig(object):
483483

484484
def __init__(self, servers, name, version, tag, release, package_hash, comp_type, image_name, parser=None):
485-
version = Version('1.0.0') if comp_type == 'docker' else version
485+
if comp_type == 'docker':
486+
version = Version('1.0.0')
487+
if comp_type == 'dockers':
488+
version = Version(tag)
489+
if name == const.COMP_PRAG:
490+
image_name = const.POWERRAG_IMAGE
486491
self._version = version
487492
self.origin_version = version
488493
self.tag = tag
@@ -595,6 +600,10 @@ def set_base_dir(self, base_dir):
595600
def docker_install(self):
596601
return self.comp_type == 'docker'
597602

603+
@property
604+
def docker_compose_install(self):
605+
return self.comp_type == 'dockers'
606+
598607
@property
599608
def deploy_name(self):
600609
return self._deploy_config.name
@@ -1835,7 +1844,7 @@ def deploy_info(self):
18351844
def _load_deploy_config(self, path):
18361845
yaml_loader = YamlLoader(stdio=self.stdio)
18371846
inner_config = InnerConfig(self.get_inner_config_path(self.config_dir), yaml_loader=yaml_loader)
1838-
deploy_config = DeployConfig(path, yaml_loader=yaml_loader, inner_config=inner_config, config_parser_manager=self.config_parser_manager, config_encrypted=self._config_encrypted,stdio=self.stdio)
1847+
deploy_config = DeployConfig(path, yaml_loader=yaml_loader, inner_config=inner_config, config_parser_manager=self.config_parser_manager, config_encrypted=self._config_encrypted, stdio=self.stdio)
18391848
deploy_info = self.deploy_info
18401849
for component_name in deploy_info.components:
18411850
if component_name not in deploy_config.components:

_errno.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class InitDirFailedErrorMessage(object):
150150
WC_FAIL_TO_RESTART_OR_RELOAD_AFTER_SCALE_OUT = OBDErrorCodeTemplate(1022, 'The cluster has been scaled out, but encountered problems when reloading or restarting. Details:\n{detail}')
151151
WC_CHANGE_SYSTEM_PARAMETER_FAILED = OBDErrorCodeTemplate(1023, '({server}) failed to change system parameter: {key})')
152152

153+
153154
# error code for observer
154155
EC_OBSERVER_NOT_ENOUGH_MEMORY = OBDErrorCodeTemplate(2000, '({ip}) not enough memory. (Free: {free}, Need: {need})')
155156
EC_OBSERVER_NOT_ENOUGH_MEMORY_ALAILABLE = OBDErrorCodeTemplate(2000, '({ip}) not enough memory. (Available [cat /proc/meminfo | grep MemAvailable] : {available}, Need: {need})')
@@ -182,7 +183,7 @@ class InitDirFailedErrorMessage(object):
182183
EC_OBSERVER_AUTO_START_DBUS_ENV = OBDErrorCodeTemplate(2019, "The current user does not have permission to enable autostart; sudo privileges are required and this operation is not allowed in container environments.")
183184
EC_MULTIPLE_NODES_SAME = OBDErrorCodeTemplate(2020, "Multiple observer nodes on the same server are not supported by the auto start feature")
184185
EC_OBSERVER_WEB_AUTO_START = OBDErrorCodeTemplate(2021, "Permission denied. Current user {user} on server {ip} requires sudo privileges.")
185-
186+
EC_CPU_CORE_NOT_ENOUGH = OBDErrorCodeTemplate(2022, "({server}) Insufficient CPU cores. (Current: {current}, Required: {required})")
186187

187188
WC_OBSERVER_SYS_MEM_TOO_LARGE = OBDErrorCodeTemplate(2010, '({server}): system_memory too large. system_memory should be less than {factor} * memory_limit/memory_limit_percentage.')
188189

@@ -270,6 +271,13 @@ class InitDirFailedErrorMessage(object):
270271
EC_OMS_SERVER_CONNECT_METADB = OBDErrorCodeTemplate(4701, 'failed to connect meta db')
271272
EC_OMS_SERVER_CONNECT_INFLUXDB = OBDErrorCodeTemplate(4702, 'failed to connect influxdb')
272273
EC_OMS_NOT_ENOUGH_DISK = OBDErrorCodeTemplate(4703, '({ip}) {disk} not enough disk space. (Need: {need})')
274+
EC_OMS_UPDATE_NOT_DISABLE_HA = OBDErrorCodeTemplate(4704, 'HA is enabled, please disable it before upgrade.')
275+
276+
#maas
277+
EC_MAAS_NOT_ENOUGH_DISK = OBDErrorCodeTemplate(4703, '({ip}) {disk} not enough disk space. (Need: {need})')
278+
279+
#powerrag
280+
EC_POWERRAG_PROJECT_NAME_USED = OBDErrorCodeTemplate(4704, '({ip}) {project_name} is already in use')
273281

274282
# sql
275283
EC_SQL_EXECUTE_FAILED = OBDErrorCodeTemplate(5000, "{sql} execute failed")

_mirror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_use_centos_release(stdio=None):
6060
'uos': {'20': 8},
6161
'anolis': {'23': 7},
6262
'openEuler': {'22.03': 7},
63-
'kylin': {'V10': 8},
63+
'kylin': {'V10': 7},
6464
'alinux': {'2': 7, '3': 8}
6565
}
6666
_SERVER_VARS = {

_repository.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,13 @@ def _parse_path(self):
333333
if not self.version:
334334
self.set_version(version)
335335

336-
def _dump(self):
336+
def _dump(self, **kwargs):
337337
data = {'version': self.version, 'hash': self.hash,
338338
'release': self.release, 'arch': self.arch, 'size': self.size}
339339
if self.install_time:
340340
data['install_time'] = self.install_time
341+
for k, v in kwargs.items():
342+
data[k] = v
341343
try:
342344
with open(self.data_file_path, 'w') as f:
343345
YamlLoader().dump(data, f)
@@ -461,6 +463,9 @@ def load_image(self, version, md5=None):
461463
self.install_time = time.time()
462464
self._dump()
463465

466+
def update_info(self, **kwargs):
467+
self._dump(**kwargs)
468+
464469
def clear(self):
465470
if os.path.exists(self.repository_dir):
466471
return DirectoryUtil.rm(self.repository_dir, self.stdio) and DirectoryUtil.mkdir(self.repository_dir, stdio=self.stdio)

_workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ def __init__(self, home_path, component_name, workflow_name=None, dev_mode=False
255255
def get_workflow_template(self, version):
256256
template = self.get_best_plugin(version)
257257
if not template:
258+
if not version:
259+
version = '0.1'
258260
template = self._general_loader.get_best_plugin(version)
259261
return template
260262

const.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@
106106
DCDTC_SCRIPT = 'docker_copy_dumpfile_to_container.sh'
107107
DCDR_SCRIPT = 'docker_copy_dumpfile_rollback.sh'
108108

109+
#maas
110+
COMP_MAAS = 'maas'
111+
112+
# powerrag
113+
COMP_PRAG = 'powerrag'
114+
POWERRAG_IMAGE = 'harbor.oceanbase-dev.com/powerrag/powerrag'
115+
POWERRAG_PKG_HOME = 'POWERRAG_PKG_HOME'
116+
109117
# service docs url
110118
DISABLE_SWAGGER = '<DISABLE_SWAGGER>'
111119

@@ -168,4 +176,7 @@
168176
"type": "list",
169177
"sub_keys": ["cm_nodes", "cm_location", "cm_region"]
170178
}
171-
]
179+
]
180+
181+
# only single server component
182+
SINGLE_SERVER_COMPONENTS = [COMP_PRAG, COMP_MAAS]

0 commit comments

Comments
 (0)