vm_create on an existing VM name overwrites the VM and answers "VirtualMachine created successfully"
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with pkg/toolsets/kubevirt/vm/create/tool.go, especially the apply call near line 209 and the success response near line 220; the issue also describes a patch with a test, but does not name its test file. Reproduce the overwrite using the three-step scenario in the issue and compare the existing VM’s uid, run strategy, memory, and disks before and after. Done means vm_create handles an existing name as described in the expected behavior and its test covers the result.
由索引模型根据 Issue 内容生成。
描述
Version: v0.1.2 (66553fed). Still present on main (ec37a146, 2026-11-12): pkg/toolsets/kubevirt/vm/create/tool.go is unchanged; reproduced live on main 13bfb96f.
What happens
vm_create renders a VirtualMachine and applies it with Force: true (tool.go:209). Given the name of a VM that already exists, the apply rewrites it:
- the run strategy changes (a running VM with
runStrategy: AlwaysbecomesHaltedunlessautostartis set); - the disks and volumes are replaced (KubeVirt's lists are atomic, so the old disk is gone);
- the memory changes;
- the uid is unchanged.
The tool still answers # VirtualMachine created successfully (tool.go:220). A POST of the same object would return 409 AlreadyExists.
Reproduction (kind, Kubernetes v1.37.0, KubeVirt v1.9.0 CRDs; the identity can get and patch VirtualMachines in demo)
- Create VM
v1indemowithrunStrategy: Always, 1Gi of memory and a diskrootdiskfromfedora. - Call
vm_createwith{"namespace": "demo", "name": "v1", "workload": "ubuntu"}. - The answer is "VirtualMachine created successfully".
kubectl -n demo get vm v1 -o yamlshows the same uid,runStrategy: Halted, different memory (2Gi in our run), and the disk replaced byv1-rootdiskwith the ubuntu image.
Expected: vm_create refuses an existing name (or at least does not report "created"), and changes to an existing VM go through vm_lifecycle or resources_create_or_update.
The annotations (destructiveHint and idempotentHint both true) and the patch-only RBAC metadata suggest the upsert itself may be intended. If so, the result text should say the VM was updated, not created.
Possible fix: read the VM first. If it exists, return an error that names it with its uid and run strategy (this needs get added to the declared RBAC). We have a patch with a test (fix(kubevirt): refuse vm_create over an existing VirtualMachine) and can open a PR. It is a check-then-apply, so a VM created by someone else between the two requests can still be overwritten. Closing that window needs a create instead of an apply, which changes the declared verbs, so we left that for your call.
Found while reviewing the MCP server with AI assistance.
- 主要语言
- Go
- 星标
- 2.3k
- 派生
- 493
- 平均合并
- 2 天 8 小时
- 30 天内合并 PR
- 75
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
containers/kubernetes-mcp-server 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
containers/kubernetes-mcp-server#1715 ·
维护者通常 1 天内回复
-
Ensure all config values are logged after validation可能已有人在做 @ychampion 于 7 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
containers/kubernetes-mcp-server#1702 ·
维护者通常 1 天内回复
-
Integer tool arguments silently truncate fractional values (gracePeriodSeconds 0.5 becomes an immediate delete)可能已有人在做 @sarankumar1325 于 28 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
containers/kubernetes-mcp-server#1584 · 2 条评论 ·
维护者通常 1 天内回复
-
Fix NetObserv config lookup when toolset name is overridden可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
containers/kubernetes-mcp-server#1496 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
containers/kubernetes-mcp-server#1412 · 1 条评论 ·
维护者通常 1 天内回复
查看 containers/kubernetes-mcp-server 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
github/github-mcp-server#3960 ·
维护者通常 3 天内回复
-
难度 1/5 1 小时以内 新手友好度 78/100
JuliusBrussee/caveman#1594 ·
维护者通常 1 天内回复
-
C-bug O-community X-blathers-triaged
难度 2/5 1-3 小时 新手友好度 66/100
cockroachdb/cockroach#176264 · 1 条评论 ·