Fix A: the stable-start sampler says at DEBUG why a sample is not ok (a live run on 9202 judged a healthy app unstable; the reason was not logged). Commit only.
gates / gates (push) Successful in 1m24s

This commit is contained in:
2026-10-25 16:43:57 +01:00
parent 2149a13378
commit 35232de80d
@@ -144,6 +144,7 @@ const (
// stableSample is one look: ok, and the fingerprint (container id → restart count) a stable window must keep. // stableSample is one look: ok, and the fingerprint (container id → restart count) a stable window must keep.
func (m *Manager) stableSample(stack string) (bool, map[string]int) { func (m *Manager) stableSample(stack string) (bool, map[string]int) {
if m.stackProvider == nil || !m.stackProvider.RefreshAndIsRunning(stack) { if m.stackProvider == nil || !m.stackProvider.RefreshAndIsRunning(stack) {
m.debugStable(stack, "the stack does not read running")
return false, nil return false, nil
} }
cs, ok := m.stackProvider.(containerSampler) cs, ok := m.stackProvider.(containerSampler)
@@ -152,11 +153,13 @@ func (m *Manager) stableSample(stack string) (bool, map[string]int) {
} }
samples, err := cs.ContainerSamples(stack) samples, err := cs.ContainerSamples(stack)
if err != nil || len(samples) == 0 { if err != nil || len(samples) == 0 {
m.debugStable(stack, fmt.Sprintf("no container sample (%d, err %v)", len(samples), err))
return false, nil return false, nil
} }
fp := make(map[string]int, len(samples)) fp := make(map[string]int, len(samples))
for _, c := range samples { for _, c := range samples {
if !c.Running || (c.Health != "" && c.Health != "healthy") { if !c.Running || (c.Health != "" && c.Health != "healthy") {
m.debugStable(stack, fmt.Sprintf("container %.12s running=%v health=%q", c.ID, c.Running, c.Health))
return false, nil return false, nil
} }
fp[c.ID] = c.RestartCount fp[c.ID] = c.RestartCount
@@ -164,6 +167,12 @@ func (m *Manager) stableSample(stack string) (bool, map[string]int) {
return true, fp return true, fp
} }
func (m *Manager) debugStable(stack, why string) {
if m.logger != nil && m.isDebug() {
m.logger.Printf("[DEBUG] [backup] stable-start sample %s: not ok — %s", stack, why)
}
}
func sameRestartFingerprint(a, b map[string]int) bool { func sameRestartFingerprint(a, b map[string]int) bool {
if len(a) != len(b) { if len(a) != len(b) {
return false return false