Make shutdown grace periods to more reasonable defaults

Note that post-shutdown-grace-period doesn't seem to contribute to graceful shutdown,
see https://github.com/kubernetes/ingress-nginx/issues/8095 for discussion.
This commit is contained in:
motoki317 2024-11-20 15:03:42 +09:00
parent 25f5d09ec0
commit 3fe18f1870
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View file

@ -222,9 +222,11 @@ Takes the form "<host>:port". If not provided, no admission controller is starte
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")
shutdownGracePeriod = flags.Int("shutdown-grace-period", 0, "Seconds to wait after receiving the shutdown signal, before stopping the nginx process.")
shutdownGracePeriod = flags.Int("shutdown-grace-period", 10, "Seconds to wait after receiving the shutdown signal, before stopping the nginx process.")
postShutdownGracePeriod = flags.Int("post-shutdown-grace-period", 10, "Seconds to wait after the nginx process has stopped before controller exits.")
postShutdownGracePeriod = flags.Int("post-shutdown-grace-period", 0, `[IN DEPRECATION] Seconds to wait after the nginx process has stopped before controller exits.
Note that increasing this value doesn't seem to contribute to graceful shutdown of the ingress controller.
If you would like to configure period for accepting requests before shutting down, use 'shutdown-grace-period' instead.'`)
deepInspector = flags.Bool("deep-inspect", true, "Enables ingress object security deep inspector")

View file

@ -17,12 +17,11 @@ limitations under the License.
package process
import (
klog "k8s.io/klog/v2"
"os"
"os/signal"
"syscall"
"time"
klog "k8s.io/klog/v2"
)
type exiter func(code int)
@ -41,8 +40,11 @@ func HandleSigterm(ngx Controller, delay int, exit exiter) {
exitCode = 1
}
klog.Infof("Handled quit, delaying controller exit for %d seconds", delay)
time.Sleep(time.Duration(delay) * time.Second)
if delay > 0 {
klog.Warning("[DEPRECATED] Delaying controller exit for %d seconds", delay)
klog.Warning("[DEPRECATED] 'post-shutdown-grace-period' does not have any effect for graceful shutdown - use 'shutdown-grace-period' flag instead.")
time.Sleep(time.Duration(delay) * time.Second)
}
klog.InfoS("Exiting", "code", exitCode)
exit(exitCode)