Skip to content

Commit 30cc850

Browse files
committed
fix: Add failure threshold to graceful shutdown
1 parent 60f8c04 commit 30cc850

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/ingress/controller/nginx.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,18 @@ func (n *NGINXController) stopWait() {
400400
var scraper collectors.NginxStatusScraper
401401
lastRequests := 0
402402
noChangeTimes := 0
403+
failures := 0
404+
const failureThreshold = 5
403405

404406
for ; ; time.Sleep(checkFrequency) {
405407
st, err := scraper.Scrape()
406408
if err != nil {
407409
klog.Warningf("failed to scrape nginx status: %v", err)
408-
noChangeTimes = 0
410+
failures++
411+
if failures >= failureThreshold {
412+
klog.Warningf("giving up graceful shutdown: too many nginx status scrape failures")
413+
break
414+
}
409415
continue
410416
}
411417

0 commit comments

Comments
 (0)