已合并
fix(volume): destroy sandbox when virtiofsd exits #167
dengchi创建于 8月14日
fix(volume): destroy sandbox when virtiofsd exits #167
已合并
dengchi创建于 8月14日
dengchi
8月14日

fix(volume): destroy sandbox when virtiofsd exits

likedislike
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 dengchi 的贡献)
Ddengchi
8月14日 创建了 pull request,commit e50f6532
atomgit-bot
atomgit-bot
8月14日 评论:

变更摘要

本 PR 主要修复了当 virtiofsd 进程异常退出时,沙箱未被及时销毁的问题。核心做法是在 internal/volume/types.goDevice 结构体中新增运行时专用的 Exited 退出信号通道(通过 json:"-" 排除持久化),由 internal/volume/virtiofs.go 中的 watchVirtiofs 监听 exec.Cmd.Wait() 并在进程退出时关闭该通道;同时调整 Cleanup 逻辑,使其在销毁前等待 virtiofsd 进程真正退出并设置超时。internal/sandbox/manager.gotrackSandbox 则通过 waitForSandboxExit 同时监听 VMM 退出和 virtiofsd 退出,任一触发即执行沙箱清理。

主要改动

  • 新增 Device.Exited 退出信号通道:在 internal/volume/types.go 中为 Device 增加 Exited <-chan struct{} 字段并使用 json:"-" 标记,用于在运行时传递 virtiofsd 进程退出事件且不参与持久化。
  • 新增 watchVirtiofs 监听进程退出:在 internal/volume/virtiofs.go 中新增 watchVirtiofs(cmd *exec.Cmd) <-chan struct{},通过后台 cmd.Wait() 并在结束后关闭通道;Prepare 成功时将该通道写入 Device.Exited
  • 调整 Prepare 的失败清理路径:当 waitUnixSocket 失败时,改为在 Kill 后等待 exited 通道(仅当 kill 成功或返回 unix.ESRCH/os.ErrProcessDone 时),避免进程尚未退出就继续清理。
  • 改造 Cleanup 等待进程真正退出:将 procs.LoadAndDelete 改为 Load,在 Kill 后通过 devices[0].Exited 等待进程退出,并引入 processExitTimeout = 5 * time.Second 超时;同时增加对 cmd.Process == nil 和缺失退出信号的错误处理。
  • 沙箱管理器监听 virtiofsd 退出internal/sandbox/manager.goCreate 捕获 volumeDevices[0].Exited 并传入 trackSandbox;新增 waitForSandboxExit(vmmExit, virtiofsExit),在 VMM 退出或 virtiofsd 退出任一事件发生时触发 handleSandboxExit,从而销毁沙箱。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月14日 评论:

代码审查

✅ 未发现问题

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

Welcome To openEuler Community

Hey @dcrlike , 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成员
8月14日 添加了label:openeuler-cla/no
Ddengchi
8月14日 预合并成功(commit_id: 87a56f52902d7703ff35fb9d1b323705ac2546ee)
Ddengchi
8月14日 强制推送  1 个提交:cd1e1648-fix(volume): destroy sandbox when virtiofsd exits
Ddengchi
8月14日 预合并成功(commit_id: 93daf8e7bd68bfc04df2ba9edfc3531b761ec758)
dengchi
8月14日 评论:

/check-cla

likedislike
Ddengchi
8月14日 预合并成功(commit_id: 7a5ae2cfa71fcefdd07594f52f2cf644f738bfc5)
此处折叠了6条事件消息 查看更多
openeuler-ci-botopeneuler-ci-bot成员
8月14日 添加了label:openeuler-cla/yes
openeuler-ci-bot
openeuler-ci-bot成员
8月14日 评论:

CLA Signature Pass

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

likedislike
jing-rui
8月14日 评论:

/lgtm
/approve

likedislike
openeuler-ci-bot
openeuler-ci-bot成员
8月14日 评论:

Label Command Feedback

  • Thanks for your review, your opinion is very important to us. The maintainers will consider your advice carefully.
  • The label(s) lgtm permission is outside.
  • Thanks for your review, your opinion is very important to us. The maintainers will consider your advice carefully.
  • The label(s) approved permission is outside.
likedislike
zhaoyifan28成员
8月14日 评论:

/lgtm
/approve

likedislike
openeuler-ci-botopeneuler-ci-bot成员
8月14日 添加了label:approvedlgtm
openeuler-ci-bot
openeuler-ci-bot成员
8月14日 评论:

Review Code Feedback

  • The label lgtm, approved was added to this pull request. It means that zhaoyifan28 reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
openeuler-ci-botopeneuler-ci-bot成员
8月14日 合入了pull request,合并节点 SHA:5618719472fcb1ac084414ed18948fcb7fe49fa0