Skip to content

Commit

Permalink
fix: Add failure threshold to graceful shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 committed Nov 25, 2024
1 parent 2ec8a55 commit 04b44eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 04b44eb

Please sign in to comment.