Skip to content

Commit

Permalink
V2.6.1 (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
frf12 authored Feb 5, 2024
1 parent 4c3a9a8 commit 4740aa7
Show file tree
Hide file tree
Showing 69 changed files with 514 additions and 373 deletions.
9 changes: 5 additions & 4 deletions _cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def lock_mode(self):

@property
def enable_log(self):
return COMMAND_ENV.get(ENV.TELEMETRY_LOG_MODE, default='0') == '1'
return COMMAND_ENV.get(ENV.ENV_TELEMETRY_LOG_MODE, default='0') == '1'

def init(self, cmd, args):
super(TelemetryPostCommand, self).init(cmd, args)
Expand All @@ -459,7 +459,7 @@ def __init__(self):
self.register_command(TelemetryPostCommand())

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

def _do_command(self, obd):
if self.cmds:
res = obd.destroy_cluster(self.cmds[0])
res = obd.destroy_cluster(self.cmds[0], need_confirm=not getattr(self.opts, 'confirm', False))
return res
else:
return self._show_help()
Expand Down Expand Up @@ -1082,7 +1083,7 @@ def __init__(self):
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='%'")

def _do_command(self, obd):
if self.cmds:
if len(self.cmds) == 1:
return obd.create_tenant(self.cmds[0])
else:
return self._show_help()
Expand Down
2 changes: 1 addition & 1 deletion _deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def __eq__(self, other):
def __deepcopy__(self, memo):
cluster_config = self.__class__(deepcopy(self.servers), self.name, self.version, self.tag, self.release, self.package_hash, self.parser)
copy_attrs = ['origin_tag', 'origin_version', 'origin_package_hash', 'parser', 'added_servers']
deepcopy_attrs = ['_temp_conf', '_default_conf', '_global_conf', '_server_conf', '_cache_server', '_original_global_conf', '_depends', '_original_servers', '_inner_config']
deepcopy_attrs = ['_temp_conf', '_all_default_conf', '_default_conf', '_global_conf', '_server_conf', '_cache_server', '_original_global_conf', '_depends', '_original_servers', '_inner_config']
for attr in copy_attrs:
setattr(cluster_config, attr, getattr(self, attr))
for attr in deepcopy_attrs:
Expand Down
7 changes: 5 additions & 2 deletions _environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@
ENV_DISABLE_PARALLER_EXTRACT = "OBD_DISALBE_PARALLER_EXTRACT"

# telemetry mode. 0 - disable, 1 - enable.
TELEMETRY_MODE = "TELEMETRY_MODE"
ENV_TELEMETRY_MODE = "TELEMETRY_MODE"

# telemetry log mode. 0 - disable, 1 - enable.
TELEMETRY_LOG_MODE = "TELEMETRY_LOG_MODE"
ENV_TELEMETRY_LOG_MODE = "TELEMETRY_LOG_MODE"

# telemetry reporter. {reporter name}
ENV_TELEMETRY_REPORTER = "TELEMETRY_REPORTER"

# ROOT IO DEFAULT CONFIRM. 0 - disable, 1 - enable.
ENV_DEFAULT_CONFIRM = "IO_DEFAULT_CONFIRM"
Expand Down
17 changes: 9 additions & 8 deletions _plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ def return_false(self, *args, **kwargs):

class PluginContext(object):

def __init__(self, plugin_name, namespace, namespaces, deploy_name, repositories, components, clients, cluster_config, cmd, options, dev_mode, stdio):
def __init__(self, plugin_name, namespace, namespaces, deploy_name, deploy_status, repositories, components, clients, cluster_config, cmd, options, dev_mode, stdio):
self.namespace = namespace
self.namespaces = namespaces
self.deploy_name = deploy_name
self.deploy_status = deploy_status
self.repositories =repositories
self.plugin_name = plugin_name
self.components = components
Expand Down Expand Up @@ -244,7 +245,7 @@ def __del__(self):
self._export()

def before_do(
self, plugin_name, namespace, namespaces, deploy_name,
self, plugin_name, namespace, namespaces, deploy_name, deploy_status,
repositories, components, clients, cluster_config, cmd,
options, stdio, *arg, **kwargs
):
Expand All @@ -254,7 +255,7 @@ def before_do(
for server in clients:
sub_clients[server] = ScriptPlugin.ClientForScriptPlugin(clients[server], sub_stdio)
self.context = PluginContext(
plugin_name, namespace, namespaces, deploy_name, repositories, components,
plugin_name, namespace, namespaces, deploy_name, deploy_status, repositories, components,
sub_clients, cluster_config, cmd, options, self.dev_mode, sub_stdio
)
namespace.set_return(plugin_name, None)
Expand All @@ -266,11 +267,11 @@ def after_do(self, stdio, *arg, **kwargs):

def pyScriptPluginExec(func):
def _new_func(
self, namespace, namespaces, deploy_name,
self, namespace, namespaces, deploy_name, deploy_status,
repositories, components, clients, cluster_config, cmd,
options, stdio, *arg, **kwargs
):
self.before_do(self.name, namespace, namespaces, deploy_name,
self.before_do(self.name, namespace, namespaces, deploy_name, deploy_status,
repositories, components, clients, cluster_config, cmd,
options, stdio, *arg, **kwargs)
method_name = self.PLUGIN_NAME
Expand Down Expand Up @@ -337,14 +338,14 @@ def __init__(self, component_name, plugin_path, version, dev_mode):
self.libs_path.append(self.plugin_path)

def __call__(
self, namespace, namespaces, deploy_name,
self, namespace, namespaces, deploy_name, deploy_status,
repositories, components, clients, cluster_config, cmd,
options, stdio, *arg, **kwargs
):
method = getattr(self, self.PLUGIN_NAME, False)
if method:
return method(
namespace, namespaces, deploy_name,
namespace, namespaces, deploy_name, deploy_status,
repositories, components, clients, cluster_config, cmd,
options, stdio, *arg, **kwargs
)
Expand Down Expand Up @@ -794,7 +795,7 @@ def set_plugin_type(plugin_type):
@pyScriptPluginExec
def %s(
self, namespace, namespaces, deploy_name,
self, namespace, namespaces, deploy_name, deploy_status,
repositories, components, clients, cluster_config, cmd,
options, stdio, *arg, **kwargs):
pass
Expand Down
10 changes: 9 additions & 1 deletion _stdio.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,12 @@ def _stop_buffer_io(self):
def set_verbose_level(level):
IO.VERBOSE_LEVEL = level

@property
def syncing(self):
if self._root_io:
return self._root_io.syncing
return self.sync_obj is not None

def _start_sync_obj(self, sync_clz, before_critical, *arg, **kwargs):
if self._root_io:
return self._root_io._start_sync_obj(sync_clz, before_critical, *arg, **kwargs)
Expand Down Expand Up @@ -667,8 +673,9 @@ def confirm(self, msg):
msg = '%s [y/n]: ' % msg
self.print(msg, end='')
if self.default_confirm:
self.verbose("default confirm: True")
return True
if self._input_is_tty:
if self.isatty() and not self.syncing:
while True:
try:
ans = self.get_input_stream().readline(blocked=True).strip().lower()
Expand All @@ -680,6 +687,7 @@ def confirm(self, msg):
if not e:
return False
else:
self.verbose("isatty: %s, syncing: %s, auto confirm: False" % (self.isatty(), self.syncing))
return False

def _format(self, msg, *args):
Expand Down
2 changes: 2 additions & 0 deletions const.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# post telemetry data to OceanBase official
TELEMETRY_WEBSITE = '<TELEMETRY_WEBSITE>'
TELEMETRY_URL = '{}/api/web/oceanbase/report'.format(TELEMETRY_WEBSITE if TELEMETRY_WEBSITE else 'https://openwebapi.oceanbase.com')
TELEMETRY_COMPONENT = 'obd'
TELEMETRY_SIG = 'dbe97393a695335d67de91dd4049ba'

# obdeploy version
VERSION = '<VERSION>'
Expand Down
6 changes: 5 additions & 1 deletion core.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def call_plugin(self, plugin, repository, spacename=None, target_servers=None, *
'namespace': self.get_namespace(repository.name if spacename == None else spacename),
'namespaces': self.namespaces,
'deploy_name': None,
'deploy_status': None,
'cluster_config': None,
'repositories': self.repositories,
'repository': repository,
Expand All @@ -176,6 +177,7 @@ def call_plugin(self, plugin, repository, spacename=None, target_servers=None, *
}
if self.deploy:
args['deploy_name'] = self.deploy.name
args['deploy_status'] = self.deploy.deploy_info.status
args['components'] = self.deploy.deploy_info.components
args['cluster_config'] = self.deploy.deploy_config.components[repository.name]
if "clients" not in kwargs:
Expand Down Expand Up @@ -2962,13 +2964,15 @@ def redeploy_cluster(self, name, search_repo=True, need_confirm=False):
self.set_repositories(repositories)
return self._deploy_cluster(deploy, repositories) and self._start_cluster(deploy, repositories)

def destroy_cluster(self, name):
def destroy_cluster(self, name, need_confirm=False):
self._call_stdio('verbose', 'Get Deploy by name')
deploy = self.deploy_manager.get_deploy_config(name)
self.set_deploy(deploy)
if not deploy:
self._call_stdio('error', 'No such deploy: %s.' % name)
return False
if need_confirm and not self._call_stdio('confirm', FormtatText.warning('Are you sure to destroy the "%s" cluster ?' % name)):
return False

deploy_info = deploy.deploy_info

Expand Down
2 changes: 1 addition & 1 deletion example/mini-distributed-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ oceanbase-ce:
datafile_size: 2G # Size of the data file.
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
log_disk_size: 13G # The size of disk space used by the clog files.
log_disk_size: 14G # The size of disk space used by the clog files.
cpu_count: 16
production_mode: false
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
Expand Down
2 changes: 1 addition & 1 deletion example/mini-distributed-with-obproxy-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ oceanbase-ce:
datafile_size: 2G # Size of the data file.
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
log_disk_size: 13G # The size of disk space used by the clog files.
log_disk_size: 14G # The size of disk space used by the clog files.
cpu_count: 16
production_mode: false
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
Expand Down
2 changes: 1 addition & 1 deletion example/mini-local-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ oceanbase-ce:
datafile_size: 2G # Size of the data file.
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
log_disk_size: 13G # The size of disk space used by the clog files.
log_disk_size: 14G # The size of disk space used by the clog files.
cpu_count: 16
production_mode: false
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
Expand Down
2 changes: 1 addition & 1 deletion example/mini-single-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ oceanbase-ce:
datafile_size: 2G # Size of the data file.
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
log_disk_size: 13G # The size of disk space used by the clog files.
log_disk_size: 14G # The size of disk space used by the clog files.
cpu_count: 16
production_mode: false
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
Expand Down
2 changes: 1 addition & 1 deletion example/mini-single-with-obproxy-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ oceanbase-ce:
datafile_size: 2G # Size of the data file.
datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
log_disk_size: 13G # The size of disk space used by the clog files.
log_disk_size: 14G # The size of disk space used by the clog files.
cpu_count: 16
production_mode: false
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
Expand Down
8 changes: 4 additions & 4 deletions plugins/general/0.1/telemetry_info_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import resource
import hashlib

from tool import NetUtil
from const import VERSION, REVISION

from tool import NetUtil, COMMAND_ENV
from const import VERSION, REVISION, TELEMETRY_COMPONENT
from _environ import ENV_TELEMETRY_REPORTER

shell_command_map = {
"host_type": 'systemd-detect-virt',
Expand Down Expand Up @@ -64,7 +64,7 @@ def wrapper(*args, **kwargs):
class BaseInfo:
@staticmethod
def reporter():
return 'obd'
return COMMAND_ENV.get(ENV_TELEMETRY_REPORTER, TELEMETRY_COMPONENT)

@staticmethod
def report_time():
Expand Down
6 changes: 4 additions & 2 deletions plugins/general/0.1/telemetry_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import json
import requests

from const import TELEMETRY_URL
from const import TELEMETRY_URL, TELEMETRY_COMPONENT, TELEMETRY_SIG
from tool import timeout


Expand All @@ -34,7 +34,9 @@ def telemetry_post(plugin_context, telemetry_post_data={}, *args, **kwargs):
stdio.verbose('post data: %s' % data)
try:
with timeout(30):
requests.post(url=TELEMETRY_URL, data=json.dumps({'content': data}), headers={'sig': 'dbe97393a695335d67de91dd4049ba', 'Content-Type': 'application/json'})
requests.post(url=TELEMETRY_URL, \
data=json.dumps({'component': TELEMETRY_COMPONENT, 'content': data}), \
headers={'sig': TELEMETRY_SIG, 'Content-Type': 'application/json'})
return plugin_context.return_true()
except:
stdio.exception('post data failed')
Expand Down
2 changes: 2 additions & 0 deletions plugins/grafana/7.5.17/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, plugin_context, local_home_path, start_plugin, reload_plugin,
self.namespace = plugin_context.namespace
self.namespaces = plugin_context.namespaces
self.deploy_name = plugin_context.deploy_name
self.deploy_status = plugin_context.deploy_status
self.repositories = plugin_context.repositories
self.plugin_name = plugin_context.plugin_name

Expand Down Expand Up @@ -60,6 +61,7 @@ def call_plugin(self, plugin, **kwargs):
'namespace': self.namespace,
'namespaces': self.namespaces,
'deploy_name': self.deploy_name,
'deploy_status': self.deploy_status,
'cluster_config': self.cluster_config,
'repositories': self.repositories,
'repository': self.repository,
Expand Down
2 changes: 2 additions & 0 deletions plugins/ob-configserver/1.0.0/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, plugin_context, local_home_path, start_check_plugin, start_pl
self.namespace = plugin_context.namespace
self.namespaces = plugin_context.namespaces
self.deploy_name = plugin_context.deploy_name
self.deploy_status = plugin_context.deploy_status
self.repositories = plugin_context.repositories
self.plugin_name = plugin_context.plugin_name

Expand Down Expand Up @@ -61,6 +62,7 @@ def call_plugin(self, plugin, **kwargs):
'namespace': self.namespace,
'namespaces': self.namespaces,
'deploy_name': self.deploy_name,
'deploy_status': self.deploy_status,
'cluster_config': self.cluster_config,
'repositories': self.repositories,
'repository': self.repository,
Expand Down
2 changes: 2 additions & 0 deletions plugins/obagent/0.1/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, plugin_context, local_home_path, start_plugin, reload_plugin,
self.namespace = plugin_context.namespace
self.namespaces = plugin_context.namespaces
self.deploy_name = plugin_context.deploy_name
self.deploy_status = plugin_context.deploy_status
self.repositories = plugin_context.repositories
self.plugin_name = plugin_context.plugin_name

Expand Down Expand Up @@ -66,6 +67,7 @@ def call_plugin(self, plugin, **kwargs):
'namespace': self.namespace,
'namespaces': self.namespaces,
'deploy_name': self.deploy_name,
'deploy_status': self.deploy_status,
'cluster_config': self.cluster_config,
'repositories': self.repositories,
'repository': self.repository,
Expand Down
3 changes: 2 additions & 1 deletion plugins/obagent/0.1/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ def call_plugin(plugin, plugin_context, repositories, *args, **kwargs):
namespace = plugin_context.namespace
namespaces = plugin_context.namespaces
deploy_name = plugin_context.deploy_name
deploy_status = plugin_context.deploy_status
components = plugin_context.components
clients = plugin_context.clients
cluster_config = plugin_context.cluster_config
cmds = plugin_context.cmds
options = plugin_context.options
stdio = plugin_context.stdio
return plugin(namespace, namespaces, deploy_name, repositories, components, clients, cluster_config, cmds, options,
return plugin(namespace, namespaces, deploy_name, deploy_status, repositories, components, clients, cluster_config, cmds, options,
stdio, *args, **kwargs)


Expand Down
2 changes: 2 additions & 0 deletions plugins/obagent/1.3.0/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, plugin_context, local_home_path, start_check_plugin, start_pl
self.namespace = plugin_context.namespace
self.namespaces = plugin_context.namespaces
self.deploy_name = plugin_context.deploy_name
self.deploy_status = plugin_context.deploy_status
self.repositories = plugin_context.repositories
self.plugin_name = plugin_context.plugin_name

Expand Down Expand Up @@ -66,6 +67,7 @@ def call_plugin(self, plugin, **kwargs):
'namespace': self.namespace,
'namespaces': self.namespaces,
'deploy_name': self.deploy_name,
'deploy_status': self.deploy_status,
'cluster_config': self.cluster_config,
'repositories': self.repositories,
'repository': self.repository,
Expand Down
3 changes: 2 additions & 1 deletion plugins/obagent/1.3.0/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ def call_plugin(plugin, plugin_context, repositories, *args, **kwargs):
namespace = plugin_context.namespace
namespaces = plugin_context.namespaces
deploy_name = plugin_context.deploy_name
deploy_status = plugin_context.deploy_status
components = plugin_context.components
clients = plugin_context.clients
cluster_config = plugin_context.cluster_config
cmds = plugin_context.cmds
options = plugin_context.options
stdio = plugin_context.stdio
return plugin(namespace, namespaces, deploy_name, repositories, components, clients, cluster_config, cmds, options,
return plugin(namespace, namespaces, deploy_name, deploy_status, repositories, components, clients, cluster_config, cmds, options,
stdio, *args, **kwargs)


Expand Down
Loading

0 comments on commit 4740aa7

Please sign in to comment.