Skip to content

Commit

Permalink
fix: gracefulShutdownTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Oct 17, 2024
1 parent 86b256e commit a1c676f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions pkg/controller/signals.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import (
"os"
"os/signal"
"syscall"
"time"

"k8s.io/klog/v2"
)

const gracefulShutdownTimeout = 25 * time.Second

func handleSignals(ctx context.Context, cancel context.CancelFunc) {
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
Expand Down
4 changes: 3 additions & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var (
Port = 9443
)

const gracefulShutdownTimeout = 25 * time.Second

func init() {
_ = admissionv1.AddToScheme(scheme)
_ = cnpgv1.AddToScheme(scheme)
Expand Down Expand Up @@ -45,7 +47,7 @@ func Server(ctx context.Context, kubeClients *client.KubeClients) error {
go func() {
<-ctx.Done()

shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.Background(), gracefulShutdownTimeout)
defer cancel()

if err := server.Shutdown(shutdownCtx); err != nil {
Expand Down

0 comments on commit a1c676f

Please sign in to comment.