feat: 实现 PostgreSQL 所有权 registry #4

Merged
panxiao81 merged 2 commits from feature/postgresql-registry into main 2026-09-10 10:59:10 +00:00
Owner

概要

实现 issue #1 的 PostgreSQL registry adapter。registry 只保存所有权、安装身份和 Retain tombstone,不保存 controller phase。

  • 引入 pgx/v5 v5.11.0
  • 幂等 bootstrap 固定 schema/table 并校验 schema version
  • 参数化 SQL 保存 Instance/Tenant UID、namespace/name、database、role 和 Bao path
  • Claim 支持首次创建、同 owner 幂等重试及唯一资源冲突
  • MarkRetained 写入不可重新认领的 unmanaged tombstone
  • Delete 要求完整 Ownership 匹配,拒绝 retained/mismatched record,重复删除安全
  • integration test 覆盖 bootstrap、claim、conflict、Get、Retain 和 Delete
  • 新增 make test-integration,未提供 DSN 的普通 test 会安全 skip 实际数据库测试

验证

  • make lint:通过
  • git diff --check:通过
  • 本地未运行数据库测试;PR Tests 会编译测试,实际 Docker 执行由后续 stacked CI PR 接入

Refs #1

## 概要 实现 issue #1 的 PostgreSQL registry adapter。registry 只保存所有权、安装身份和 Retain tombstone,不保存 controller phase。 - 引入 `pgx/v5 v5.11.0` - 幂等 bootstrap 固定 schema/table 并校验 schema version - 参数化 SQL 保存 Instance/Tenant UID、namespace/name、database、role 和 Bao path - `Claim` 支持首次创建、同 owner 幂等重试及唯一资源冲突 - `MarkRetained` 写入不可重新认领的 unmanaged tombstone - `Delete` 要求完整 Ownership 匹配,拒绝 retained/mismatched record,重复删除安全 - integration test 覆盖 bootstrap、claim、conflict、Get、Retain 和 Delete - 新增 `make test-integration`,未提供 DSN 的普通 test 会安全 skip 实际数据库测试 ## 验证 - `make lint`:通过 - `git diff --check`:通过 - 本地未运行数据库测试;PR Tests 会编译测试,实际 Docker 执行由后续 stacked CI PR 接入 Refs #1
panxiao81 added 1 commit 2026-09-10 09:30:32 +00:00
feat: 实现 PostgreSQL 所有权 registry
E2E Tests / Run on Ubuntu (pull_request) Failing after 52s
Tests / Run on Ubuntu (pull_request) Successful in 6m46s
Lint / Run on Ubuntu (pull_request) Successful in 9m12s
558df2bbcd
@@ -0,0 +80,4 @@
ClaimOwned ClaimResult = "Owned"
)
// Bootstrap creates the private schema and the current registry table idempotently.
Author
Owner

要么用bootstrap脚本在init容器里跑,要么用migrate,不要用土办法

要么用bootstrap脚本在init容器里跑,要么用migrate,不要用土办法
panxiao81 marked this conversation as resolved
@@ -0,0 +126,4 @@
}
defer func() { _ = tx.Rollback(ctx) }()
commandTag, err := tx.Exec(ctx, claimStatement,
Author
Owner

pg sql有RETURN的

pg sql有RETURN的
panxiao81 marked this conversation as resolved
@@ -0,0 +16,4 @@
package registry
var bootstrapStatements = []string{
Author
Owner

索引怎么说,两个ID复合够吗(应该够了吧

索引怎么说,两个ID复合够吗(应该够了吧
panxiao81 marked this conversation as resolved
panxiao81 added 1 commit 2026-09-10 09:51:55 +00:00
fix: address PostgreSQL registry review
E2E Tests / Run on Ubuntu (pull_request) Failing after 50s
Tests / Run on Ubuntu (pull_request) Successful in 4m28s
Lint / Run on Ubuntu (pull_request) Successful in 5m5s
9e5fbe6dfb
panxiao81 merged commit 6220a917e4 into main 2026-09-10 10:59:10 +00:00
panxiao81 deleted branch feature/postgresql-registry 2026-09-10 10:59:10 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: panxiao81/postgresql-tenant-operator#4