Skip to content

Commit 0b903e9

Browse files
committed
Make shutdown grace periods to more reasonable defaults
Note that post-shutdown-grace-period doesn't seem to contribute to graceful shutdown, see #8095 for discussion.
1 parent 073786e commit 0b903e9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pkg/flags/flags.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ Takes the form "<host>:port". If not provided, no admission controller is starte
222222

223223
statusUpdateInterval = flags.Int("status-update-interval", status.UpdateInterval, "Time interval in seconds in which the status should check if an update is required. Default is 60 seconds")
224224

225-
shutdownGracePeriod = flags.Int("shutdown-grace-period", 0, "Seconds to wait after receiving the shutdown signal, before stopping the nginx process.")
225+
shutdownGracePeriod = flags.Int("shutdown-grace-period", 10, "Seconds to wait after receiving the shutdown signal, before stopping the nginx process.")
226226

227-
postShutdownGracePeriod = flags.Int("post-shutdown-grace-period", 10, "Seconds to wait after the nginx process has stopped before controller exits.")
227+
postShutdownGracePeriod = flags.Int("post-shutdown-grace-period", 0, `[IN DEPRECATION] Seconds to wait after the nginx process has stopped before controller exits.
228+
Note that increasing this value doesn't seem to contribute to graceful shutdown of the ingress controller.
229+
If you would like to configure period for accepting requests before shutting down, use 'shutdown-grace-period' instead.'`)
228230

229231
deepInspector = flags.Bool("deep-inspect", true, "Enables ingress object security deep inspector")
230232

pkg/util/process/sigterm.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ limitations under the License.
1717
package process
1818

1919
import (
20+
klog "k8s.io/klog/v2"
2021
"os"
2122
"os/signal"
2223
"syscall"
2324
"time"
24-
25-
klog "k8s.io/klog/v2"
2625
)
2726

2827
type exiter func(code int)
@@ -41,8 +40,11 @@ func HandleSigterm(ngx Controller, delay int, exit exiter) {
4140
exitCode = 1
4241
}
4342

44-
klog.Infof("Handled quit, delaying controller exit for %d seconds", delay)
45-
time.Sleep(time.Duration(delay) * time.Second)
43+
if delay > 0 {
44+
klog.Warning("[DEPRECATED] Delaying controller exit for %d seconds", delay)
45+
klog.Warning("[DEPRECATED] 'post-shutdown-grace-period' does not have any effect for graceful shutdown - use 'shutdown-grace-period' flag instead.")
46+
time.Sleep(time.Duration(delay) * time.Second)
47+
}
4648

4749
klog.InfoS("Exiting", "code", exitCode)
4850
exit(exitCode)

0 commit comments

Comments
 (0)