From f38835665605586018b8a98d52d5e0c185e89898 Mon Sep 17 00:00:00 2001 From: Keerthan Reddy Mala Date: Wed, 21 Feb 2024 13:48:34 -0800 Subject: [PATCH] gracefully terminate on SIGTERM --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index a25e6ea87..ebf521619 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,6 @@ import ( "crypto/x509/pkix" goflag "flag" "fmt" - "github.com/aws/amazon-eks-pod-identity-webhook/pkg/containercredentials" "net/http" "os" "strings" @@ -31,6 +30,7 @@ import ( "github.com/aws/amazon-eks-pod-identity-webhook/pkg/cache" cachedebug "github.com/aws/amazon-eks-pod-identity-webhook/pkg/cache/debug" "github.com/aws/amazon-eks-pod-identity-webhook/pkg/cert" + "github.com/aws/amazon-eks-pod-identity-webhook/pkg/containercredentials" "github.com/aws/amazon-eks-pod-identity-webhook/pkg/handler" "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/session" @@ -302,6 +302,8 @@ func main() { Handler: metricsMux, } + handler.ShutdownFromContext(signalHandlerCtx, metricsServer, time.Duration(10)*time.Second) + go func() { klog.Infof("Listening on %s", addr) if err := server.ListenAndServeTLS("", ""); err != http.ErrServerClosed {