已合并
feat(webhook): add sandbox lifecycle notifications #174
hu-zhangying创建于 17 天前
feat(webhook): add sandbox lifecycle notifications #174
已合并
hu-zhangying创建于 17 天前
hu-zhangying
hu-zhangying
17 天前

当前PR是否有AI参与:

[x] 否

[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

参考:openEuler社区《生成式AI工具使用与开源贡献政策》

PR功能描述 / 为什么需要这个合入**:

该PR关联的issue

(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #

希望检视人员了解:

likedislike
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 hu-zhangying 的贡献)
hu-zhangyinghu-zhangying
17 天前 创建了 pull request,commit 53c04ddd
atomgit-bot
atomgit-bot
17 天前 评论:

变更摘要

该 PR 为沙箱引入生命周期事件通知能力:新增 internal/webhook 包(内存注册的 Dispatcher、事件模型与异步 HTTP 投递)、新增 internal/id 包统一 ID 生成与校验,并在沙箱创建成功、被请求删除、意外退出时发布 sandbox.lifecycle.created / sandbox.lifecycle.killed 事件;daemon 侧新增 webhook 管理 API。同时为可靠识别"意外退出",将 VMM 进程退出信号从 <-chan error 重构为 driver.ProcessExit 接口,并让 Sandbox.Wait 透传进程退出错误。

主要改动

  • 新增 webhook 事件模块:新增 internal/webhook/webhook.go,定义 DispatcherWebhookEventExecution 等结构,支持 sandbox.lifecycle.createdsandbox.lifecycle.killed 两类事件;Dispatcher 仅在内存保存注册信息,事件发布时异步 POST 到订阅方 URL,失败最多重试 3 次。
  • 沙箱生命周期事件发布conchruntime.Service 新增 WebhookDispatcher 字段与 SetWebhookDispatcherCreateSandbox 成功后发布 EventSandboxCreatedRemoveSandbox 发布 EventSandboxKilledkill_reason="request");新增 HandleSandboxUnexpectedExit,将沙箱状态标记为 SandboxUnknown 并持久化后发布 EventSandboxKilledkill_reason="orphaned")。
  • 意外退出识别sandbox.Manager 新增 unexpectedExitHandlerSetUnexpectedExitHandlersandboxEntry 增加 expectedStop 标记并在 Delete 时置位;handleSandboxExit 仅在非预期退出时回调 handler,避免重复通知。
  • VMM 进程退出机制重构internal/vmm/driver 新增 ProcessExit 接口(Done()/Err()),ProcessexitDone channel 与 exitOnce/exitErr/cleanupOnce 取代原 exitSignal channel;AdapterWaitForCreateReadyWaitForRestoreReadyCheckAgentAlive 签名改为接收 driver.ProcessExit,cloud-hypervisor 与 stratovirt 适配器同步更新,Sandbox.Wait 改为透传进程退出错误。
  • 新增 webhook 管理 API 与 ID 模块合并:daemon 注册 POST /api/v1/events/webhooksGET /api/v1/events/webhooksDELETE /api/v1/events/webhooks/{webhookID} 路由及对应 handler,并新增 webhook.invalid / webhook.not_found 错误码;原 internal/sandboxid 包更名为 internal/id,新增 New() / NewWithPrefix() 统一 ID 生成。
likedislike
不准确?
atomgit-bot
atomgit-bot
17 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
openeuler-ci-botopeneuler-ci-bot成员
17 天前 将weibaohui,yangzhao_kl,jimmieme,duguhaotian,wonleing,zmr_2020,gaodaweiky,lu-wei-army,zhaoyifan28设为审查人
openeuler-ci-botopeneuler-ci-bot成员
17 天前 添加了label:sig/sig-CloudNative
此处折叠了61条消息 查看更多
openeuler-ci-bot
openeuler-ci-bot成员
14 天前 评论:

Review Code Feedback

  • The label lgtm 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
zhaoyifan28成员
14 天前 评论:

/approve

likedislike
openeuler-ci-botopeneuler-ci-bot成员
14 天前 添加了label:approved
openeuler-ci-bot
openeuler-ci-bot成员
14 天前 评论:

Review Code Feedback

  • The label 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成员
14 天前 合入了pull request,合并节点 SHA:fa93d571d97233267f2ffadbf6b8b179801eeaac