From ee5a76bb0b1056cd1a858d03b9d9eaf662f56869 Mon Sep 17 00:00:00 2001 From: Rongfeng Fu Date: Wed, 30 Mar 2022 15:14:15 +0800 Subject: [PATCH] Support obproxy ce (#94) * support obproxy-ce --- core.py | 10 +++++----- plugins/oceanbase/3.1.0/bootstrap.py | 7 ++++++- plugins/oceanbase/3.1.0/generate_config.py | 20 +++++++++++--------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/core.py b/core.py index 58454c2..67bca4a 100644 --- a/core.py +++ b/core.py @@ -2189,7 +2189,7 @@ class ObdHome(object): deploy_config = deploy.deploy_config if opts.component is None: - for component_name in ['obproxy', 'oceanbase', 'oceanbase-ce']: + for component_name in ['obproxy', 'obproxy-ce', 'oceanbase', 'oceanbase-ce']: if component_name in deploy_config.components: opts.component = component_name break @@ -2357,7 +2357,7 @@ class ObdHome(object): self._call_stdio('verbose', 'Get deploy configuration') deploy_config = deploy.deploy_config - allow_components = ['obproxy', 'oceanbase', 'oceanbase-ce'] + allow_components = ['obproxy', 'obproxy-ce', 'oceanbase', 'oceanbase-ce'] if opts.component is None: for component_name in allow_components: if component_name in deploy_config.components: @@ -2423,7 +2423,7 @@ class ObdHome(object): connect_plugin = self.search_py_script_plugin(repositories, 'connect')[repository] - if repository.name == 'obproxy': + if repository.name in ['obproxy', 'obproxy-ce']: ob_optimization = False allow_components = ['oceanbase', 'oceanbase-ce'] for component_name in deploy_config.components: @@ -2583,7 +2583,7 @@ class ObdHome(object): self._call_stdio('verbose', 'Get deploy configuration') deploy_config = deploy.deploy_config - allow_components = ['obproxy', 'oceanbase', 'oceanbase-ce'] + allow_components = ['obproxy', 'obproxy-ce', 'oceanbase', 'oceanbase-ce'] if opts.component is None: for component_name in allow_components: if component_name in deploy_config.components: @@ -2649,7 +2649,7 @@ class ObdHome(object): connect_plugin = self.search_py_script_plugin(repositories, 'connect')[repository] - if repository.name == 'obproxy': + if repository.name in ['obproxy', 'obproxy-ce']: ob_optimization = False allow_components = ['oceanbase', 'oceanbase-ce'] for component in deploy_info.components: diff --git a/plugins/oceanbase/3.1.0/bootstrap.py b/plugins/oceanbase/3.1.0/bootstrap.py index 4a6b450..2f30640 100644 --- a/plugins/oceanbase/3.1.0/bootstrap.py +++ b/plugins/oceanbase/3.1.0/bootstrap.py @@ -33,6 +33,11 @@ def bootstrap(plugin_context, cursor, *args, **kwargs): inner_config = { InnerConfigItem('$_zone_idc'): 'idc' } + has_obproxy = False + for componet_name in ['obproxy', 'obproxy-ce']: + if componet_name in plugin_context.components: + has_obproxy = True + break inner_keys = inner_config.keys() for server in cluster_config.servers: server_config = cluster_config.get_server_conf(server) @@ -67,7 +72,7 @@ def bootstrap(plugin_context, cursor, *args, **kwargs): stdio.verbose('execute sql: %s' % sql) cursor.execute(sql) global_conf = cluster_config.get_global_conf() - if 'proxyro_password' in global_conf or 'obproxy' in plugin_context.components: + if has_obproxy or 'proxyro_password' in global_conf: value = global_conf['proxyro_password'] if global_conf.get('proxyro_password') is not None else '' sql = 'create user "proxyro" IDENTIFIED BY %s' stdio.verbose(sql) diff --git a/plugins/oceanbase/3.1.0/generate_config.py b/plugins/oceanbase/3.1.0/generate_config.py index 2e3e216..04447df 100644 --- a/plugins/oceanbase/3.1.0/generate_config.py +++ b/plugins/oceanbase/3.1.0/generate_config.py @@ -75,15 +75,17 @@ def generate_config(plugin_context, deploy_config, *args, **kwargs): if not cluster_config.get_global_conf().get('appname'): default_appname = 'obcluster' - if 'obproxy' in deploy_config.components: - obproxy_cluster_config = deploy_config.components['obproxy'] - cluster_name = obproxy_cluster_config.get_global_conf().get('cluster_name') - if not cluster_name: - for server in obproxy_cluster_config.servers: - server_config = obproxy_cluster_config.get_server_conf(server) - if server_config.get('cluster_name'): - default_appname = server_config['cluster_name'] - break + for componet_name in ['obproxy', 'obproxy-ce']: + if componet_name in deploy_config.components: + obproxy_cluster_config = deploy_config.components[componet_name] + cluster_name = obproxy_cluster_config.get_global_conf().get('cluster_name') + if not cluster_name: + for server in obproxy_cluster_config.servers: + server_config = obproxy_cluster_config.get_server_conf(server) + if server_config.get('cluster_name'): + default_appname = server_config['cluster_name'] + break + break cluster_config.update_global_conf('appname', default_appname, False) MIN_MEMORY = 8 << 30 -- GitLab