diff --git a/internal/librarymaintenance/gate.go b/internal/librarymaintenance/gate.go index aa1d046..5512488 100644 --- a/internal/librarymaintenance/gate.go +++ b/internal/librarymaintenance/gate.go @@ -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:把闸门拉起来并等健康检查通过;能不能真的服务由入口探针再确认一次。