diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index 773868bdcc..86bc1b7077 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -23,7 +23,6 @@ import ( "errors" "fmt" "io/fs" - "k8s.io/ingress-nginx/internal/ingress/metric/collectors" "net" "net/http" "os" @@ -38,6 +37,8 @@ import ( "time" "unicode" + "k8s.io/ingress-nginx/internal/ingress/metric/collectors" + proxyproto "github.com/armon/go-proxyproto" "github.com/eapache/channels" apiv1 "k8s.io/api/core/v1" @@ -429,7 +430,7 @@ func (n *NGINXController) stopWait() { } // Wait at least for the configured duration, if any - delay := waitAtLeastUntil.Sub(time.Now()) + delay := time.Until(waitAtLeastUntil) if delay > 0 { time.Sleep(delay) } diff --git a/pkg/util/process/sigterm.go b/pkg/util/process/sigterm.go index 689947c808..8f25e2d994 100644 --- a/pkg/util/process/sigterm.go +++ b/pkg/util/process/sigterm.go @@ -17,11 +17,12 @@ limitations under the License. package process import ( - klog "k8s.io/klog/v2" "os" "os/signal" "syscall" "time" + + "k8s.io/klog/v2" ) type exiter func(code int) @@ -41,7 +42,7 @@ func HandleSigterm(ngx Controller, delay int, exit exiter) { } if delay > 0 { - klog.Warning("[DEPRECATED] Delaying controller exit for %d seconds", delay) + klog.Warningf("[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) } diff --git a/test/e2e/gracefulshutdown/k8s_async_shutdown.go b/test/e2e/gracefulshutdown/k8s_async_shutdown.go index cf245dc055..9a4bc368d7 100644 --- a/test/e2e/gracefulshutdown/k8s_async_shutdown.go +++ b/test/e2e/gracefulshutdown/k8s_async_shutdown.go @@ -19,14 +19,15 @@ package gracefulshutdown import ( "context" "fmt" + "net/http" + "strings" + "time" + "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/test/e2e/framework" - "net/http" - "strings" - "time" ) var _ = framework.IngressNginxDescribe("[Shutdown] Asynchronous shutdown", func() {