diff --git a/build/build.sh b/build/build.sh index bbcaf78e8e..6d6953d93f 100755 --- a/build/build.sh +++ b/build/build.sh @@ -57,13 +57,3 @@ ${GO_BUILD_CMD} \ -X ${PKG}/version.REPO=${REPO_INFO}" \ -buildvcs=false \ -o "${TARGETS_DIR}/dbg" "${PKG}/cmd/dbg" - -echo "Building ${PKG}/cmd/waitshutdown" - -${GO_BUILD_CMD} \ - -trimpath -ldflags="-buildid= -w -s \ - -X ${PKG}/version.RELEASE=${TAG} \ - -X ${PKG}/version.COMMIT=${COMMIT_SHA} \ - -X ${PKG}/version.REPO=${REPO_INFO}" \ - -buildvcs=false \ - -o "${TARGETS_DIR}/wait-shutdown" "${PKG}/cmd/waitshutdown" \ No newline at end of file diff --git a/charts/ingress-nginx/README.md b/charts/ingress-nginx/README.md index c0b00e56d1..0369d685e9 100644 --- a/charts/ingress-nginx/README.md +++ b/charts/ingress-nginx/README.md @@ -372,7 +372,7 @@ metadata: | controller.keda.triggers | list | `[]` | | | controller.kind | string | `"Deployment"` | Use a `DaemonSet` or `Deployment` | | controller.labels | object | `{}` | Labels to be added to the controller Deployment or DaemonSet and other resources that do not have option to specify labels # | -| controller.lifecycle | object | `{"preStop":{"exec":{"command":["/wait-shutdown"]}}}` | Improve connection draining when ingress controller pod is deleted using a lifecycle hook: With this new hook, we increased the default terminationGracePeriodSeconds from 30 seconds to 300, allowing the draining of connections up to five minutes. If the active connections end before that, the pod will terminate gracefully at that time. To effectively take advantage of this feature, the Configmap feature worker-shutdown-timeout new value is 240s instead of 10s. # | +| controller.lifecycle | object | `{}` | | | controller.livenessProbe.failureThreshold | int | `5` | | | controller.livenessProbe.httpGet.path | string | `"/healthz"` | | | controller.livenessProbe.httpGet.port | int | `10254` | | diff --git a/charts/ingress-nginx/values.yaml b/charts/ingress-nginx/values.yaml index 116adf7ca5..4049f42c54 100644 --- a/charts/ingress-nginx/values.yaml +++ b/charts/ingress-nginx/values.yaml @@ -945,18 +945,7 @@ controller: # annotations: # description: Too many 4XXs # summary: More than 5% of all requests returned 4XX, this requires your attention - # -- Improve connection draining when ingress controller pod is deleted using a lifecycle hook: - # With this new hook, we increased the default terminationGracePeriodSeconds from 30 seconds - # to 300, allowing the draining of connections up to five minutes. - # If the active connections end before that, the pod will terminate gracefully at that time. - # To effectively take advantage of this feature, the Configmap feature - # worker-shutdown-timeout new value is 240s instead of 10s. - ## - lifecycle: - preStop: - exec: - command: - - /wait-shutdown + lifecycle: {} priorityClassName: "" # -- Rollback limit ## diff --git a/cmd/waitshutdown/main.go b/cmd/waitshutdown/main.go deleted file mode 100644 index 7bc50d9cb8..0000000000 --- a/cmd/waitshutdown/main.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "os" - "os/exec" - "time" - - "k8s.io/ingress-nginx/internal/nginx" - "k8s.io/klog/v2" -) - -func main() { - err := exec.Command("bash", "-c", "pkill -SIGTERM -f nginx-ingress-controller").Run() - if err != nil { - klog.ErrorS(err, "terminating ingress controller") - os.Exit(1) - } - - // wait for the NGINX process to terminate - timer := time.NewTicker(time.Second * 1) - for range timer.C { - if !nginx.IsRunning() { - timer.Stop() - break - } - } -} diff --git a/rootfs/Dockerfile b/rootfs/Dockerfile index a04cfe3dec..cfcfe0c69f 100644 --- a/rootfs/Dockerfile +++ b/rootfs/Dockerfile @@ -43,7 +43,6 @@ COPY --chown=www-data:www-data etc /etc COPY --chown=www-data:www-data bin/${TARGETARCH}/dbg / COPY --chown=www-data:www-data bin/${TARGETARCH}/nginx-ingress-controller / -COPY --chown=www-data:www-data bin/${TARGETARCH}/wait-shutdown / # Fix permission during the build to avoid issues at runtime # with volumes (custom templates) diff --git a/rootfs/Dockerfile-chroot b/rootfs/Dockerfile-chroot index b719f2fc32..7f66f1da01 100644 --- a/rootfs/Dockerfile-chroot +++ b/rootfs/Dockerfile-chroot @@ -65,7 +65,6 @@ COPY --chown=www-data:www-data etc /chroot/etc COPY --chown=www-data:www-data bin/${TARGETARCH}/dbg / COPY --chown=www-data:www-data bin/${TARGETARCH}/nginx-ingress-controller / -COPY --chown=www-data:www-data bin/${TARGETARCH}/wait-shutdown / COPY --chown=www-data:www-data nginx-chroot-wrapper.sh /usr/bin/nginx WORKDIR /chroot/etc/nginx diff --git a/test/e2e/gracefulshutdown/grace_period.go b/test/e2e/gracefulshutdown/grace_period.go index 123892f3ac..cd000fa00b 100644 --- a/test/e2e/gracefulshutdown/grace_period.go +++ b/test/e2e/gracefulshutdown/grace_period.go @@ -41,16 +41,14 @@ var _ = framework.IngressNginxDescribe("[Shutdown] Grace period shutdown", func( if strings.Contains(v, "--shutdown-grace-period") { continue } - args = append(args, v) } - args = append(args, "--shutdown-grace-period=90") deployment.Spec.Template.Spec.Containers[0].Args = args - cmds := []string{"/wait-shutdown"} - deployment.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command = cmds + grace := int64(3600) deployment.Spec.Template.Spec.TerminationGracePeriodSeconds = &grace + _, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(context.TODO(), deployment, metav1.UpdateOptions{}) return err })