Skip to content

Commit 4740aa7

Browse files
authored
V2.6.1 (#190)
1 parent 4c3a9a8 commit 4740aa7

Some content is hidden

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

69 files changed

+514
-373
lines changed

_cmd.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def lock_mode(self):
441441

442442
@property
443443
def enable_log(self):
444-
return COMMAND_ENV.get(ENV.TELEMETRY_LOG_MODE, default='0') == '1'
444+
return COMMAND_ENV.get(ENV.ENV_TELEMETRY_LOG_MODE, default='0') == '1'
445445

446446
def init(self, cmd, args):
447447
super(TelemetryPostCommand, self).init(cmd, args)
@@ -459,7 +459,7 @@ def __init__(self):
459459
self.register_command(TelemetryPostCommand())
460460

461461
def do_command(self):
462-
if COMMAND_ENV.get(ENV.TELEMETRY_MODE, default='1') == '1':
462+
if COMMAND_ENV.get(ENV.ENV_TELEMETRY_MODE, default='1') == '1':
463463
return super(TelemetryMajorCommand, self).do_command()
464464
else:
465465
ROOT_IO.critical('Telemetry is disabled. To enable OBD telemetry, run the `obd env set TELEMETRY_MODE 1` command.')
@@ -914,11 +914,12 @@ class ClusterDestroyCommand(ClusterMirrorCommand):
914914
def __init__(self):
915915
super(ClusterDestroyCommand, self).__init__('destroy', 'Destroy a deployed cluster.')
916916
self.parser.add_option('-f', '--force-kill', action='store_true', help="Force kill the running observer process in the working directory.")
917+
self.parser.add_option('--confirm', action='store_true', help='Confirm to destroy.')
917918
self.parser.add_option('--ignore-standby', '--igs', action='store_true', help="Force kill the observer while standby tenant in others cluster exists.")
918919

919920
def _do_command(self, obd):
920921
if self.cmds:
921-
res = obd.destroy_cluster(self.cmds[0])
922+
res = obd.destroy_cluster(self.cmds[0], need_confirm=not getattr(self.opts, 'confirm', False))
922923
return res
923924
else:
924925
return self._show_help()
@@ -1082,7 +1083,7 @@ def __init__(self):
10821083
self.parser.add_option('-s', '--variables', type='string', help="Set the variables for the system tenant. [ob_tcp_invited_nodes='%'].", default="ob_tcp_invited_nodes='%'")
10831084

10841085
def _do_command(self, obd):
1085-
if self.cmds:
1086+
if len(self.cmds) == 1:
10861087
return obd.create_tenant(self.cmds[0])
10871088
else:
10881089
return self._show_help()

_deploy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def __eq__(self, other):
532532
def __deepcopy__(self, memo):
533533
cluster_config = self.__class__(deepcopy(self.servers), self.name, self.version, self.tag, self.release, self.package_hash, self.parser)
534534
copy_attrs = ['origin_tag', 'origin_version', 'origin_package_hash', 'parser', 'added_servers']
535-
deepcopy_attrs = ['_temp_conf', '_default_conf', '_global_conf', '_server_conf', '_cache_server', '_original_global_conf', '_depends', '_original_servers', '_inner_config']
535+
deepcopy_attrs = ['_temp_conf', '_all_default_conf', '_default_conf', '_global_conf', '_server_conf', '_cache_server', '_original_global_conf', '_depends', '_original_servers', '_inner_config']
536536
for attr in copy_attrs:
537537
setattr(cluster_config, attr, getattr(self, attr))
538538
for attr in deepcopy_attrs:

_environ.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@
3838
ENV_DISABLE_PARALLER_EXTRACT = "OBD_DISALBE_PARALLER_EXTRACT"
3939

4040
# telemetry mode. 0 - disable, 1 - enable.
41-
TELEMETRY_MODE = "TELEMETRY_MODE"
41+
ENV_TELEMETRY_MODE = "TELEMETRY_MODE"
4242

4343
# telemetry log mode. 0 - disable, 1 - enable.
44-
TELEMETRY_LOG_MODE = "TELEMETRY_LOG_MODE"
44+
ENV_TELEMETRY_LOG_MODE = "TELEMETRY_LOG_MODE"
45+
46+
# telemetry reporter. {reporter name}
47+
ENV_TELEMETRY_REPORTER = "TELEMETRY_REPORTER"
4548

4649
# ROOT IO DEFAULT CONFIRM. 0 - disable, 1 - enable.
4750
ENV_DEFAULT_CONFIRM = "IO_DEFAULT_CONFIRM"

_plugin.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,11 @@ def return_false(self, *args, **kwargs):
147147

148148
class PluginContext(object):
149149

150-
def __init__(self, plugin_name, namespace, namespaces, deploy_name, repositories, components, clients, cluster_config, cmd, options, dev_mode, stdio):
150+
def __init__(self, plugin_name, namespace, namespaces, deploy_name, deploy_status, repositories, components, clients, cluster_config, cmd, options, dev_mode, stdio):
151151
self.namespace = namespace
152152
self.namespaces = namespaces
153153
self.deploy_name = deploy_name
154+
self.deploy_status = deploy_status
154155
self.repositories =repositories
155156
self.plugin_name = plugin_name
156157
self.components = components
@@ -244,7 +245,7 @@ def __del__(self):
244245
self._export()
245246

246247
def before_do(
247-
self, plugin_name, namespace, namespaces, deploy_name,
248+
self, plugin_name, namespace, namespaces, deploy_name, deploy_status,
248249
repositories, components, clients, cluster_config, cmd,
249250
options, stdio, *arg, **kwargs
250251
):
@@ -254,7 +255,7 @@ def before_do(
254255
for server in clients:
255256
sub_clients[server] = ScriptPlugin.ClientForScriptPlugin(clients[server], sub_stdio)
256257
self.context = PluginContext(
257-
plugin_name, namespace, namespaces, deploy_name, repositories, components,
258+
plugin_name, namespace, namespaces, deploy_name, deploy_status, repositories, components,
258259
sub_clients, cluster_config, cmd, options, self.dev_mode, sub_stdio
259260
)
260261
namespace.set_return(plugin_name, None)
@@ -266,11 +267,11 @@ def after_do(self, stdio, *arg, **kwargs):
266267

267268
def pyScriptPluginExec(func):
268269
def _new_func(
269-
self, namespace, namespaces, deploy_name,
270+
self, namespace, namespaces, deploy_name, deploy_status,
270271
repositories, components, clients, cluster_config, cmd,
271272
options, stdio, *arg, **kwargs
272273
):
273-
self.before_do(self.name, namespace, namespaces, deploy_name,
274+
self.before_do(self.name, namespace, namespaces, deploy_name, deploy_status,
274275
repositories, components, clients, cluster_config, cmd,
275276
options, stdio, *arg, **kwargs)
276277
method_name = self.PLUGIN_NAME
@@ -337,14 +338,14 @@ def __init__(self, component_name, plugin_path, version, dev_mode):
337338
self.libs_path.append(self.plugin_path)
338339

339340
def __call__(
340-
self, namespace, namespaces, deploy_name,
341+
self, namespace, namespaces, deploy_name, deploy_status,
341342
repositories, components, clients, cluster_config, cmd,
342343
options, stdio, *arg, **kwargs
343344
):
344345
method = getattr(self, self.PLUGIN_NAME, False)
345346
if method:
346347
return method(
347-
namespace, namespaces, deploy_name,
348+
namespace, namespaces, deploy_name, deploy_status,
348349
repositories, components, clients, cluster_config, cmd,
349350
options, stdio, *arg, **kwargs
350351
)
@@ -794,7 +795,7 @@ def set_plugin_type(plugin_type):
794795
795796
@pyScriptPluginExec
796797
def %s(
797-
self, namespace, namespaces, deploy_name,
798+
self, namespace, namespaces, deploy_name, deploy_status,
798799
repositories, components, clients, cluster_config, cmd,
799800
options, stdio, *arg, **kwargs):
800801
pass

_stdio.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,12 @@ def _stop_buffer_io(self):
547547
def set_verbose_level(level):
548548
IO.VERBOSE_LEVEL = level
549549

550+
@property
551+
def syncing(self):
552+
if self._root_io:
553+
return self._root_io.syncing
554+
return self.sync_obj is not None
555+
550556
def _start_sync_obj(self, sync_clz, before_critical, *arg, **kwargs):
551557
if self._root_io:
552558
return self._root_io._start_sync_obj(sync_clz, before_critical, *arg, **kwargs)
@@ -667,8 +673,9 @@ def confirm(self, msg):
667673
msg = '%s [y/n]: ' % msg
668674
self.print(msg, end='')
669675
if self.default_confirm:
676+
self.verbose("default confirm: True")
670677
return True
671-
if self._input_is_tty:
678+
if self.isatty() and not self.syncing:
672679
while True:
673680
try:
674681
ans = self.get_input_stream().readline(blocked=True).strip().lower()
@@ -680,6 +687,7 @@ def confirm(self, msg):
680687
if not e:
681688
return False
682689
else:
690+
self.verbose("isatty: %s, syncing: %s, auto confirm: False" % (self.isatty(), self.syncing))
683691
return False
684692

685693
def _format(self, msg, *args):

const.py

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# post telemetry data to OceanBase official
2424
TELEMETRY_WEBSITE = '<TELEMETRY_WEBSITE>'
2525
TELEMETRY_URL = '{}/api/web/oceanbase/report'.format(TELEMETRY_WEBSITE if TELEMETRY_WEBSITE else 'https://openwebapi.oceanbase.com')
26+
TELEMETRY_COMPONENT = 'obd'
27+
TELEMETRY_SIG = 'dbe97393a695335d67de91dd4049ba'
2628

2729
# obdeploy version
2830
VERSION = '<VERSION>'

core.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def call_plugin(self, plugin, repository, spacename=None, target_servers=None, *
165165
'namespace': self.get_namespace(repository.name if spacename == None else spacename),
166166
'namespaces': self.namespaces,
167167
'deploy_name': None,
168+
'deploy_status': None,
168169
'cluster_config': None,
169170
'repositories': self.repositories,
170171
'repository': repository,
@@ -176,6 +177,7 @@ def call_plugin(self, plugin, repository, spacename=None, target_servers=None, *
176177
}
177178
if self.deploy:
178179
args['deploy_name'] = self.deploy.name
180+
args['deploy_status'] = self.deploy.deploy_info.status
179181
args['components'] = self.deploy.deploy_info.components
180182
args['cluster_config'] = self.deploy.deploy_config.components[repository.name]
181183
if "clients" not in kwargs:
@@ -2962,13 +2964,15 @@ def redeploy_cluster(self, name, search_repo=True, need_confirm=False):
29622964
self.set_repositories(repositories)
29632965
return self._deploy_cluster(deploy, repositories) and self._start_cluster(deploy, repositories)
29642966

2965-
def destroy_cluster(self, name):
2967+
def destroy_cluster(self, name, need_confirm=False):
29662968
self._call_stdio('verbose', 'Get Deploy by name')
29672969
deploy = self.deploy_manager.get_deploy_config(name)
29682970
self.set_deploy(deploy)
29692971
if not deploy:
29702972
self._call_stdio('error', 'No such deploy: %s.' % name)
29712973
return False
2974+
if need_confirm and not self._call_stdio('confirm', FormtatText.warning('Are you sure to destroy the "%s" cluster ?' % name)):
2975+
return False
29722976

29732977
deploy_info = deploy.deploy_info
29742978

example/mini-distributed-example.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ oceanbase-ce:
2727
datafile_size: 2G # Size of the data file.
2828
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
2929
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
30-
log_disk_size: 13G # The size of disk space used by the clog files.
30+
log_disk_size: 14G # The size of disk space used by the clog files.
3131
cpu_count: 16
3232
production_mode: false
3333
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.

example/mini-distributed-with-obproxy-example.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ oceanbase-ce:
2727
datafile_size: 2G # Size of the data file.
2828
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
2929
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
30-
log_disk_size: 13G # The size of disk space used by the clog files.
30+
log_disk_size: 14G # The size of disk space used by the clog files.
3131
cpu_count: 16
3232
production_mode: false
3333
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.

example/mini-local-example.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ oceanbase-ce:
2424
datafile_size: 2G # Size of the data file.
2525
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
2626
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
27-
log_disk_size: 13G # The size of disk space used by the clog files.
27+
log_disk_size: 14G # The size of disk space used by the clog files.
2828
cpu_count: 16
2929
production_mode: false
3030
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.

example/mini-single-example.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ oceanbase-ce:
3131
datafile_size: 2G # Size of the data file.
3232
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
3333
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
34-
log_disk_size: 13G # The size of disk space used by the clog files.
34+
log_disk_size: 14G # The size of disk space used by the clog files.
3535
cpu_count: 16
3636
production_mode: false
3737
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.

example/mini-single-with-obproxy-example.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ oceanbase-ce:
3131
datafile_size: 2G # Size of the data file.
3232
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
3333
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
34-
log_disk_size: 13G # The size of disk space used by the clog files.
34+
log_disk_size: 14G # The size of disk space used by the clog files.
3535
cpu_count: 16
3636
production_mode: false
3737
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.

plugins/general/0.1/telemetry_info_collect.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import resource
2828
import hashlib
2929

30-
from tool import NetUtil
31-
from const import VERSION, REVISION
32-
30+
from tool import NetUtil, COMMAND_ENV
31+
from const import VERSION, REVISION, TELEMETRY_COMPONENT
32+
from _environ import ENV_TELEMETRY_REPORTER
3333

3434
shell_command_map = {
3535
"host_type": 'systemd-detect-virt',
@@ -64,7 +64,7 @@ def wrapper(*args, **kwargs):
6464
class BaseInfo:
6565
@staticmethod
6666
def reporter():
67-
return 'obd'
67+
return COMMAND_ENV.get(ENV_TELEMETRY_REPORTER, TELEMETRY_COMPONENT)
6868

6969
@staticmethod
7070
def report_time():

plugins/general/0.1/telemetry_post.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import json
2424
import requests
2525

26-
from const import TELEMETRY_URL
26+
from const import TELEMETRY_URL, TELEMETRY_COMPONENT, TELEMETRY_SIG
2727
from tool import timeout
2828

2929

@@ -34,7 +34,9 @@ def telemetry_post(plugin_context, telemetry_post_data={}, *args, **kwargs):
3434
stdio.verbose('post data: %s' % data)
3535
try:
3636
with timeout(30):
37-
requests.post(url=TELEMETRY_URL, data=json.dumps({'content': data}), headers={'sig': 'dbe97393a695335d67de91dd4049ba', 'Content-Type': 'application/json'})
37+
requests.post(url=TELEMETRY_URL, \
38+
data=json.dumps({'component': TELEMETRY_COMPONENT, 'content': data}), \
39+
headers={'sig': TELEMETRY_SIG, 'Content-Type': 'application/json'})
3840
return plugin_context.return_true()
3941
except:
4042
stdio.exception('post data failed')

plugins/grafana/7.5.17/restart.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, plugin_context, local_home_path, start_plugin, reload_plugin,
3030
self.namespace = plugin_context.namespace
3131
self.namespaces = plugin_context.namespaces
3232
self.deploy_name = plugin_context.deploy_name
33+
self.deploy_status = plugin_context.deploy_status
3334
self.repositories = plugin_context.repositories
3435
self.plugin_name = plugin_context.plugin_name
3536

@@ -60,6 +61,7 @@ def call_plugin(self, plugin, **kwargs):
6061
'namespace': self.namespace,
6162
'namespaces': self.namespaces,
6263
'deploy_name': self.deploy_name,
64+
'deploy_status': self.deploy_status,
6365
'cluster_config': self.cluster_config,
6466
'repositories': self.repositories,
6567
'repository': self.repository,

plugins/ob-configserver/1.0.0/restart.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, plugin_context, local_home_path, start_check_plugin, start_pl
3030
self.namespace = plugin_context.namespace
3131
self.namespaces = plugin_context.namespaces
3232
self.deploy_name = plugin_context.deploy_name
33+
self.deploy_status = plugin_context.deploy_status
3334
self.repositories = plugin_context.repositories
3435
self.plugin_name = plugin_context.plugin_name
3536

@@ -61,6 +62,7 @@ def call_plugin(self, plugin, **kwargs):
6162
'namespace': self.namespace,
6263
'namespaces': self.namespaces,
6364
'deploy_name': self.deploy_name,
65+
'deploy_status': self.deploy_status,
6466
'cluster_config': self.cluster_config,
6567
'repositories': self.repositories,
6668
'repository': self.repository,

plugins/obagent/0.1/restart.py

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(self, plugin_context, local_home_path, start_plugin, reload_plugin,
3232
self.namespace = plugin_context.namespace
3333
self.namespaces = plugin_context.namespaces
3434
self.deploy_name = plugin_context.deploy_name
35+
self.deploy_status = plugin_context.deploy_status
3536
self.repositories = plugin_context.repositories
3637
self.plugin_name = plugin_context.plugin_name
3738

@@ -66,6 +67,7 @@ def call_plugin(self, plugin, **kwargs):
6667
'namespace': self.namespace,
6768
'namespaces': self.namespaces,
6869
'deploy_name': self.deploy_name,
70+
'deploy_status': self.deploy_status,
6971
'cluster_config': self.cluster_config,
7072
'repositories': self.repositories,
7173
'repository': self.repository,

plugins/obagent/0.1/upgrade.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ def call_plugin(plugin, plugin_context, repositories, *args, **kwargs):
2727
namespace = plugin_context.namespace
2828
namespaces = plugin_context.namespaces
2929
deploy_name = plugin_context.deploy_name
30+
deploy_status = plugin_context.deploy_status
3031
components = plugin_context.components
3132
clients = plugin_context.clients
3233
cluster_config = plugin_context.cluster_config
3334
cmds = plugin_context.cmds
3435
options = plugin_context.options
3536
stdio = plugin_context.stdio
36-
return plugin(namespace, namespaces, deploy_name, repositories, components, clients, cluster_config, cmds, options,
37+
return plugin(namespace, namespaces, deploy_name, deploy_status, repositories, components, clients, cluster_config, cmds, options,
3738
stdio, *args, **kwargs)
3839

3940

plugins/obagent/1.3.0/restart.py

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(self, plugin_context, local_home_path, start_check_plugin, start_pl
3232
self.namespace = plugin_context.namespace
3333
self.namespaces = plugin_context.namespaces
3434
self.deploy_name = plugin_context.deploy_name
35+
self.deploy_status = plugin_context.deploy_status
3536
self.repositories = plugin_context.repositories
3637
self.plugin_name = plugin_context.plugin_name
3738

@@ -66,6 +67,7 @@ def call_plugin(self, plugin, **kwargs):
6667
'namespace': self.namespace,
6768
'namespaces': self.namespaces,
6869
'deploy_name': self.deploy_name,
70+
'deploy_status': self.deploy_status,
6971
'cluster_config': self.cluster_config,
7072
'repositories': self.repositories,
7173
'repository': self.repository,

plugins/obagent/1.3.0/upgrade.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ def call_plugin(plugin, plugin_context, repositories, *args, **kwargs):
2727
namespace = plugin_context.namespace
2828
namespaces = plugin_context.namespaces
2929
deploy_name = plugin_context.deploy_name
30+
deploy_status = plugin_context.deploy_status
3031
components = plugin_context.components
3132
clients = plugin_context.clients
3233
cluster_config = plugin_context.cluster_config
3334
cmds = plugin_context.cmds
3435
options = plugin_context.options
3536
stdio = plugin_context.stdio
36-
return plugin(namespace, namespaces, deploy_name, repositories, components, clients, cluster_config, cmds, options,
37+
return plugin(namespace, namespaces, deploy_name, deploy_status, repositories, components, clients, cluster_config, cmds, options,
3738
stdio, *args, **kwargs)
3839

3940

0 commit comments

Comments
 (0)