diff --git a/bitnami/etcd/Chart.yaml b/bitnami/etcd/Chart.yaml index c870220b6e2966..94ec8cf4a91de8 100644 --- a/bitnami/etcd/Chart.yaml +++ b/bitnami/etcd/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: etcd -version: 4.4.14 +version: 4.5.0 appVersion: 3.4.3 description: etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines keywords: diff --git a/bitnami/etcd/README.md b/bitnami/etcd/README.md index ed3edaa00121eb..afb958b07b1868 100644 --- a/bitnami/etcd/README.md +++ b/bitnami/etcd/README.md @@ -130,6 +130,7 @@ The following tables lists the configurable parameters of the etcd chart and the | `startFromSnapshot.existingClaim` | PVC containing the existing snapshot | `nil` | | `startFromSnapshot.snapshotFilename` | Snapshot filename | `nil` | | `disasterRecovery.enabled` | Enable auto disaster recovery by periodically snapshotting the keyspace | `false` | +| `disasterRecovery.debug` | Enable debug logging for snapshots | `false` | | `disasterRecovery.cronjob.schedule` | Schedule in Cron format to save snapshots | `*/30 * * * *` | | `disasterRecovery.cronjob.historyLimit` | Number of successful finished jobs to retain | `1` | | `disasterRecovery.cronjob.podAnnotations` | Pod annotations for cronjob pods | `{}` | diff --git a/bitnami/etcd/templates/cronjob.yaml b/bitnami/etcd/templates/cronjob.yaml index 40db3afd42b4f4..4bd3da76bf4316 100644 --- a/bitnami/etcd/templates/cronjob.yaml +++ b/bitnami/etcd/templates/cronjob.yaml @@ -31,6 +31,10 @@ spec: command: - /scripts/save-snapshot.sh env: + - name: BITNAMI_SNAPSHOT_DEBUG + value: {{ ternary "true" "false" .Values.disasterRecovery.debug | quote }} + - name: BITNAMI_DEBUG + value: {{ ternary "true" "false" .Values.image.debug | quote }} - name: ETCDCTL_API value: "3" {{- if .Values.auth.client.secureTransport }} diff --git a/bitnami/etcd/templates/scripts-configmap.yaml b/bitnami/etcd/templates/scripts-configmap.yaml index 0d515011bcef77..10244792953807 100644 --- a/bitnami/etcd/templates/scripts-configmap.yaml +++ b/bitnami/etcd/templates/scripts-configmap.yaml @@ -245,8 +245,9 @@ data: exec 3>&1 exec 4>&2 - if [ "${BITNAMI_DEBUG}" = true ]; then + if [ "${BITNAMI_SNAPSHOT_DEBUG}" = true -o "${BITNAMI_DEBUG}" = true ]; then echo "==> Bash debug is on" + set -x else echo "==> Bash debug is off" exec 1>/dev/null @@ -257,14 +258,24 @@ data: AUTH_OPTIONS="{{ $etcdAuthOptions }}" ETCDCTL_ENDPOINTS="{{range $i, $e := until $replicaCount }}{{ $etcdClientProtocol }}://{{ $etcdFullname }}-{{ $e }}.{{ $etcdHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:{{ $clientPort }},{{ end }}" # Remove the last comma "," introduced in the string - export ETCDCTL_ENDPOINTS="$(sed 's/,/ /g' <<< $ETCDCTL_ENDPOINTS | awk '{$1=$1};1' | sed 's/ /,/g')" + export ETCDCTL_ENDPOINTS="${ETCDCTL_ENDPOINTS%%,}" mkdir -p "/snapshots" 1>&3 2>&4 - if etcdctl $AUTH_OPTIONS endpoint health; then - echo "Snapshotting the keyspace..." 1>&3 2>&4 - etcdctl $AUTH_OPTIONS snapshot save "/snapshots/db" 1>&3 2>&4 - else - echo "Cluster isn't responding!!" 1>&3 2>&4 - exit 1 - fi + + # walk over each node in the list, check if node healthy make snapshot and exit, otherwise try another node + while read -d, ETCDCTL_ENDPOINTS; do + echo "Using endpoint ${ETCDCTL_ENDPOINTS}" 1>&3 2>&4 + if etcdctl $AUTH_OPTIONS endpoint health; then + echo "Snapshotting the keyspace..." 1>&3 2>&4 + etcdctl $AUTH_OPTIONS snapshot save "/snapshots/db" 1>&3 2>&4 + exit 0 + else + echo "Warning - etcd endpoint ${ETCDCTL_ENDPOINTS} not healthy" 1>&3 2>&4 + echo "Trying another endpoint." 1>&3 2>&4 + fi + done <<< "$ETCDCTL_ENDPOINTS" + + # exit with error if all endpoints are bad + echo "Error - all etcd endpoints are unhealthy!" 1>&3 2>&4 + exit 1 {{- end }} diff --git a/bitnami/etcd/values-production.yaml b/bitnami/etcd/values-production.yaml index 240954903e65a0..ed7fcfa3587357 100644 --- a/bitnami/etcd/values-production.yaml +++ b/bitnami/etcd/values-production.yaml @@ -320,6 +320,8 @@ startFromSnapshot: ## disasterRecovery: enabled: false + ## Set to true if you would like to see extra information on logs for snapshotting + debug: false cronjob: ## Schedule in Cron format to save snapshots ## See https://en.wikipedia.org/wiki/Cron diff --git a/bitnami/etcd/values.yaml b/bitnami/etcd/values.yaml index 50ac03837e14ce..61612ae0cb2840 100644 --- a/bitnami/etcd/values.yaml +++ b/bitnami/etcd/values.yaml @@ -320,6 +320,8 @@ startFromSnapshot: ## disasterRecovery: enabled: false + ## Set to true if you would like to see extra information on logs for snapshotting + debug: true cronjob: ## Schedule in Cron format to save snapshots ## See https://en.wikipedia.org/wiki/Cron