@@ -90,8 +90,27 @@ func productionScopeState(ctx context.Context, config Config, scope string) (boo
|
||||
v071.ProductionScope{TenantID: config.LibraryProductionTenantID, KnowledgeBaseID: kb})
|
||||
}
|
||||
|
||||
// productionScopeEmpty 保留"只问空不空"的调用形状;逐表行数在需要举证时用
|
||||
// productionScopeState 取。
|
||||
// unknownLibraryTarget distinguishes an empty target from unreadable state.
|
||||
// Overview and enqueue share this probe; neither may infer nonempty from failure.
|
||||
func unknownLibraryTarget(ctx context.Context, config Config, scope string) libraryKnownView {
|
||||
probe := config.LibraryScopeProbe
|
||||
if probe == nil {
|
||||
probe = func(ctx context.Context, scope string) (bool, map[string]int64, error) {
|
||||
return productionScopeState(ctx, config, scope)
|
||||
}
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
empty, _, err := probe(ctx, scope)
|
||||
if err != nil {
|
||||
return libraryKnownView{State: "unreachable", Reason: "无法读取目标整库状态:请检查目标连接后重试,不能据此判定空库或建立基线"}
|
||||
}
|
||||
if empty {
|
||||
return libraryKnownView{State: "unknown", EmptyBaseline: true, Reason: "生产目标可读且为空:本次是首次发布,写入前仍会生成完整预备份"}
|
||||
}
|
||||
return libraryKnownView{State: "unknown", Reason: "目标非空且尚无权威版本"}
|
||||
}
|
||||
|
||||
func productionScopeEmpty(ctx context.Context, config Config, scope string) (bool, error) {
|
||||
empty, _, err := productionScopeState(ctx, config, scope)
|
||||
return empty, err
|
||||
@@ -638,7 +657,9 @@ func librarySyncGateWithGrant(config Config, production libraryKnownView, prebac
|
||||
// 这就是一个合法的"空基线",不应该被永久挡住。非空但无权威版本仍然阻断,
|
||||
// 指向真实可行的入口(在维护隔离下捕获目标整库并校验后登记基线),
|
||||
// 而不是让人去手写版本或清空目标。
|
||||
if production.State != "known" && !production.EmptyBaseline {
|
||||
if production.State == "unreachable" {
|
||||
gate.Reasons = append(gate.Reasons, production.Reason)
|
||||
} else if production.State != "known" && !production.EmptyBaseline {
|
||||
gate.Reasons = append(gate.Reasons, "目标非空且没有生效版本记录:先建立目标权威基线(维护隔离下捕获整库并逐类校验),或确认目标确实是空库")
|
||||
}
|
||||
if target == "" {
|
||||
@@ -713,6 +734,8 @@ func libraryOverviewHandler(w http.ResponseWriter, r *http.Request, config Confi
|
||||
if hasCurrent {
|
||||
view := libraryVersionViewOf(current)
|
||||
overview.Production = libraryKnownView{State: "known", Version: &view}
|
||||
} else {
|
||||
overview.Production = unknownLibraryTarget(r.Context(), config, scope)
|
||||
}
|
||||
target := ""
|
||||
if overview.TestSealed != nil {
|
||||
@@ -879,9 +902,8 @@ func librarySyncEnqueue(w http.ResponseWriter, r *http.Request, config Config) {
|
||||
overview.Production = libraryKnownView{State: "known", Version: &view}
|
||||
}
|
||||
overview.Prebackup = libraryKnownView{State: "unknown"}
|
||||
if empty, probeErr := productionScopeEmpty(r.Context(), config, request.Scope); probeErr == nil && empty {
|
||||
overview.Production = libraryKnownView{State: "unknown", EmptyBaseline: true,
|
||||
Reason: "生产目标可读且为空:本次是首次发布,写入前仍会生成完整预备份"}
|
||||
if !hasCurrent {
|
||||
overview.Production = unknownLibraryTarget(r.Context(), config, request.Scope)
|
||||
}
|
||||
for index := range versions {
|
||||
item := versions[index]
|
||||
|
||||
Reference in New Issue
Block a user