Skip to content

Commit e6cc698

Browse files
committed
v4.0.0
2 parents c6fc3e3 + f283bfd commit e6cc698

File tree

280 files changed

+27762
-10370
lines changed

Some content is hidden

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

280 files changed

+27762
-10370
lines changed

_cmd.py

Lines changed: 152 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ def do_command(self):
308308
obd.set_cmds(self.cmds)
309309
ret = self._do_command(obd)
310310
if not ret:
311-
ROOT_IO.exit_msg = DOC_LINK_MSG + "\n" + ROOT_IO.exit_msg
311+
from _errno import EXIST_ERROR_CODE
312+
ROOT_IO.exit_msg = ((DOC_LINK_MSG + "\n") if EXIST_ERROR_CODE else '') + ROOT_IO.exit_msg
312313
except NotImplementedError:
313314
ROOT_IO.exception('command \'%s\' is not implemented' % self.prev_cmd)
314315
except LockError:
@@ -839,7 +840,7 @@ def _do_command(self, obd):
839840
class DemoCommand(ClusterMirrorCommand):
840841

841842
def __init__(self):
842-
super(DemoCommand, self).__init__('demo', 'Quickly start')
843+
super(DemoCommand, self).__init__('demo', 'Quickly start, This is a basic setup with minimal resources.')
843844
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"
844845
+ "start -c oceanbase-ce V3.2.3: obd demo -c oceanbase-ce --oceanbase-ce.version=3.2.3\n"
845846
+ "start oceanbase-ce and obproxy-ce: obd demo -c oceanbase-ce,obproxy-ce", default='oceanbase-ce,obproxy-ce,obagent,prometheus,grafana')
@@ -866,10 +867,10 @@ def _do_command(self, obd):
866867
class PrefCommand(ClusterMirrorCommand):
867868

868869
def __init__(self):
869-
super(PrefCommand, self).__init__('pref', 'Quickly start')
870+
super(PrefCommand, self).__init__('perf', 'Quickly start, This deploys OceanBase with production-optimized configuration for enhanced performance.')
870871
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"
871-
+ "start -c oceanbase-ce V3.2.3: obd pref -c oceanbase-ce --oceanbase-ce.version=3.2.3\n"
872-
+ "start oceanbase-ce and obproxy-ce: obd pref -c oceanbase-ce,obproxy-ce", default='oceanbase-ce,obproxy-ce,obagent,prometheus,grafana')
872+
+ "start -c oceanbase-ce V3.2.3: obd perf -c oceanbase-ce --oceanbase-ce.version=3.2.3\n"
873+
+ "start oceanbase-ce and obproxy-ce: obd perf -c oceanbase-ce,obproxy-ce", default='oceanbase-ce,obproxy-ce,obagent,prometheus,grafana')
873874
self.parser.allow_undefine = True
874875
self.parser.undefine_warn = False
875876

@@ -885,8 +886,8 @@ def _do_command(self, obd):
885886
setattr(self.opts, 'max', True)
886887
obd.set_options(self.opts)
887888

888-
res = obd.demo(name='pref')
889-
self.background_telemetry_task(obd, 'pref')
889+
res = obd.demo(name='perf')
890+
self.background_telemetry_task(obd, 'perf')
890891
return res
891892

892893

@@ -1090,6 +1091,20 @@ def _do_command(self, obd):
10901091
return self._show_help()
10911092

10921093

1094+
class ClusterPruneConfigCommand(ClusterMirrorCommand):
1095+
1096+
def __init__(self):
1097+
super(ClusterPruneConfigCommand, self).__init__('prune-config', 'Remove configuration files for destroyed or configured clusters.')
1098+
self.parser.add_option('--confirm', action='store_true', help='Confirm to prune configuration files.')
1099+
1100+
def _do_command(self, obd):
1101+
if self.cmds:
1102+
res = obd.prune_config(self.cmds[0], need_confirm=not getattr(self.opts, 'confirm', False))
1103+
return res
1104+
else:
1105+
return self._show_help()
1106+
1107+
10931108
class ClusterDisplayCommand(ClusterMirrorCommand):
10941109

10951110
def __init__(self):
@@ -1204,6 +1219,8 @@ def __init__(self):
12041219
super(CLusterUpgradeCommand, self).__init__('upgrade', 'Upgrade a cluster.')
12051220
self.parser.add_option('-c', '--component', type='string', help="Component name to upgrade.")
12061221
self.parser.add_option('-V', '--version', type='string', help="Target version.")
1222+
self.parser.add_option('--tag', type='string', help="Docker component tag.")
1223+
self.parser.add_option('-i', '--image-name', type='string', help="Docker component image name.")
12071224
self.parser.add_option('--skip-check', action='store_true', help="Skip all the possible checks.")
12081225
self.parser.add_option('--usable', type='string', help="Hash list for priority mirrors, separated with `,`.", default='')
12091226
self.parser.add_option('--disable', type='string', help="Hash list for disabled mirrors, separated with `,`.", default='')
@@ -1212,8 +1229,12 @@ def __init__(self):
12121229
self.parser.add_option('--ignore-standby', '--igs', action='store_true', help="Force upgrade, before upgrade standby tenant`s cluster.")
12131230

12141231
def _do_command(self, obd):
1232+
oms_upgrade_mode = None
1233+
if len(self.cmds) == 2 and self.cmds[1] in ['offline', 'online']:
1234+
oms_upgrade_mode = self.cmds[1]
1235+
del self.cmds[1]
12151236
if self.cmds:
1216-
res = obd.upgrade_cluster(self.cmds[0])
1237+
res = obd.upgrade_cluster(self.cmds[0], oms_upgrade_mode)
12171238
self.background_telemetry_task(obd)
12181239
return res
12191240
else:
@@ -1632,6 +1653,7 @@ def __init__(self):
16321653
self.register_command(ClusterStartCommand())
16331654
self.register_command(ClusterStopCommand())
16341655
self.register_command(ClusterDestroyCommand())
1656+
self.register_command(ClusterPruneConfigCommand())
16351657
self.register_command(ClusterDisplayCommand())
16361658
self.register_command(ClusterListCommand())
16371659
self.register_command(ClusterRestartCommand())
@@ -2875,6 +2897,127 @@ def _do_command(self, obd):
28752897
return self._show_help()
28762898

28772899

2900+
class SeekdbMirrorCommand(ObdCommand):
2901+
2902+
def init(self, cmd, args, need_deploy_name=True):
2903+
super(SeekdbMirrorCommand, self).init(cmd, args)
2904+
if need_deploy_name and not self.cmds:
2905+
return self._show_help()
2906+
return self
2907+
2908+
2909+
class SeekdbDeployCommand(SeekdbMirrorCommand):
2910+
2911+
def __init__(self):
2912+
super(SeekdbDeployCommand, self).__init__('deploy', 'Deploy a seekdb cluster.')
2913+
self.parser.add_option('-f', '--force', action='store_true', help="Force deploy, clear the working directory.")
2914+
self.parser.add_option('-C', '--clean', action='store_true', help="Clean deploy, clear the working directory if it belongs to the current user.")
2915+
self.parser.add_option('-U', '--ulp', '--unuselibrepo', action='store_true', help="Disable automatic dependency handling.")
2916+
self.parser.add_option('-A', '--act', '--auto-create-tenant', action='store_true', help="Auto create tenant during bootstrap.")
2917+
2918+
def _do_command(self, obd):
2919+
if self.cmds:
2920+
obd.set_options(self.opts)
2921+
res = obd.deploy_cluster(self.cmds[0])
2922+
self.background_telemetry_task(obd)
2923+
return res
2924+
else:
2925+
return self._show_help()
2926+
2927+
2928+
class SeekdbStartCommand(SeekdbMirrorCommand):
2929+
2930+
def __init__(self):
2931+
super(SeekdbStartCommand, self).__init__('start', 'Start a deployed seekdb cluster.')
2932+
self.parser.add_option('-s', '--servers', type='string', help="List of servers to be started. Multiple servers are separated with commas.")
2933+
self.parser.add_option('-S', '--strict-check', action='store_true', help="Throw errors instead of warnings when check fails.")
2934+
self.parser.add_option('--without-parameter', '--wop', action='store_true', help='Start without parameters.')
2935+
2936+
def _do_command(self, obd):
2937+
if self.cmds:
2938+
obd.set_cmds(self.cmds[1:])
2939+
res = obd.start_cluster(self.cmds[0])
2940+
self.background_telemetry_task(obd)
2941+
return res
2942+
else:
2943+
return self._show_help()
2944+
2945+
2946+
class SeekdbStopCommand(SeekdbMirrorCommand):
2947+
2948+
def __init__(self):
2949+
super(SeekdbStopCommand, self).__init__('stop', 'Stop a started seekdb cluster.')
2950+
self.parser.add_option('-s', '--servers', type='string', help="List of servers to be stopped. Multiple servers are separated with commas.")
2951+
2952+
def _do_command(self, obd):
2953+
if self.cmds:
2954+
obd.set_cmds(self.cmds[1:])
2955+
res = obd.stop_cluster(self.cmds[0])
2956+
self.background_telemetry_task(obd)
2957+
return res
2958+
else:
2959+
return self._show_help()
2960+
2961+
2962+
class SeekdbRestartCommand(SeekdbMirrorCommand):
2963+
2964+
def __init__(self):
2965+
super(SeekdbRestartCommand, self).__init__('restart', 'Restart a started seekdb cluster.')
2966+
self.parser.add_option('-s', '--servers', type='string', help="List of servers to be restarted. Multiple servers are separated with commas.")
2967+
self.parser.add_option('--with-parameter', '--wp', action='store_true', help='Restart with parameters.')
2968+
2969+
def _do_command(self, obd):
2970+
if self.cmds:
2971+
if not getattr(self.opts, 'with_parameter', False):
2972+
setattr(self.opts, 'without_parameter', True)
2973+
obd.set_options(self.opts)
2974+
res = obd.restart_cluster(self.cmds[0])
2975+
self.background_telemetry_task(obd)
2976+
return res
2977+
else:
2978+
return self._show_help()
2979+
2980+
2981+
class SeekdbDestroyCommand(SeekdbMirrorCommand):
2982+
2983+
def __init__(self):
2984+
super(SeekdbDestroyCommand, self).__init__('destroy', 'Destroy a deployed seekdb cluster.')
2985+
self.parser.add_option('-f', '--force-kill', action='store_true', help="Force kill the running seekdb process in the working directory.")
2986+
self.parser.add_option('--confirm', action='store_true', help='Confirm to destroy.')
2987+
2988+
def _do_command(self, obd):
2989+
if self.cmds:
2990+
res = obd.destroy_cluster(self.cmds[0], need_confirm=not getattr(self.opts, 'confirm', False))
2991+
return res
2992+
else:
2993+
return self._show_help()
2994+
2995+
2996+
class SeekdbDisplayCommand(SeekdbMirrorCommand):
2997+
2998+
def __init__(self):
2999+
super(SeekdbDisplayCommand, self).__init__('display', 'Display the information for a seekdb cluster.')
3000+
self.parser.add_option('--encryption-passkey', '--epk', type='string', help="Encryption passkey.")
3001+
3002+
def _do_command(self, obd):
3003+
if self.cmds:
3004+
return obd.display_cluster(self.cmds[0])
3005+
else:
3006+
return self._show_help()
3007+
3008+
3009+
class SeekdbMajorCommand(MajorCommand):
3010+
3011+
def __init__(self):
3012+
super(SeekdbMajorCommand, self).__init__('seekdb', 'Deploy and manage a seekdb cluster.')
3013+
self.register_command(SeekdbDeployCommand())
3014+
self.register_command(SeekdbStartCommand())
3015+
self.register_command(SeekdbStopCommand())
3016+
self.register_command(SeekdbRestartCommand())
3017+
self.register_command(SeekdbDestroyCommand())
3018+
self.register_command(SeekdbDisplayCommand())
3019+
3020+
28783021
class MainCommand(MajorCommand):
28793022

28803023
def __init__(self):
@@ -2885,6 +3028,7 @@ def __init__(self):
28853028
self.register_command(WebCommand())
28863029
self.register_command(MirrorMajorCommand())
28873030
self.register_command(ClusterMajorCommand())
3031+
self.register_command(SeekdbMajorCommand())
28883032
self.register_command(RepositoryMajorCommand())
28893033
self.register_command(TestMajorCommand())
28903034
self.register_command(UpdateCommand())

_deploy.py

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import _errno as err
3131
import const
32+
from _rpm import Version
3233
from tool import ConfigUtil, FileUtil, YamlLoader, OrderedDict, COMMAND_ENV, aes_encrypt, aes_decrypt, \
3334
string_to_md5_32bytes
3435
from _manager import Manager
@@ -372,7 +373,9 @@ def _to_cluster_config(cls, component_name, conf, added_servers=None):
372373
ConfigUtil.get_value_from_dict(conf, 'version', None, str),
373374
ConfigUtil.get_value_from_dict(conf, 'tag', None, str),
374375
ConfigUtil.get_value_from_dict(conf, 'release', None, str),
375-
ConfigUtil.get_value_from_dict(conf, 'package_hash', None, str)
376+
ConfigUtil.get_value_from_dict(conf, 'package_hash', None, str),
377+
ConfigUtil.get_value_from_dict(conf, 'type', 'rpm', str),
378+
ConfigUtil.get_value_from_dict(conf, 'image_name', 'None', str)
376379
)
377380
if added_servers:
378381
cluster_config.added_servers = added_servers
@@ -478,14 +481,17 @@ def _from_cluster_config(cls, conf, cluster_config):
478481

479482
class ClusterConfig(object):
480483

481-
def __init__(self, servers, name, version, tag, release, package_hash, parser=None):
484+
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
482486
self._version = version
483487
self.origin_version = version
484488
self.tag = tag
489+
self.comp_type = comp_type
485490
self.origin_tag = tag
486491
self._release = release
487492
self.origin_release = release
488493
self.name = name
494+
self.image_name = image_name
489495
self.origin_package_hash = package_hash
490496
self._package_hash = package_hash
491497
self._temp_conf = {}
@@ -562,7 +568,7 @@ def __eq__(self, other):
562568
return True
563569

564570
def __deepcopy__(self, memo):
565-
cluster_config = self.__class__(deepcopy(self.servers), self.name, self.version, self.tag, self.release, self.package_hash, self.parser)
571+
cluster_config = self.__class__(deepcopy(self.servers), self.name, self.version, self.tag, self.release, self.package_hash, self.image_name, self.parser)
566572
copy_attrs = ['origin_tag', 'origin_version', 'origin_package_hash', 'parser', 'added_servers']
567573
deepcopy_attrs = ['_temp_conf', '_all_default_conf', '_default_conf', '_global_conf', '_server_conf', '_cache_server', '_original_global_conf', '_depends', '_original_servers', '_inner_config']
568574
for attr in copy_attrs:
@@ -585,6 +591,10 @@ def set_base_dir(self, base_dir):
585591
self._include_config = None
586592
self._global_conf = None
587593

594+
@property
595+
def docker_install(self):
596+
return self.comp_type == 'docker'
597+
588598
@property
589599
def deploy_name(self):
590600
return self._deploy_config.name
@@ -784,6 +794,16 @@ def get_need_redeploy_items(self, server):
784794
items[key] = config[key]
785795
return items
786796

797+
def get_read_only_items(self, server):
798+
if server not in self._server_conf:
799+
return None
800+
items = {}
801+
config = self.get_server_conf(server)
802+
for key in config:
803+
if key in self._temp_conf and self._temp_conf[key].read_only:
804+
items[key] = config[key]
805+
return items
806+
787807
def get_need_restart_items(self, server):
788808
if server not in self._server_conf:
789809
return None
@@ -1244,7 +1264,9 @@ def update_component_info(self, repository):
12441264
src_data['version'] = repository.version
12451265
if 'release' in src_data:
12461266
src_data['release'] = repository.release
1247-
if 'tag' in src_data:
1267+
if src_data.get('type') == 'docker':
1268+
src_data['tag'] = repository.version
1269+
elif 'tag' in src_data:
12481270
del src_data['tag']
12491271

12501272
self._src_data[component] = src_data
@@ -1693,6 +1715,11 @@ def update_password_in_global_config(self, global_config, path, key, enable_encr
16931715
self.update_password_in_global_config(global_config[current_key], path[1:], key, enable_encrypt)
16941716

16951717
def change_deploy_config_password(self, enable_encrypt, change_deploy_encrypt=True, first_encrypt=False):
1718+
class ExcludePassword:
1719+
def __init__(self, ob_param: str, comps: list):
1720+
self.ob_param = ob_param
1721+
self.comps = comps
1722+
16961723
if COMMAND_ENV.get(const.ENCRYPT_PASSWORD) != '1' and not first_encrypt:
16971724
return True
16981725
deploy_encrypt_enable = self.inner_config.get_global_config(const.ENCRYPT_PASSWORD) or False
@@ -1701,12 +1728,13 @@ def change_deploy_config_password(self, enable_encrypt, change_deploy_encrypt=Tr
17011728
if not enable_encrypt and not self._config_encrypted:
17021729
self._need_encrypt_dump = False
17031730
else:
1704-
1731+
ob_global_config = {}
17051732
cluster_id = ''
17061733
for component in const.COMPS_OB:
17071734
if component in self.components.keys():
17081735
cluster_config = self.components[component]
17091736
global_config = cluster_config.get_global_conf()
1737+
ob_global_config = global_config
17101738
cluster_id = str(global_config['cluster_id']) if 'cluster_id' in global_config else ''
17111739
key = string_to_md5_32bytes(self.name + cluster_id).encode('utf-8')
17121740
self.stdio.verbose(f"encrypt key: {key}")
@@ -1715,13 +1743,19 @@ def change_deploy_config_password(self, enable_encrypt, change_deploy_encrypt=Tr
17151743
self.user.password = aes_encrypt(str(self.user.password), key)
17161744
else:
17171745
self.user.password = aes_decrypt(self.user.password, key)
1746+
1747+
exclude_pwd = {"ocp_meta_password": ExcludePassword("ocp_meta_password", const.COMPS_OCP)}
17181748
for component, cluster_config in self.components.items():
17191749
self.stdio.verbose(f"change {component} pwd encrypt.")
17201750
password_paths = []
17211751
global_config = cluster_config.get_global_conf()
17221752
self.get_all_password_path(global_config, password_paths, component)
17231753
change_global_config = deepcopy(global_config)
17241754
for password_path in password_paths:
1755+
if password_path in exclude_pwd and component in exclude_pwd[password_path].comps:
1756+
origin_global_config = cluster_config.get_original_global_conf()
1757+
if ob_global_config.get(exclude_pwd[password_path].ob_param) and not origin_global_config.get(password_path):
1758+
continue
17251759
password_path_keys = password_path.split('.')
17261760
self.update_password_in_global_config(change_global_config, password_path_keys, key, enable_encrypt)
17271761
cluster_config.update_global_conf(password_path_keys[0], change_global_config[password_path_keys[0]], save=False)

0 commit comments

Comments
 (0)