fix(chv-hybrid): p2 热插盘 body 补 image_type + 非 2xx 记 CHV 原话
ci / test (push) Failing after 48m54s

- attach_tenant_data_disk:PUT /vm.add-disk body 由 {"path"} 改为
  {"path", "image_type"}(复用 _disk_image_type,与 create 时盘
  同款;租户数据盘 raw → Raw)。CHV v54 已移除盘格式自动探测,
  只发 path 时真机回 400(p2 复测);证据:v54 release notes
  “autodetection removed”、ch-remote v54.0 add-disk --help 含
  image_type=<raw,qcow2,...>、本仓 _vm_config_disks 的 vm.boot
  400 "Image type required for disk" 真机实测(2026-11-07)。
- 非 2xx 时 body 原样记入 data_disk_attach_failed 审计事件与
  ChvFailure detail(新增 _api_error_body_text,截断上限 500
  字符:CHV 400 体通常一行 JSON <200 字符,500 足够装完整原话;
  超长截断并标 "…(已截断)",保审计与异常串有界);同类问题一并
  修 _create_vm(vm_create_failed 带 body)。fail-closed 语义
  不变(失败仍销毁/回落,不把未挂盘的 VM 当已绑定)。
- 单测:attach 成功断言 image_type=Raw;新增 400 body 记录用例
  与超长截断用例;vm.create 失败 body 用例。
- 真机探针:chv-multi-host/probe-add-disk.py(px2,旧形状 A/B +
  产品函数成功路径 + 两条 400 记录路径,待复测代理跑)。

全量:Ran 4678,OK (skipped=14),0 失败/错误。
This commit is contained in:
host committed 2026-11-09 06:12:21 +00:00
1 parent 6c03ac9b0f
commit 0dc8328ecc
3 files changed
+101 -8

No files matched your search

+3 -1
View File
@@ -195,12 +195,14 @@ class WakeFailureTest(CloseupCase):
def api(socket_path, method, path, payload=None):
self.api_calls.append((method, path))
if method == "PUT" and path == "/vm.create":
return (500, {})
return (500, {"error": "boom-create"})
return (200, {})
ex = self.make_exec(api_client=api)
with self.assertRaises(ChvFailure) as ctx:
ex.wake_vm(self._task())
self.assertEqual(ctx.exception.kind, "vm_create_failed")
# p2 同类修复:vm.create 失败的 body 也须进异常 detail。
self.assertIn("boom-create", str(ctx.exception))
self.assertIn("vm_failed", self._audit_events())
self.assertEqual(ex._vms, {})
self.assertTrue(any(c[-1] == "shutdown" for c in self.calls))