charts icon indicating copy to clipboard operation
charts copied to clipboard

etcd cluster has split-brain after deleting a node

Open canhnt opened this issue 8 years ago • 14 comments

I install an etcd cluster with 3 nodes using binami/etcd chart. After deployment, the cluster works well with 3 members:

When an etcd node was deleted (via kubectl delete pod), a new pod with the same name is replaced. However this node cannot join the existing cluster but create a single node cluster. Then we have two clusters: a single-node cluster and a two-node cluster.

etcdctl --endpoints=$ENDPOINTS endpoint status --write-out=table
+-----------------------------------------------------------------+------------------+---------+---------+-----------+-----------+------------+
|                              ENDPOINT                           |        ID        | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |
+-----------------------------------------------------------------+------------------+---------+---------+-----------+-----------+------------+
| http://my-etcd-0.my-etcd-headless.canhnt.svc.cluster.local:2379 | cabc37e6ee4246c8 |  3.3.10 |   20 kB |      true |         3 |         18 |
| http://my-etcd-1.my-etcd-headless.canhnt.svc.cluster.local:2379 | 87b52d8b24932e92 |  3.3.10 |   20 kB |     false |         4 |         24 |
| http://my-etcd-2.my-etcd-headless.canhnt.svc.cluster.local:2379 | 5605bf6091f96554 |  3.3.10 |   20 kB |      true |         4 |         24 |
+-----------------------------------------------------------------+------------------+---------+---------+-----------+-----------+------------+

canhnt avatar Oct 30 '18 16:10 canhnt

I was able to reproduce the issue. We will check it and update the github issue once we have more information.

tompizmor avatar Nov 06 '18 16:11 tompizmor

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

stale[bot] avatar Nov 24 '18 11:11 stale[bot]

I have the same issue. When I delete pod-0, the new pod with same name can't rejoin the cluster. The new pod try to create a new cluster and failed, then restart again and again. The log is below:

root@k8s01:~# kubectl logs service-factory-etcd-etc-0 -n csf
==> The ID of the host is 0
==> Creating data dir...
==> There is no data at all. Creating new cluster
2018-12-06 11:15:12.997281 I | pkg/flags: recognized and used environment variable ETCD_ADVERTISE_CLIENT_URLS=http://service-factory-etcd-etc-0.service-factory-etcd-etc-headless.csf.svc.cluster.local:2379
2018-12-06 11:15:12.997407 I | pkg/flags: recognized and used environment variable ETCD_DATA_DIR=/bitnami/etcd/data
2018-12-06 11:15:12.997428 I | pkg/flags: recognized and used environment variable ETCD_INITIAL_ADVERTISE_PEER_URLS=http://service-factory-etcd-etc-0.service-factory-etcd-etc-headless.csf.svc.cluster.local:2380
2018-12-06 11:15:12.997438 I | pkg/flags: recognized and used environment variable ETCD_INITIAL_CLUSTER=service-factory-etcd-etc-0=http://service-factory-etcd-etc-0.service-factory-etcd-etc-headless.csf.svc.cluster.local:2380,service-factory-etcd-etc-1=http://service-factory-etcd-etc-1.service-factory-etcd-etc-headless.csf.svc.cluster.local:2380,service-factory-etcd-etc-2=http://service-factory-etcd-etc-2.service-factory-etcd-etc-headless.csf.svc.cluster.local:2380,
2018-12-06 11:15:12.997446 I | pkg/flags: recognized and used environment variable ETCD_INITIAL_CLUSTER_STATE=new
2018-12-06 11:15:12.997450 I | pkg/flags: recognized and used environment variable ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster-k8s
2018-12-06 11:15:12.997457 I | pkg/flags: recognized and used environment variable ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
2018-12-06 11:15:12.997467 I | pkg/flags: recognized and used environment variable ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
2018-12-06 11:15:12.997486 I | pkg/flags: recognized and used environment variable ETCD_NAME=service-factory-etcd-etc-0
2018-12-06 11:15:12.997555 I | etcdmain: etcd Version: 3.3.10
2018-12-06 11:15:12.997561 I | etcdmain: Git SHA: 27fc7e2
2018-12-06 11:15:12.997564 I | etcdmain: Go Version: go1.10.4
2018-12-06 11:15:12.997567 I | etcdmain: Go OS/Arch: linux/amd64
2018-12-06 11:15:12.997571 I | etcdmain: setting maximum number of CPUs to 40, total number of available CPUs is 40
2018-12-06 11:15:12.997627 W | etcdmain: found invalid file/dir member_id under data dir /bitnami/etcd/data (Ignore this if you are upgrading etcd)
2018-12-06 11:15:12.997639 N | etcdmain: the server is already initialized as member before, starting as etcd member...
2018-12-06 11:15:12.997704 I | embed: listening for peers on http://0.0.0.0:2380
2018-12-06 11:15:12.997728 I | embed: listening for client requests on 0.0.0.0:2379
2018-12-06 11:15:12.998488 I | etcdserver: name = service-factory-etcd-etc-0
2018-12-06 11:15:12.998498 I | etcdserver: data dir = /bitnami/etcd/data
2018-12-06 11:15:12.998502 I | etcdserver: member dir = /bitnami/etcd/data/member
2018-12-06 11:15:12.998506 I | etcdserver: heartbeat = 100ms
2018-12-06 11:15:12.998508 I | etcdserver: election = 1000ms
2018-12-06 11:15:12.998511 I | etcdserver: snapshot count = 100000
2018-12-06 11:15:12.998522 I | etcdserver: advertise client URLs = http://service-factory-etcd-etc-0.service-factory-etcd-etc-headless.csf.svc.cluster.local:2379
2018-12-06 11:15:13.002841 I | etcdserver: restarting member 370d93c208893c77 in cluster aa441f14685c1e40 at commit index 613
2018-12-06 11:15:13.002954 I | raft: 370d93c208893c77 became follower at term 1876
2018-12-06 11:15:13.003025 I | raft: newRaft 370d93c208893c77 [peers: [], term: 1876, commit: 613, applied: 0, lastindex: 614, lastterm: 1866]
2018-12-06 11:15:13.007913 W | auth: simple token is not cryptographically signed
2018-12-06 11:15:13.010020 I | etcdserver: starting server... [version: 3.3.10, cluster version: to_be_decided]
2018-12-06 11:15:13.010373 I | etcdserver/membership: added member 321b5633e49b8ca2 [http://service-factory-etcd-etc-2.service-factory-etcd-etc-headless.csf.svc.cluster.local:2380] to cluster aa441f14685c1e40
2018-12-06 11:15:13.010394 I | rafthttp: starting peer 321b5633e49b8ca2...
2018-12-06 11:15:13.010416 I | rafthttp: started HTTP pipelining with peer 321b5633e49b8ca2
2018-12-06 11:15:13.010700 I | rafthttp: started streaming with peer 321b5633e49b8ca2 (writer)
2018-12-06 11:15:13.011109 I | rafthttp: started streaming with peer 321b5633e49b8ca2 (writer)
2018-12-06 11:15:13.011683 I | rafthttp: started peer 321b5633e49b8ca2
2018-12-06 11:15:13.011737 I | rafthttp: started streaming with peer 321b5633e49b8ca2 (stream MsgApp v2 reader)
2018-12-06 11:15:13.011786 I | rafthttp: started streaming with peer 321b5633e49b8ca2 (stream Message reader)
2018-12-06 11:15:13.011853 I | rafthttp: added peer 321b5633e49b8ca2
2018-12-06 11:15:13.012129 I | etcdserver/membership: added member 370d93c208893c77 [http://service-factory-etcd-etc-0.service-factory-etcd-etc-headless.csf.svc.cluster.local:2380] to cluster aa441f14685c1e40
2018-12-06 11:15:13.012243 I | etcdserver/membership: added member 670d13ff11ff0a8f [http://service-factory-etcd-etc-1.service-factory-etcd-etc-headless.csf.svc.cluster.local:2380] to cluster aa441f14685c1e40
2018-12-06 11:15:13.012267 I | rafthttp: starting peer 670d13ff11ff0a8f...
2018-12-06 11:15:13.012290 I | rafthttp: started HTTP pipelining with peer 670d13ff11ff0a8f
2018-12-06 11:15:13.012889 I | rafthttp: started streaming with peer 670d13ff11ff0a8f (writer)
2018-12-06 11:15:13.013563 I | rafthttp: peer 321b5633e49b8ca2 became active
2018-12-06 11:15:13.013615 I | rafthttp: established a TCP streaming connection with peer 321b5633e49b8ca2 (stream MsgApp v2 reader)
2018-12-06 11:15:13.013619 I | rafthttp: started streaming with peer 670d13ff11ff0a8f (writer)
2018-12-06 11:15:13.013673 I | rafthttp: established a TCP streaming connection with peer 321b5633e49b8ca2 (stream Message reader)
2018-12-06 11:15:13.014008 I | rafthttp: started peer 670d13ff11ff0a8f
2018-12-06 11:15:13.014057 I | rafthttp: added peer 670d13ff11ff0a8f
2018-12-06 11:15:13.014077 I | rafthttp: started streaming with peer 670d13ff11ff0a8f (stream Message reader)
2018-12-06 11:15:13.014250 I | rafthttp: started streaming with peer 670d13ff11ff0a8f (stream MsgApp v2 reader)
2018-12-06 11:15:13.014301 N | etcdserver/membership: set the initial cluster version to 3.0
2018-12-06 11:15:13.014353 I | etcdserver/api: enabled capabilities for version 3.0
2018-12-06 11:15:13.014435 N | etcdserver/membership: updated the cluster version from 3.0 to 3.3
2018-12-06 11:15:13.014489 I | etcdserver/api: enabled capabilities for version 3.3
2018-12-06 11:15:13.015992 E | etcdserver: the member has been permanently removed from the cluster
2018-12-06 11:15:13.016004 I | etcdserver: the data-dir used by this member must be removed.
2018-12-06 11:15:13.016020 E | etcdserver: publish error: etcdserver: request cancelled
2018-12-06 11:15:13.016034 I | etcdserver: aborting publish because server is stopped
2018-12-06 11:15:13.016566 I | rafthttp: stopping peer 321b5633e49b8ca2...
2018-12-06 11:15:13.016590 I | rafthttp: stopped streaming with peer 321b5633e49b8ca2 (writer)
2018-12-06 11:15:13.016601 I | rafthttp: stopped streaming with peer 321b5633e49b8ca2 (writer)
2018-12-06 11:15:13.016625 I | rafthttp: stopped HTTP pipelining with peer 321b5633e49b8ca2
2018-12-06 11:15:13.016741 W | rafthttp: lost the TCP streaming connection with peer 321b5633e49b8ca2 (stream MsgApp v2 reader)
2018-12-06 11:15:13.016760 E | rafthttp: failed to read 321b5633e49b8ca2 on stream MsgApp v2 (context canceled)
2018-12-06 11:15:13.016769 I | rafthttp: peer 321b5633e49b8ca2 became inactive (message send to peer failed)
2018-12-06 11:15:13.016780 I | rafthttp: stopped streaming with peer 321b5633e49b8ca2 (stream MsgApp v2 reader)
2018-12-06 11:15:13.016853 W | rafthttp: lost the TCP streaming connection with peer 321b5633e49b8ca2 (stream Message reader)
2018-12-06 11:15:13.016874 I | rafthttp: stopped streaming with peer 321b5633e49b8ca2 (stream Message reader)
2018-12-06 11:15:13.016886 I | rafthttp: stopped peer 321b5633e49b8ca2
2018-12-06 11:15:13.016895 I | rafthttp: stopping peer 670d13ff11ff0a8f...
2018-12-06 11:15:13.016912 I | rafthttp: stopped streaming with peer 670d13ff11ff0a8f (writer)
2018-12-06 11:15:13.016923 I | rafthttp: stopped streaming with peer 670d13ff11ff0a8f (writer)
2018-12-06 11:15:13.016946 I | rafthttp: stopped HTTP pipelining with peer 670d13ff11ff0a8f
2018-12-06 11:15:13.017022 I | rafthttp: stopped streaming with peer 670d13ff11ff0a8f (stream MsgApp v2 reader)
2018-12-06 11:15:13.017067 I | rafthttp: stopped streaming with peer 670d13ff11ff0a8f (stream Message reader)
2018-12-06 11:15:13.017076 I | rafthttp: stopped peer 670d13ff11ff0a8f

zhaoshan86 avatar Dec 06 '18 11:12 zhaoshan86

Thanks for the logs! I am afraid that we didn't have time yet to work on a fix for this issue but it is on our board.

tompizmor avatar Dec 12 '18 07:12 tompizmor

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

stale[bot] avatar Dec 27 '18 07:12 stale[bot]

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

stale[bot] avatar Jan 01 '19 08:01 stale[bot]

I'm still seeing this exact issue. Can we re-open this?

jeff-french avatar Jan 24 '19 20:01 jeff-french

Hi @jeff-french,

Yes! It seems there are still some conditions where this issue is reproducible. We will need to take another look. We talked about them in this other issue, in case you are interested. In summary, is reproducible if authentication is disabled and you delete the first pod.

tompizmor avatar Jan 25 '19 08:01 tompizmor

We are seeing this issue in a scenario where authentication is disabled and the first pod gets deleted. It happened on GKE when applying a node upgrade to the node pool. The first pod happened to be on the first node that got rolled and when it came back up it was not able to rejoin or restart the cluster. Then as subsequent nodes rolled, the other pods failed to come online and rejoin the cluster.

jeff-french avatar Jan 25 '19 16:01 jeff-french

Sorry yes! I meant to say authentication disabled. I just edited my previous comment.

tompizmor avatar Jan 28 '19 09:01 tompizmor

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

stale[bot] avatar Feb 12 '19 09:02 stale[bot]

We still need to look into it

tompizmor avatar Feb 12 '19 15:02 tompizmor

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

stale[bot] avatar Feb 27 '19 15:02 stale[bot]

This issue should be already fixed thanks to https://github.com/bitnami/charts/pull/1064. I am going to close the issue, please create a new one if you find another issue.

tompizmor avatar Mar 01 '19 07:03 tompizmor