已开启
fix(volume): validate volume args at request entrypoint #173
jing-rui创建于 24 天前
fix(volume): validate volume args at request entrypoint #173
已开启
jing-rui创建于 24 天前
jing-rui
24 天前

Was This PR authored or co-authored using generative AI tooling?

[ ] No

[x] Yes
__1. AI Agent : Codex:GPT-5.6-sol
__2. AI Model :
__3. Prompt :

Reference: openEuler Community Generative AI Use and Open Source Contribution Policy

What this PR does / why we need it:

Which issue this PR fixes

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

likedislike
合并受阻
Jjing-rui
24 天前 创建了 pull request,commit 828c5466
atomgit-bot
atomgit-bot
24 天前 评论:

变更摘要

本 PR 的核心目标是将 volume 挂载参数校验提前到请求入口(CreateSandbox 阶段),使非法挂载在创建 sandbox 状态之前即被拒绝。具体做法是:在 internal/conchruntimeService 中新增 VolumeManager 字段与 SetVolumeManager 注入方法,新增 validateVolumeMountsCreateSandbox 中调用,并将原本分散在 internal/sandbox/manager.gointernal/volume/manager.go 的校验逻辑抽取为 volume.Manager.ValidateMounts(mounts, resumeBoot),其中"快照恢复(warm)模板不支持 volume_mounts"的拒绝逻辑从 sandbox 管理器上移至此入口校验。此外该 PR 还顺带改进了 netstack.Pool.Close 的并发清理逻辑、重写了 examples/volume.py 示例脚本,并将 Makefile 的 build-offline 目标替换为 static 目标。

主要改动

  • 入口处校验 volume 挂载:在 conchruntime.Service 中新增 VolumeManager 字段、SetVolumeManager 注入方法与 validateVolumeMounts 方法,在 CreateSandbox 中(网络配置校验之后)调用,基于模板的 BootMode 是否为 BootModeResume 判断是否允许挂载,并由 internal/daemon/daemon.go 完成 SetVolumeManager 的装配。
  • 抽取 ValidateMounts 校验逻辑internal/volume/manager.go 将原本内嵌于 PrepareSandbox 的校验(最大挂载数、目标路径绝对/禁阻/去重、源路径非空且绝对等)抽成独立的 ValidateMounts(mounts, resumeBoot)PrepareSandbox 改为先调用该校验(以非 resume 方式),错误信息中补充了 volume.max_mounts 配置项说明。
  • 移除 sandbox 层的 resume 拒绝逻辑internal/sandbox/manager.goprepareVolumes 不再接收 resume 参数,也不再在创建流程中直接拒绝"带 volumeMounts 的快照恢复启动",该判断统一上移到入口校验。
  • netstack.Pool.Close 并发清理internal/netstack/pool.go 在关闭时将缓冲的 Slot 全部弹出并脱离队列,随后通过信号量限定的固定并发数(cleanupWorkers = 16)配合 sync.WaitGroup 并行销毁网络槽位,并增加耗时追踪日志,避免停机清理压垮主机网络栈。
  • volume 示例脚本与构建目标调整examples/volume.py 改为支持通过 -n 参数一次性挂载多个卷(1–99 个)、以 CONCH_TEMPLATE_ID 环境变量传入模板 ID、挂载基路径改为 ./debug/shared,并重构了写入/读取/删除流程;Makefilebuild-offline 替换为静态构建的 static 目标。
likedislike
不准确?
atomgit-bot
atomgit-bot
24 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
openeuler-ci-botopeneuler-ci-bot成员
24 天前 将weibaohui,yangzhao_kl,jimmieme,duguhaotian,wonleing,zmr_2020,gaodaweiky,lu-wei-army,zhaoyifan28设为审查人
openeuler-ci-botopeneuler-ci-bot成员
24 天前 添加了label:sig/sig-CloudNative
openeuler-ci-bot
openeuler-ci-bot成员
24 天前 评论:

Welcome To openEuler Community

Hey @jing-rui , 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: sig-CloudNative ,
and any of the maintainers: @duguhaotian, @gaodaweiky, @jimmieme, @lu-wei-army, @weibaohui, @wonleing, @yangzhao_kl, @zhaoyifan28, @zmr_2020 ,
and any of the committers: @Yekelu .

likedislike
openeuler-ci-botopeneuler-ci-bot成员
24 天前 添加了label:stat/needs-squashai-co-authored
openeuler-ci-botopeneuler-ci-bot成员
24 天前 添加了label:ai-includes-code
openeuler-ci-botopeneuler-ci-bot成员
24 天前 添加了label:openeuler-cla/yes
openeuler-ci-bot
openeuler-ci-bot成员
24 天前 评论:

CLA Signature Pass

jing-rui, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
openeuler-ci-botopeneuler-ci-bot成员
24 天前 添加了label:ai-compliance-successful