fix(library): 死信解除绑定封存源实例而不是同步目标
build / build (push) Successful in 1m18s

同步目标与封存源常常不是同一个实例(kgseal vs kgmaint);用目标名去绑来源死信,
真实观测的 project 永远对不上,解除会被一律拒绝。新增 LIBRARY_SOURCE_INSTANCE,
留空回落到目标实例名,API 写记录与 worker 取指纹共用同一个来源实例名。

试过:真实 API GET/POST、go test ./internal/{httpapi,appconfig} 与 make verify 全绿。
This commit is contained in:
姚章浩
2026-10-29 07:13:18 +08:00
parent c542a1333a
commit e508abd958
6 changed files with 31 additions and 3 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ func deadLetterReleaseHandlers(w http.ResponseWriter, r *http.Request, config Co
writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "死信解除存储不可用"})
return
}
instance := strings.TrimSpace(config.LibraryTargetInstance)
instance := strings.TrimSpace(config.SourceInstance())
if instance == "" {
writeJSON(w, http.StatusServiceUnavailable, map[string]any{
"code": "dead_letter_release_unwired", "reason": "未接线:没有配置来源实例身份,无法绑定解除记录",
+11
View File
@@ -148,6 +148,8 @@ type Config struct {
// LibraryTargetInstance 是实例级维护的目标实例名;留空即"未接线",
// 页面不能发起按预备份恢复,接口返回原因而不是假装能恢复。
LibraryTargetInstance string
// LibrarySourceInstance 是死信解除记录的来源实例名(封存源),留空回落到目标实例名。
LibrarySourceInstance string
// LibraryAgentSocket 是主机侧封存 agent 的 unix socket;留空即页面不能发起封存。
LibraryAgentSocket string
// LibraryCapacityBudgetBytes 是整库归档容量预算;0 = 未设置(容量门禁不放行)。
@@ -2807,3 +2809,12 @@ func writeJSON(w http.ResponseWriter, status int, value any) {
w.WriteHeader(status)
_ = json.NewEncoder(w).Encode(value)
}
// SourceInstance 是死信解除记录绑定的实例名:来源实例与同步目标常常不是同一个,
// 用目标名去绑来源死信会让真实观测永远对不上。
func (config Config) SourceInstance() string {
if config.LibrarySourceInstance != "" {
return config.LibrarySourceInstance
}
return config.LibraryTargetInstance
}