mirror of
https://github.com/helm/charts.git
synced 2026-08-23 22:37:45 +00:00
Improve etcd statefulset template (#19535)
+ Fix bash'ism in sh command for stderr redirection. The old line results in process forking and a loop that doesn't finish + etcdctl defaults to simple output now which is comma separated + There are some scenarios when recovering from a crash where /var/run/etcd/default.etcd exists but /var/run/etcd/member_id does not, so make sure both exist before trying to use it to recover Signed-off-by: Michael Peters <michael00peters@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
apiVersion: v1
|
||||
name: etcd
|
||||
home: https://github.com/coreos/etcd
|
||||
version: 0.7.3
|
||||
version: 0.7.4
|
||||
appVersion: 3.2.26
|
||||
description: Distributed reliable key-value store for the most critical data of a
|
||||
distributed system.
|
||||
|
||||
@@ -101,7 +101,7 @@ spec:
|
||||
AUTH_OPTIONS="{{ $etcdAuthOptions }}"
|
||||
|
||||
member_hash() {
|
||||
etcdctl $AUTH_OPTIONS member list | grep {{ $etcdPeerProtocol }}://${HOSTNAME}.${SET_NAME}:2380 | cut -d':' -f1 | cut -d'[' -f1
|
||||
etcdctl $AUTH_OPTIONS member list | grep {{ $etcdPeerProtocol }}://${HOSTNAME}.${SET_NAME}:2380 | cut -d ',' -f1
|
||||
}
|
||||
|
||||
SET_ID=${HOSTNAME##*[^0-9]}
|
||||
@@ -122,8 +122,8 @@ spec:
|
||||
AUTH_OPTIONS="{{ $etcdAuthOptions }}"
|
||||
# store member id into PVC for later member replacement
|
||||
collect_member() {
|
||||
while ! etcdctl $AUTH_OPTIONS member list &>/dev/null; do sleep 1; done
|
||||
etcdctl $AUTH_OPTIONS member list | grep {{ $etcdPeerProtocol }}://${HOSTNAME}.${SET_NAME}:2380 | cut -d':' -f1 | cut -d'[' -f1 > /var/run/etcd/member_id
|
||||
while ! etcdctl $AUTH_OPTIONS member list > /dev/null 2>&1; do sleep 1; done
|
||||
etcdctl $AUTH_OPTIONS member list | grep {{ $etcdPeerProtocol }}://${HOSTNAME}.${SET_NAME}:2380 | cut -d ',' -f1 > /var/run/etcd/member_id
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ spec:
|
||||
}
|
||||
|
||||
member_hash() {
|
||||
etcdctl $AUTH_OPTIONS member list | grep {{ $etcdPeerProtocol }}://${HOSTNAME}.${SET_NAME}:2380 | cut -d':' -f1 | cut -d'[' -f1
|
||||
etcdctl $AUTH_OPTIONS member list | grep {{ $etcdPeerProtocol }}://${HOSTNAME}.${SET_NAME}:2380 | cut -d ',' -f1
|
||||
}
|
||||
|
||||
# we should wait for other pods to be up before trying to join
|
||||
@@ -150,7 +150,7 @@ spec:
|
||||
done
|
||||
|
||||
# re-joining after failure?
|
||||
if [ -e /var/run/etcd/default.etcd ]; then
|
||||
if [ -e /var/run/etcd/default.etcd && -e /var/run/etcd/member_id ]; then
|
||||
echo "Re-joining etcd member"
|
||||
member_id=$(cat /var/run/etcd/member_id)
|
||||
|
||||
@@ -255,4 +255,4 @@ spec:
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user