Skip to content

Commit 40a3247

Browse files
committed
Use --shutdown-delay-duration
Signed-off-by: Luke Addison <[email protected]>
1 parent 1c2ad5b commit 40a3247

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ var (
117117
disabledBuiltins = util.NewFlagSet()
118118
enableK8sCel = flag.Bool("experimental-enable-k8s-native-validation", false, "PROTOTYPE (not stable): enable the validating admission policy driver")
119119
externaldataProviderResponseCacheTTL = flag.Duration("external-data-provider-response-cache-ttl", 3*time.Minute, "TTL for the external data provider response cache. Specify the duration in 'h', 'm', or 's' for hours, minutes, or seconds respectively. Defaults to 3 minutes if unspecified. Setting the TTL to 0 disables the cache.")
120-
shutdownWaitPeriod = flag.Duration("shutdown-wait-period", 10*time.Second, "The amount of time to wait before shutting down gracefully. This is used to delay webhook shutdown until the API Server stops sending new connections")
120+
shutdownDelayDuration = flag.Duration("shutdown-delay-duration", 10*time.Second, "The amount of time to wait before shutting down gracefully. This can be used to delay webhook shutdown until the API Server stops trying to make new connections")
121121
)
122122

123123
func init() {
@@ -312,7 +312,7 @@ func innerMain() int {
312312

313313
// Setup controllers asynchronously, they will block for certificate generation if needed.
314314
setupErr := make(chan error)
315-
ctx := setupSignalHandler(*shutdownWaitPeriod)
315+
ctx := setupSignalHandler(*shutdownDelayDuration)
316316
go func() {
317317
setupErr <- setupControllers(ctx, mgr, sw, tracker, setupFinished)
318318
}()
@@ -585,21 +585,21 @@ func setLoggerForProduction(encoder zapcore.LevelEncoder, dest io.Writer) {
585585

586586
// setupSignalHandler registers a signal handler for SIGTERM and SIGINT and
587587
// returns a context which is canceled when one of these signals is caught after
588-
// waiting for the specified period. If a second signal is caught then we
588+
// waiting for the specified duration. If a second signal is caught then we
589589
// terminate immediately with exit code 1. The implementation has been stolen
590-
// from controller-runtime and then extended with wait period support:
590+
// from controller-runtime and then extended to support delay:
591591
// https://github.com/kubernetes-sigs/controller-runtime/blob/2154ffbc22e26ffd8c3b713927f0df2fa40841f2/pkg/manager/signals/signal.go#L27-L45
592-
func setupSignalHandler(waitPeriod time.Duration) context.Context {
592+
func setupSignalHandler(delayDuration time.Duration) context.Context {
593593
ctx, cancel := context.WithCancel(context.Background())
594594

595595
c := make(chan os.Signal, 2)
596596
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
597597
go func() {
598598
<-c
599-
// Cancel the context once the wait period expires but avoid blocking if
600-
// a second signal is received
599+
// Cancel the context after delaying for the specified duration but
600+
// avoid blocking if a second signal is received
601601
go func() {
602-
<-time.After(waitPeriod)
602+
<-time.After(delayDuration)
603603
cancel()
604604
}()
605605
<-c

0 commit comments

Comments
 (0)