Skip to content

Commit 087c8e6

Browse files
committed
Add optional pre-upgrade hook delay
On clusters with slow network initialization the pre-upgrade hook may fail when etcdctl tries to contact etcd members before pod network is actually initialized. Optional customizable delay can be injected before running etcdctl to give kubelet enough time to initialize network. fixes #82322 Signed-off-by: Robert Moucha <[email protected]>
1 parent b31bd9f commit 087c8e6

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

bitnami/etcd/3.6/debian-12/rootfs/opt/bitnami/scripts/etcd-env.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ etcd_env_vars=(
3434
ETCD_DISASTER_RECOVERY
3535
ETCD_ON_K8S
3636
ETCD_INIT_SNAPSHOT_FILENAME
37+
ETCD_PREUPGRADE_START_DELAY
3738
ETCD_NAME
3839
ETCD_LOG_LEVEL
3940
ETCD_LISTEN_CLIENT_URLS
@@ -90,6 +91,7 @@ export ETCD_START_FROM_SNAPSHOT="${ETCD_START_FROM_SNAPSHOT:-no}"
9091
export ETCD_DISASTER_RECOVERY="${ETCD_DISASTER_RECOVERY:-no}"
9192
export ETCD_ON_K8S="${ETCD_ON_K8S:-no}"
9293
export ETCD_INIT_SNAPSHOT_FILENAME="${ETCD_INIT_SNAPSHOT_FILENAME:-}"
94+
export ETCD_PREUPGRADE_START_DELAY="${ETCD_PREUPGRADE_START_DELAY:-}"
9395

9496
# etcd native environment variables (see https://etcd.io/docs/current/op-guide/configuration)
9597
export ETCD_NAME="${ETCD_NAME:-}"

bitnami/etcd/3.6/debian-12/rootfs/opt/bitnami/scripts/etcd/preupgrade.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set -o nounset
2121
# based on "initial-cluster" flag value
2222
# ref: https://etcd.io/docs/latest/op-guide/clustering/#static
2323
# Globals:
24-
# ETCD_INITIAL_CLUSTER
24+
# ETCD_INITIAL_CLUSTER
2525
# Arguments:
2626
# None
2727
# Returns:
@@ -37,6 +37,11 @@ endpoints_as_host_port() {
3737

3838
read -r -a extra_flags <<<"$(etcdctl_auth_flags)"
3939
is_boolean_yes "$ETCD_ON_K8S" && extra_flags+=("--endpoints=$(endpoints_as_host_port)")
40+
41+
if [[ -n "$ETCD_PREUPGRADE_START_DELAY" ]]; then
42+
info "Waiting for $ETCD_PREUPGRADE_START_DELAY seconds before starting pre-upgrade checks"
43+
sleep "$ETCD_PREUPGRADE_START_DELAY"
44+
fi
4045
debug "Listing members"
4146
if ! current="$(etcdctl member list "${extra_flags[@]}" --write-out simple | awk -F ", " '{print $3 ":" $1}')"; then
4247
error "Unable to list members, are all members healthy?"

bitnami/etcd/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ Apart from providing your custom configuration file, you can also modify the ser
195195
| `ETCD_START_FROM_SNAPSHOT` | Whether etcd should start from an existing snapshot or not. | `no` |
196196
| `ETCD_DISASTER_RECOVERY` | Whether etcd should try or not to recover from snapshots when the cluste disastrously fails. | `no` |
197197
| `ETCD_ON_K8S` | Whether etcd is running on a K8s environment or not. | `no` |
198+
| `ETCD_PREUPGRADE_START_DELAY` | Optional delay before starting the pre-upgrade hook (in seconds). | `nil` |
198199
| `ETCD_INIT_SNAPSHOT_FILENAME` | Existing snapshot filename to start the etcd cluster from. | `nil` |
199200
| `ETCD_NAME` | etcd member name. | `nil` |
200201
| `ETCD_LOG_LEVEL` | etcd log level. | `info` |

0 commit comments

Comments
 (0)