{"action":"created","issue":{"url":"https://api.github.com/repos/brpc/braft/issues/18","repository_url":"https://api.github.com/repos/brpc/braft","labels_url":"https://api.github.com/repos/brpc/braft/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/brpc/braft/issues/18/comments","events_url":"https://api.github.com/repos/brpc/braft/issues/18/events","html_url":"https://github.com/brpc/braft/issues/18","id":315718873,"number":18,"title":"如果想用hostname做peer ID，怎样改比较方便呢？","user":{"login":"pdu","id":278147,"avatar_url":"https://avatars0.githubusercontent.com/u/278147?v=4","gravatar_id":"","url":"https://api.github.com/users/pdu","html_url":"https://github.com/pdu","followers_url":"https://api.github.com/users/pdu/followers","following_url":"https://api.github.com/users/pdu/following{/other_user}","gists_url":"https://api.github.com/users/pdu/gists{/gist_id}","starred_url":"https://api.github.com/users/pdu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdu/subscriptions","organizations_url":"https://api.github.com/users/pdu/orgs","repos_url":"https://api.github.com/users/pdu/repos","events_url":"https://api.github.com/users/pdu/events{/privacy}","received_events_url":"https://api.github.com/users/pdu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-04-19T03:53:11Z","updated_at":"2018-04-19T07:09:49Z","closed_at":null,"author_association":"NONE","body":"比如在k8s里面用braft，stateful应用只能保证hostname不变，但是IP每次重启就变了。"},"comment":{"url":"https://api.github.com/repos/brpc/braft/issues/comments/382633725","html_url":"https://github.com/brpc/braft/issues/18#issuecomment-382633725","issue_url":"https://api.github.com/repos/brpc/braft/issues/18","id":382633725,"user":{"login":"chenzhangyi","id":6805583,"avatar_url":"https://avatars2.githubusercontent.com/u/6805583?v=4","gravatar_id":"","url":"https://api.github.com/users/chenzhangyi","html_url":"https://github.com/chenzhangyi","followers_url":"https://api.github.com/users/chenzhangyi/followers","following_url":"https://api.github.com/users/chenzhangyi/following{/other_user}","gists_url":"https://api.github.com/users/chenzhangyi/gists{/gist_id}","starred_url":"https://api.github.com/users/chenzhangyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenzhangyi/subscriptions","organizations_url":"https://api.github.com/users/chenzhangyi/orgs","repos_url":"https://api.github.com/users/chenzhangyi/repos","events_url":"https://api.github.com/users/chenzhangyi/events{/privacy}","received_events_url":"https://api.github.com/users/chenzhangyi/received_events","type":"User","site_admin":false},"created_at":"2018-04-19T07:09:49Z","updated_at":"2018-04-19T07:09:49Z","author_association":"MEMBER","body":"支持hostname并不难，让braft::PeerId适配下就好了，现在所有的传输和存储格式都是string，这不会带来兼容性问题。\r\n另外 brpc::Channel是支持动态更新hostname到ip的映射. 但是更新会有一点delay（主动refresh）.\r\n这里主要还是得确认几点;\r\n1. hostname会不会查出多个ip\r\n2. ip在多少时间内不会被重用.\r\n\r\n2018-04-19 15:01 GMT+08:00 Peng Du <notifications@github.com>:\r\n\r\n> 不能保证。k8s的stateful只能保证每次重启hostname不变，但是IP是不做限制的（刚被释放的IP，是否会被立即重用，\r\n> 这个我不确定，但是我感觉应该会有限制，待确认）。\r\n>\r\n> 我现在简单的改了一个版本：\r\n> 1，peerID里面不用butil::EndPoint，自己用hostname + port来代替\r\n> 2，建立braft::Channel的时候，把hostname+port再转换成butil::EndPoint\r\n>\r\n> 这样解决了一个问题是：\r\n> 1，node重启后，重新加入raft group后，不用再去sync所有的snapshot+binlog\r\n>\r\n> 但是还有个问题：\r\n> 1，leader的replicator是在peers加入的时候建立brpc::Channel的，在那个阶段我把hostname解析成了IP。\r\n> 但是node重启后，leader并不知道背后的IP已经变了。\r\n>\r\n> 感觉这个问题在brpc::Channel层面解决会更好一点。\r\n>\r\n> 我现在暂时的解决方式是：外围的master/tools发现node重启后，会给leader发请求remove_peers，\r\n> 在node起来后，在add_peers。\r\n> 但是如果braft能够自动处理的话就更好了。\r\n>\r\n> BTW：etcd的raft实现是支持用hostname的，可能因为他们原生就是要用在k8s上的吧。\r\n>\r\n> —\r\n> You are receiving this because you commented.\r\n> Reply to this email directly, view it on GitHub\r\n> <https://github.com/brpc/braft/issues/18#issuecomment-382631877>, or mute\r\n> the thread\r\n> <https://github.com/notifications/unsubscribe-auth/AGfYT7GHpHGe4XkuIYmRuHdHJydZx4Baks5tqDZLgaJpZM4TbHFV>\r\n> .\r\n>\r\n"}}
{"actor":{"display_login":"chenzhangyi"}}