From fcaacf94a37d028e542d98312348b3cc4f4e010d Mon Sep 17 00:00:00 2001 From: Matt McEuen Date: Thu, 7 Nov 2019 17:28:49 -0600 Subject: [PATCH] Add -e to pre_stop hooks This adds -e to the pre_stop scripts, so that they fail out if any of their commands fail. This is required, since it's the only way to communicate whether there is an issue during pre_hook execution. "The logs for a Hook handler are not exposed in Pod events. If a handler fails for some reason, it broadcasts an event." https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks As an example, this issue was discovered when "touch /tmp/stop" was failing silently due to a readOnlyRootFilesystem setting, resulting in pods that would not successfully Terminate until the grace period was exhausted. Change-Id: Ic9a228230d944530e31ed61f4239fd434cbb6187 --- charts/apiserver/templates/bin/_pre_stop.tpl | 2 +- charts/controller_manager/templates/bin/_pre_stop.tpl | 2 +- charts/etcd/templates/bin/_pre_stop.tpl | 2 +- charts/haproxy/templates/bin/_pre_stop.tpl | 2 +- charts/scheduler/templates/bin/_pre_stop.tpl | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/apiserver/templates/bin/_pre_stop.tpl b/charts/apiserver/templates/bin/_pre_stop.tpl index e58fffe9..5e6342b5 100644 --- a/charts/apiserver/templates/bin/_pre_stop.tpl +++ b/charts/apiserver/templates/bin/_pre_stop.tpl @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -x +set -ex touch /tmp/stop sleep {{ .Values.anchor.period }} diff --git a/charts/controller_manager/templates/bin/_pre_stop.tpl b/charts/controller_manager/templates/bin/_pre_stop.tpl index e58fffe9..5e6342b5 100644 --- a/charts/controller_manager/templates/bin/_pre_stop.tpl +++ b/charts/controller_manager/templates/bin/_pre_stop.tpl @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -x +set -ex touch /tmp/stop sleep {{ .Values.anchor.period }} diff --git a/charts/etcd/templates/bin/_pre_stop.tpl b/charts/etcd/templates/bin/_pre_stop.tpl index 5346a63f..f455b32d 100644 --- a/charts/etcd/templates/bin/_pre_stop.tpl +++ b/charts/etcd/templates/bin/_pre_stop.tpl @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -x +set -ex function cleanup_host { rm -f $MANIFEST_PATH diff --git a/charts/haproxy/templates/bin/_pre_stop.tpl b/charts/haproxy/templates/bin/_pre_stop.tpl index 3d5d5275..5e6e1fb5 100644 --- a/charts/haproxy/templates/bin/_pre_stop.tpl +++ b/charts/haproxy/templates/bin/_pre_stop.tpl @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. */}} -set -x +set -ex touch /tmp/stop sleep {{ .Values.conf.anchor.period }} diff --git a/charts/scheduler/templates/bin/_pre_stop.tpl b/charts/scheduler/templates/bin/_pre_stop.tpl index 769c1b9d..a559b01c 100644 --- a/charts/scheduler/templates/bin/_pre_stop.tpl +++ b/charts/scheduler/templates/bin/_pre_stop.tpl @@ -15,7 +15,7 @@ # limitations under the License. */}} -set -x +set -ex touch /tmp/stop sleep {{ .Values.anchor.period }}