Skip to content

fix(storage): namespace Redis ID key - #29

Open
yangruike wants to merge 1 commit into
flashcatcloud:masterfrom
yangruike:fix/redis-id-key-prefix
Open

fix(storage): namespace Redis ID key#29
yangruike wants to merge 1 commit into
flashcatcloud:masterfrom
yangruike:fix/redis-id-key-prefix

Conversation

@yangruike

Copy link
Copy Markdown

问题背景

ibex 的 Redis ID 生成器目前使用全局 Key id

当 Nightingale 使用 Redis ACL,并仅授权带命名空间的 Key,例如 n9e_* 时,服务启动阶段无法访问 id,并出现以下错误:

cannot init id generator: NOPERM No permissions to access a key

id 缺少明确的业务前缀,在多个应用共用 Redis 的场景下,不利于最小权限配置和 Key 管理。

关联 Issue:ccfos/nightingale#3284

修改内容

  • 新增包内私有常量 idKey
  • 将 Redis ID 生成器使用的 Key 从 id 修改为 n9e_ibex_id
  • IdInitIdGet 统一使用 idKey
  • 保持 IDINITIAL 的值不变
  • 保持启动时重置计数器的现有行为不变
  • 不迁移或删除旧的 id Key
  • 不修改其他业务逻辑

修改后,n9e_ibex_id 可以被现有的 n9e_* Redis ACL 规则覆盖。

验证结果

  • gofmt -w src/storage/redis.go:通过
  • git diff --check:通过
  • go test ./src/storage:通过,该包当前无测试文件,编译检查成功

执行 go test ./... 时,项目现有的 Nightingale Router API 兼容问题导致部分包编译失败,涉及 rt.Authrt.Userrt.Permrt.Bgrw。该问题与本次 Redis Key 修改无关,因此未在本 PR 中处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant