已关闭
[Bug]: LocalCheckSE.py capture_output 不兼容 Python3.6(跟进8300,需代码修复) #8347
wuchenlong创建于  7月24日关闭于  22 天前
wuchenlong
wuchenlong成员
7月24日 创建

测试类型

工具功能

测试版本

7.0.0LTS

问题描述

openGauss 7.0.0 B015 安装包中 gs_checkse 调用的 LocalCheckSE.py,在 getDatabaseInfo() 使用了 Python 3.7+ 专有参数 subprocess.run(..., capture_output=True, text=True)。当系统默认 python3 为 3.6.x 时(CentOS 7、RHEL 7、部分存量 CI/生产节点仍常见),执行 gs_checkse 会失败。

与 #8300 的关系:#8300 已以「更新资料声明 Python 版本要求」验收关闭(docs !8741),但 server 仓 LocalCheckSE.py 源码未修改,B015 包中第 220 行仍为 capture_output=True。开发以「openEuler 24.03 自带 Python 3.11」为由改文档,无法覆盖 CentOS/RHEL 等仍使用 Python 3.6 的场景。

期望:修改工具脚本使其兼容 Python 3.6(官方安装指南仍面向多发行版),而非仅通过文档限定 OS/Python 版本规避。

操作系统和硬件信息

Python 3.6 运行环境(典型:CentOS 7.x / RHEL 7.x,系统默认 python3 为 3.6.x);本地复现验证:aarch64 Linux + Python 3.6.15

测试环境

企业版主备

被测功能

gs_checkse / LocalCheckSE.py(安全检查工具)

预置条件

已安装 openGauss 7.0.0 B015 集群;系统 PATH 中 python3 指向 3.6.x(与 CentOS 7 / RHEL 7 等存量环境一致)

操作步骤

# 1. 确认 Python 版本为 3.6
python3 --version
# 预期:Python 3.6.x

# 2. 确认安装包中问题代码仍存在
grep -n capture_output $GAUSSHOME/../tool/script/local/LocalCheckSE.py
# 预期:220:    result = subprocess.run(cmd_args, capture_output=True, text=True)

# 3. 直接调用 LocalCheckSE.py(与 gs_checkse 内部调用一致)
source $GAUSSHOME/../gauss_env
python3 $GAUSSHOME/../tool/script/local/LocalCheckSE.py \
  -t Check_Connection_configuration \
  -l /tmp/gs_local.log --database=postgres

# 4. 最小化复现(subprocess.run capture_output 在 3.6 下不可用)
python3 -c "import subprocess; subprocess.run(['echo','test'], capture_output=True, text=True)"

预期输出

LocalCheckSE.py 正常完成 Connection configuration 检查;
subprocess.run 在 Python 3.6 下可正常执行(或使用 3.6 兼容写法)。

实际输出

# LocalCheckSE.py(Python 3.6.15)
[FATAL_CRASH] Action:Check_Connection_configuration, Exception:__init__() got an unexpected keyword argument 'capture_output'
  File ".../LocalCheckSE.py", line 220, in getDatabaseInfo
    result = subprocess.run(cmd_args, capture_output=True, text=True)
TypeError: __init__() got an unexpected keyword argument 'capture_output'

# 最小化复现(Python 3.6.15)
TypeError: __init__() got an unexpected keyword argument 'capture_output'

日志信息

关联 issue:https://gitcode.com/opengauss/openGauss-server/issues/8300(已关闭,仅改 docs)
关联 docs MR:https://gitcode.com/opengauss/docs/merge_requests/8741

问题代码位置(7.0.0 B015 安装包):
  cluster/tool/script/local/LocalCheckSE.py:220
  result = subprocess.run(cmd_args, capture_output=True, text=True)

capture_output / text 为 Python 3.7 新增参数(PEP 578 之前 subprocess.run 签名不含此参数)。

建议修复(兼容 3.6):
  result = subprocess.run(
      cmd_args,
      stdout=subprocess.PIPE,
      stderr=subprocess.PIPE,
      universal_newlines=True,
  )

本地复现脚本:issues/issue-to-submit/repro_gs_checkse_py36.py
本地复现输出:issues/issue-to-submit/result_localcheckse_py36.txt

提单组织

测试团队

likedislike
wuchenlongwuchenlong成员
7月24日 添加了label:bug
opengauss_bot
opengauss_bot成员
7月24日 评论:

This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.

likedislike
opengauss_botopengauss_bot成员
7月24日 添加了label:sig/StorageEngine,sig/AI,sig/CM,sig/CloudNative,sig/SecurityTechnology,sig/SQLEngine
opengauss_bot
opengauss_bot成员
7月24日 评论:

Welcome To openGauss Community

Hey @wuchenlong , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: StorageEngine, AI, CM, CloudNative, SecurityTechnology, SQLEngine ,
and any of the maintainers: @CarrotGo, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @hwworkholic, @jemappellehc, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @totaj, @wlff234, @wofanzheng, @ywzq1161327784 ,
and any of the committers: @Igali, @bihua111, @cailei19, @h_ray, @levy53071, @libiao2024, @lihaixiao, @mrzack, @wangfeihuo, @wuyuechuan, @xiong_xjun, @zhangfengzhi123, @zhangxubo, @zhangzq131, @zjh_hw .

likedislike
opengauss_botopengauss_bot成员
7月24日 将 TestManager 设为负责人
opengauss_botopengauss_bot成员
7月24日 添加了label:sig/StorageEngine,sig/SQLEngine,sig/SecurityTechnology,sig/CM,sig/CloudNative,sig/AI
wuchenlongwuchenlong成员
8月3日 issue优先级由 无优先级 改变为 次要
wuchenlongwuchenlong成员
8月3日 关联了看板:openGauss 7.0.0-LTS
shenzheng4shenzheng4成员
8月5日 移除了负责人 TestManager
opengauss_bot
opengauss_bot成员
8月5日 评论:

This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.

likedislike
opengauss_botopengauss_bot成员
8月5日 将 TestManager 设为负责人
shenzheng4shenzheng4成员
8月5日 将 wang4721 设为负责人,移除负责人 TestManager
wangchaowangchao成员
8月11日 关联了pull request:getDatabaseInfo远程命令兼容python3.6
wangchaowangchao成员
8月13日 issue状态由 待办的 改变为 已完成
wangchao
wangchao成员
27 天前 评论:

B019版本自验证
安装数据库,查看系统版本,python版本
image.png

执行相关验证

image.png

likedislike
wangchaowangchao成员
27 天前 issue状态由 已完成 改变为 待回归
wuchenlong
wuchenlong成员
22 天前 评论:

【回归版本】openGauss 7.0.0-RC3 build a2d43dcd(7.0.0LTS B019,compiled at 2026-08-19 00:10:18)
【回归日期】20260824
【回归人员】wuchenlong
【回归结论】通过

测试结果

B019 安装包 LocalCheckSE.py 已将 subprocess.run(..., capture_output=True, text=True) 改为 Python 3.6 兼容写法 stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True;在 Python 3.6.15 下执行 Check_Connection_configuration 正常完成(exit=0),不再出现 unexpected keyword argument 'capture_output'

说明

历史异常:B015 包在 Python 3.6 下因 capture_output(3.7+)崩溃。B019 已修复脚本兼容性。

【回归步骤】

# 1. 源码确认
grep -n capture_output $GAUSSHOME/../tool/script/local/LocalCheckSE.py
# 实际:无命中;第 220 行为 PIPE 写法

# 2. Python 3.6 下跑 LocalCheckSE
/tmp/py36/bin/python3.6 .../LocalCheckSE.py \
  -t Check_Connection_configuration \
  -l /tmp/gs_local.log --database=postgres

执行结果:见 result_B019.txt(LocalCheckSE exit=0;最小 repro 仍验证 3.6 本身不支持 capture_output)。

likedislike
wuchenlongwuchenlong成员
22 天前 issue状态由 待回归 改变为 已验收
wuchenlongwuchenlong成员
22 天前 关闭了 issue