From 4f43d4a78c4953e062a59387c49e3ab61218eb24 Mon Sep 17 00:00:00 2001 From: motoki317 Date: Fri, 22 Nov 2024 00:48:36 +0900 Subject: [PATCH] fix: Add failure threshold to graceful shutdown --- internal/ingress/controller/nginx.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index 86bc1b707..945d6047b 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -400,12 +400,18 @@ func (n *NGINXController) stopWait() { var scraper collectors.NginxStatusScraper lastRequests := 0 noChangeTimes := 0 + failures := 0 + const failureThreshold = 5 for ; ; time.Sleep(checkFrequency) { st, err := scraper.Scrape() if err != nil { klog.Warningf("failed to scrape nginx status: %v", err) - noChangeTimes = 0 + failures++ + if failures >= failureThreshold { + klog.Warningf("giving up graceful shutdown: too many nginx status scrape failures") + break + } continue }