Repository navigation
fix(server): workspace 创建 receipt 与当前容器不匹配导致 Space 永久死锁 - #30
Merged
Merged
Conversation
receipt 只证明过去发生过一次创建,不证明容器现在还活着。以下两种真实场景 都会让 reconcileWorkspaceCreate 永久失败,且 workspace_create_operations 从不清理,Space 只能一直停在 error: 1. docker.recreate(节点镜像更新)会重建 v1 工作区容器,保留名字、标签和 create-digest,但 DockerID 变了;旧逻辑用 DockerID 硬比较 -> 永久不匹配。 2. 容器被带外删除后,receipt 仍是 committed,而 docker.list 观测为空 -> 同样永久不匹配。 修复: - 观测到的容器只要满足 op.matches(名字 + 全部标签 + digest)就视为同一逻辑 效果并重绑,不再比较 DockerID;observeSpaceWorkspace 已保证同一 space/ instance 只有一个容器,因此不会放过真正的重复创建。 - 观测为空时用 docker.inspect 精确确认 receipt 容器是否真的不存在;仅当 Docker 明确返回 no such object 时,在同一把 fence 下清除陈旧 operation, 返回 errWorkspaceCreateVoided。启动路径会据此创建新的 operation;恢复路径 只会把 Space 结算为 stopped,绝不重建容器。 - 传输失败、超时或其它 inspect 错误仍保持原语义(保留 intent,交给人处理)。 测试覆盖 recreated / missing-container 两个场景,旧代码可精确复现 "workspace creation receipt does not match the current container"。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现象
自建控制面上某个 Space 永久卡在:
之后无论怎么点启动,都返回同一句错误,空间再也起不来。
现场数据:
根因
workspace_create_operations是持久意图,只插入、从不删除;reconcileWorkspaceCreate用 DockerID 做硬比较,于是下面两种真实场景都会永久失败:docker.recreate(节点镜像更新)会重建 v1 工作区容器。specFromInspectJSON保留了全部标签(zakura.create-operation、zakura.create-digest等),但 DockerID 变了 → receipt 与观测到的容器 ID 永远不同。committed,而docker.list为空 →op.matches因DockerID == ""失败 → 同样永久报错。由于没有任何路径能清掉这条 operation,Space 只能一直
error。修复
A. 容器身份用标签证明,而不是 DockerID
op.matches已经校验名字 + 全部 operation 标签 +create-operation+create-digest;而observeSpaceWorkspace保证同一 space/instance 最多一个容器,所以 ID 变化只可能是同一个逻辑容器被重建,重绑是安全的(不会放过真正的重复创建)。B. 确认容器真的不存在时,清除陈旧意图
观测为空时用
docker.inspect精确检查 receipt 里的容器 ID:no such object才判定"效果已不存在",在同一把 fence 下删除该 operation,返回errWorkspaceCreateVoided;op = nil后走原有 create 流程);stopped;验证
单测新增两个场景(
recreated、missing-container),并做了反向验证:生产环境热修后,同一 Space:
备注
workspace_migration_orchestrator)对errWorkspaceCreateVoided仍按失败处理:迁移中容器消失属于真实故障,不应静默重建。