【 使用环境 】 测试环境
【 OB or 其他组件 】 oceanbase-ce
【 使用版本 】4.2.1.8
【问题描述】 集群reload报错
【附件及日志】
查看日志:
[2025-03-25 20:33:27.323] [DEBUG] -- obshell_port is not a oceanbase parameter. skip
[2025-03-25 20:33:27.323] [DEBUG] -- production_mode is not a oceanbase parameter. skip
[2025-03-25 20:33:27.323] [DEBUG] -- apply new configuration
[2025-03-25 20:33:27.323] [INFO] Reload observer
[2025-03-25 20:33:27.324] [DEBUG] -- execute sql: alter system reload server. args: None
[2025-03-25 20:33:27.326] [DEBUG] -- execute sql: alter system reload zone. args: None
[2025-03-25 20:33:27.330] [DEBUG] -- execute sql: alter system reload unit. args: None
[2025-03-25 20:33:27.455] [DEBUG] - sub reload ref count to 0
[2025-03-25 20:33:27.455] [DEBUG] - export reload
[2025-03-25 20:33:27.455] [DEBUG] - plugin oceanbase-ce-py_script_reload-4.2.1.4 result: True
[2025-03-25 20:33:27.455] [DEBUG] - Searching obshell_password_reload plugin for components ...
[2025-03-25 20:33:27.456] [DEBUG] - Searching obshell_password_reload plugin for oceanbase-ce-4.2.1.8-108000022024072217.el7-499b676f2ede5a16e0c07b2b15991d1160d972e8
[2025-03-25 20:33:27.456] [DEBUG] - Found for oceanbase-ce-py_script_obshell_password_reload-4.2.1.4 for oceanbase-ce-4.2.1.8
[2025-03-25 20:33:27.457] [DEBUG] - Call plugin oceanbase-ce-py_script_obshell_password_reload-4.2.1.4 for oceanbase-ce-4.2.1.8-108000022024072217.el7-499b676f2ede5a16e0c07b2b15991d1160d972e8
[2025-03-25 20:33:27.457] [DEBUG] - import obshell_password_reload
[2025-03-25 20:33:28.180] [DEBUG] - add obshell_password_reload ref count to 1
[2025-03-25 20:33:28.183] [ERROR] oceanbase-ce-py_script_obshell_password_reload-4.2.1.4 RuntimeError: 'NoneType' object is not iterable
[2025-03-25 20:33:28.183] [ERROR] Traceback (most recent call last):
[2025-03-25 20:33:28.183] [ERROR] File "core.py", line 2393, in reload_cluster
[2025-03-25 20:33:28.183] [ERROR] File "core.py", line 2437, in _reload_cluster
[2025-03-25 20:33:28.183] [ERROR] File "core.py", line 228, in run_workflow
[2025-03-25 20:33:28.183] [ERROR] File "core.py", line 270, in run_plugin_template
[2025-03-25 20:33:28.183] [ERROR] File "core.py", line 315, in call_plugin
[2025-03-25 20:33:28.184] [ERROR] File "_plugin.py", line 347, in __call__
[2025-03-25 20:33:28.184] [ERROR] File "_plugin.py", line 304, in _new_func
[2025-03-25 20:33:28.184] [ERROR] File "/home/dba/.obd/plugins/oceanbase-ce/4.2.1.4/obshell_password_reload.py", line 31, in obshell_password_reload
[2025-03-25 20:33:28.184] [ERROR] for key in global_change_conf:
[2025-03-25 20:33:28.184] [ERROR] TypeError: 'NoneType' object is not iterable
[2025-03-25 20:33:28.184] [ERROR]
[2025-03-25 20:33:28.184] [DEBUG] - sub obshell_password_reload ref count to 0
[2025-03-25 20:33:28.184] [DEBUG] - export obshell_password_reload
[2025-03-25 20:33:28.184] [DEBUG] - plugin oceanbase-ce-py_script_obshell_password_reload-4.2.1.4 result: False
[2025-03-25 20:33:28.186] [DEBUG] - open /home/dba/.obd/cluster/mediatest_ocpserver_ce/inner_config.yaml for w
[2025-03-25 20:33:28.204] [WARNING] Some configuration items reload failed
[2025-03-25 20:33:28.209] [INFO] See https://www.oceanbase.com/product/ob-deployer/error-codes .
[2025-03-25 20:33:28.209] [INFO] Trace ID: 588553ea-0975-11f0-8bfb-246e96c6abc8
[2025-03-25 20:33:28.210] [INFO] If you want to view detailed obd logs, please run: obd display-trace 588553ea-0975-11f0-8bfb-246e96c6abc8
[2025-03-25 20:33:28.210] [DEBUG] - unlock /home/dba/.obd/lock/global
[2025-03-25 20:33:28.211] [DEBUG] - unlock /home/dba/.obd/lock/deploy_mediatest_ocpserver_ce
[2025-03-25 20:33:28.211] [DEBUG] - unlock /home/dba/.obd/lock/mirror_and_repo
shell:~/.obd/plugins/oceanbase-ce/4.2.1.4$ cat /home/dba/.obd/plugins/oceanbase-ce/4.2.1.4/obshell_password_reload.py
# coding: utf-8
# Copyright (c) 2025 OceanBase.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
from obshell import ClientSet
from obshell.auth import PasswordAuth
from _errno import EC_OBSERVER_INVALID_MODFILY_GLOBAL_KEY
def obshell_password_reload(plugin_context, *args, **kwargs):
global_ret = True
stdio = plugin_context.stdio
cluster_config = plugin_context.cluster_config
servers = cluster_config.servers
global_change_conf = plugin_context.get_variable('global_change_conf')
change_conf = plugin_context.get_variable('change_conf')
server = cluster_config.servers[0]
for key in global_change_conf:
try:
value = change_conf[server][key] if change_conf[server].get(key) is not None else ''
if key == 'root_password':
for server in servers:
stdio.verbose('update %s obshell password' % (server))
server_config = cluster_config.get_server_conf(server)
obshell_port = server_config.get('obshell_port')
client = ClientSet(server.ip, obshell_port, PasswordAuth(value))
client.v1.get_ob_info()
except:
stdio.exception("")
global_ret = False
if not global_ret:
return plugin_context.return_false()
return plugin_context.return_true()
由于这个问题可能一直会导致 obd cluster reload 不完全成功。
看上去是因为 因 global_change_conf
为 None
而引发的错误 我尝试修改了一下脚本, 修改后的代码添加了对 global_change_conf
的检查,会先确认 global_change_conf
是否存在以及其中是否包含 root_password
。若不满足条件,就会输出日志信息并跳过密码更新逻辑,暂时先跨过了这个问题。
def obshell_password_reload(plugin_context, *args, **kwargs):
global_ret = True
stdio = plugin_context.stdio
cluster_config = plugin_context.cluster_config
servers = cluster_config.servers
global_change_conf = plugin_context.get_variable('global_change_conf')
change_conf = plugin_context.get_variable('change_conf')
# 这里检查 global_change_conf 是否存在且包含 root_password
if global_change_conf and 'root_password' in global_change_conf:
for key in global_change_conf:
if key == 'root_password':
value = global_change_conf[key]
for server in servers:
stdio.verbose('update %s obshell password' % (server))
server_config = cluster_config.get_server_conf(server)
obshell_port = server_config.get('obshell_port')
try:
client = ClientSet(server.ip, obshell_port, PasswordAuth(value))
client.v1.get_ob_info()
except Exception as e:
stdio.exception(f"Failed to update password for {server}: {str(e)}")
global_ret = False
else:
stdio.verbose("No root_password change required. Skipping password reload.")
return plugin_context.return_true() if global_ret else plugin_context.return_false()
@论坛小助手 辛苦同学帮忙看一下这个问题,如若我的修改不妥,看下可否通过其他方法跨过此问题。