fix(library): 排空证据要读闸门记录的 active_at_close
build / build (push) Successful in 1m16s

闸门写的是 active_at_close / drain_ms,Go 侧却去读 active(排空后必然 0)
与 waited_ms(已改名),于是证据里恒显示"关闭时无在途连接"。改为读真实字段。
This commit is contained in:
姚章浩
2026-10-29 00:12:10 +08:00
parent 96fffb5081
commit ec737a9a65
+11 -6
View File
@@ -106,11 +106,15 @@ func (g *dockerGate) container(ctx context.Context) (gateInspection, error) {
return data, nil
}
// drainRecord 是闸门自己写的现场:关闭瞬间还有多少在途连接(active_at_close)、
// 等了多久(drain_ms)、一共服务过多少连接(served)。
type drainRecord struct {
Phase string `json:"phase"`
Active int `json:"active"`
Served int `json:"served"`
WaitedMS int64 `json:"waited_ms"`
Phase string `json:"phase"`
Active int `json:"active"`
ActiveAtClose int `json:"active_at_close"`
Served int `json:"served"`
DrainMS int64 `json:"drain_ms"`
UptimeMS int64 `json:"uptime_ms"`
}
func (g *dockerGate) readDrain() (drainRecord, error) {
@@ -184,8 +188,9 @@ func (g *dockerGate) CloseIngress(ctx context.Context) (libraryfreeze.GateEviden
return libraryfreeze.GateEvidence{}, fmt.Errorf("入口排空未确认(phase=%s exit=%d active=%d)",
record.Phase, data.State.ExitCode, record.Active)
}
return libraryfreeze.GateEvidence{Closed: true, Drained: true, ActiveAtClose: record.Active,
Served: record.Served, Detail: fmt.Sprintf("gate exit=0 phase=%s waited_ms=%d", record.Phase, record.WaitedMS)}, nil
return libraryfreeze.GateEvidence{Closed: true, Drained: true, ActiveAtClose: record.ActiveAtClose,
Served: record.Served, Detail: fmt.Sprintf("gate exit=0 phase=%s drain_ms=%d active_at_close=%d",
record.Phase, record.DrainMS, record.ActiveAtClose)}, nil
}
// OpenIngress:把闸门拉起来并等健康检查通过;能不能真的服务由入口探针再确认一次。