apache / kvrocks-controller

Apache Kvrocks Controller is a cluster management tool for Apache Kvrocks.
https://kvrocks.apache.org/
Apache License 2.0
84 stars 42 forks source link

Add the support of using Apache Zookeeper as an alternative storage #124

Closed git-hulk closed 10 months ago

jihuayu commented 10 months ago

I want to have a try. Can I use go-zookeeper/zk as Zookeeper client?

git-hulk commented 10 months ago

@jihuayu Thank you!

Can I use go-zookeeper/zk as Zookeeper client?

Yes for sure.

jihuayu commented 10 months ago

@git-hulk I have some question about etcd storage. In this code: When should we send true to e.leaderChangeCh, and when should we send false? https://github.com/apache/kvrocks-controller/blob/unstable/storage/persistence/etcd/etcd.go#L265-L277

I'm not very familiar with the Go language, but it seems like this continue is unnecessary. https://github.com/apache/kvrocks-controller/blob/unstable/storage/persistence/etcd/etcd.go#L271-L273

I would greatly appreciate it if you could help me answer my questions.

git-hulk commented 10 months ago

I'm not very familiar with the Go language, but it seems like this continue is unnecessary.

It's indeed a bug that Line 270 should be after #L271-L273. That said don't emit leader change even if the leader is not changed.

When should we send true to e.leaderChangeCh, and when should we send false?

For the initial design intention, we would like to send true to the channel if the leader is changed, and false if any other events. But from the current implementation, it doesn't care about the value of the channel and always checks if the leader has been changed.

git-hulk commented 10 months ago

For the zookeeper, it should be a bit simpler than the ETCD. Just create an ephemeral node to watch and try to create if the node does not exist.