feat(library): 目标维护窗口(持久所有权/独占/release-on-verify)+ known-broken 记录
build / build (push) Failing after 16s
build / build (push) Failing after 16s
为什么:用户确认维护窗口方案,需要真实占有目标而不是 503 页面。 - 迁移 000070 library_maintenance:scope 唯一持有者、作业/目标身份、服务原状态、阶段。 - worker 在写目标前 acquire,验证+登记成功才 release;回滚失败/未验证保持 needs_restore。 - API GET /library/maintenance + 同步入口在他人持有时 409。 - 已知缺陷如实记录:候选实例该路由 404;kill 取证脚本竞态导致三项断言为 false。
This commit is contained in:
@@ -447,6 +447,27 @@ func NewHandler(config Config) (http.Handler, error) {
|
||||
libraryStorageHandler(w, r, config)
|
||||
})
|
||||
})
|
||||
// 目标维护窗口状态:谁持有、处于哪个阶段、何时释放。
|
||||
mux.HandleFunc("GET /api/v1/library/maintenance", func(w http.ResponseWriter, r *http.Request) {
|
||||
scope := r.URL.Query().Get("scope")
|
||||
if scope != "internal" && scope != "external" {
|
||||
writeJSON(w, http.StatusBadRequest, map[string]string{"error": "scope must be internal or external"})
|
||||
return
|
||||
}
|
||||
store, ok := config.Store.(interface {
|
||||
LibraryMaintenanceOf(ctx context.Context, scope string) (*postgresstore.LibraryMaintenance, error)
|
||||
})
|
||||
if !ok {
|
||||
writeJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "维护窗口存储不可用"})
|
||||
return
|
||||
}
|
||||
held, err := store.LibraryMaintenanceOf(r.Context(), scope)
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": "无法读取维护窗口"})
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{"held": held != nil && held.ReleasedAt == nil, "maintenance": held})
|
||||
})
|
||||
mux.HandleFunc("GET /api/v1/library/jobs", func(w http.ResponseWriter, r *http.Request) {
|
||||
libraryJobsHandler(w, r, config)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user