已合并
docs: update template store semantics #179
docs: update template store semantics #179
已合并
zhaoyifan28创建于 8 天前
zhaoyifan28成员
8 天前

背景

Template 元数据当前同时保存在 state.db 和 containerd Canonical Image Record 中,存在双重 owner 及跨 Store 一致性问题。
改动

将 Canonical Image Record 作为 Template metadata 的唯一 source of truth 和 GC root。
使用 containerd content labels、短生命周期 lease 和原生 GC 管理 Boot Index descriptor closure。
调整 Create、Pull 和 Checkpoint 流程,确保完整 Image Record 在 lease 释放前发布。
Template 删除仅解除 Canonical Image Record,并使用 target digest 防止并发误删。
从 bbolt 中移除 Template CRUD,仅保留 Sandbox 状态和 checkpoint head CAS。
对请求取消后的临时 image record 执行限时清理,避免残留 GC root。

边界

本次不迁移已有 state.db/templates 数据,测试及部署升级需使用干净数据目录。
Sandbox metadata 迁移不在本 PR 范围内。
底层 Content 由 containerd 异步 GC 回收,不保证删除后磁盘空间立即释放。

验证

受影响包单元测试通过。
Race test 和 go vet 通过。
conch、conchd 构建通过。
likedislike
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 zhaoyifan28 的贡献)
Zzhaoyifan28成员
8 天前 创建了 pull request,commit bc9e6502
atomgit-bot
atomgit-bot
8 天前 评论:

变更摘要

本 PR 重构 Template 元数据的存储语义:将 containerd Canonical Image Record 作为 Template 元数据的唯一 source of truth 与 GC root,移除 state.db(bbolt)中 Template 的 CRUD,同时调整 Create、Pull、Checkpoint 流程,使其在短生命周期 lease 释放前发布完整 Image Record,并利用 containerd 原生 GC 与内容标签管理 Boot Index descriptor closure。新增基于 containerd images.Store/content.Storecontainerdtemplate.Store 实现 conchtemplate.Storestate.Store 接口仅保留 Sandbox 状态与 checkpoint head 的 CAS 更新。

主要改动

  • Template 元数据迁移至 containerd:新增 internal/adapters/containerd/template/store.go,以 io.conch.template.* 系列标签(schemaoriginparentsource-sandboxsource-refuser. 前缀)编码 Template 元数据到 Canonical Image Record,并删除 internal/template/store.go 中基于 StateStorePersistentStore/NewStoreStore 接口的 Create 签名改为接收 ocispec.Descriptor target 参数。

  • bbolt 移除 Template CRUD,保留 checkpoint head CASinternal/daemon/state/bbolt.go 删除 templates bucket 及 CreateTemplate/GetTemplate/ListTemplates/DeleteTemplate/PublishCheckpoint,新增 AdvanceCheckpointHead(sandboxID, expectedDigest, nextDigest) 在单事务内校验并推进 checkpoint head;state.Store 接口同步收敛为仅含该 CAS 方法。

  • 调整 Checkpoint/Pull/Create 流程与 lease 生命周期internal/conchruntime/service.go 中 Checkpoint 与 Pull 流程改用 WithLease 创建内容 lease,在 lease 释放前通过 Templates.Create 发布完整 Image Record;createTemplateFromSource 同样在 publish lease 内创建记录,CAS 失败时通过 cleanupTemplateRecord 回滚。

  • 删除仅解除 Canonical Image Record 并防并发误删Store.Delete 校验 record.Target.Digest 与请求 digest 一致后调用 images.DeleteTarget 删除记录,RemoveTemplate 简化为直接调用 Templates.Delete,同时删除 internal/image/bootindex_publish.go 中旧的 EnsureCanonicalBootIndexRecord/RemoveCanonicalBootIndexRecord

  • 请求取消后的临时记录限时清理internal/image/image.go 新增 RemoveFetchedImageRecord,使用 context.WithoutCancel 加 10 秒超时清理拉取产生的临时 image record;PublishBootIndexResult/PullBootIndexResult/PublishCheckpointBootIndexResult 增加 Target 描述符(及 SourceImageName)字段供下游创建记录。

likedislike
atomgit-bot
atomgit-bot
8 天前 评论:

🤖 AI 代码检视正在进行中,请稍候…

likedislike
openeuler-ci-botopeneuler-ci-bot成员
8 天前 添加了label:sig/sig-CloudNative
openeuler-ci-bot
openeuler-ci-bot成员
8 天前 评论:

Welcome To openEuler Community

Hey @zhaoyifan28 , 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. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

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 天前 添加了label:stat/needs-squash
openeuler-ci-botopeneuler-ci-bot成员
8 天前 添加了label:openeuler-cla/yes
openeuler-ci-bot
openeuler-ci-bot成员
8 天前 评论:

CLA Signature Pass

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

likedislike
Yekelu
Yekelu成员
8 天前 评论:

/lgtm
/approve

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

Review Code Feedback

  • The label lgtm, approved was added to this pull request. It means that Yekelu 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 天前 合入了pull request,合并节点 SHA:cf3dcede0243336d38181f143e218981c3aacd18