{"action":"created","comment":{"url":"https://api.github.com/repos/samuel/go-zookeeper/pulls/comments/77136506","id":77136506,"diff_hunk":"@@ -317,6 +326,65 @@ func (c *Conn) connect() error {\n \t}\n }\n \n+func (c *Conn) resendZkAuth(reauthReadyChan chan struct{}) {\n+","path":"zk/conn.go","position":33,"original_position":33,"commit_id":"49f877f7828d18a24e961166f1f85dca5ea2e49f","original_commit_id":"49f877f7828d18a24e961166f1f85dca5ea2e49f","user":{"login":"alberts","id":409689,"avatar_url":"https://avatars.githubusercontent.com/u/409689?v=3","gravatar_id":"","url":"https://api.github.com/users/alberts","html_url":"https://github.com/alberts","followers_url":"https://api.github.com/users/alberts/followers","following_url":"https://api.github.com/users/alberts/following{/other_user}","gists_url":"https://api.github.com/users/alberts/gists{/gist_id}","starred_url":"https://api.github.com/users/alberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alberts/subscriptions","organizations_url":"https://api.github.com/users/alberts/orgs","repos_url":"https://api.github.com/users/alberts/repos","events_url":"https://api.github.com/users/alberts/events{/privacy}","received_events_url":"https://api.github.com/users/alberts/received_events","type":"User","site_admin":false},"body":"delete","created_at":"2016-09-01T08:51:06Z","updated_at":"2016-09-01T08:51:06Z","html_url":"https://github.com/samuel/go-zookeeper/pull/139#discussion_r77136506","pull_request_url":"https://api.github.com/repos/samuel/go-zookeeper/pulls/139","_links":{"self":{"href":"https://api.github.com/repos/samuel/go-zookeeper/pulls/comments/77136506"},"html":{"href":"https://github.com/samuel/go-zookeeper/pull/139#discussion_r77136506"},"pull_request":{"href":"https://api.github.com/repos/samuel/go-zookeeper/pulls/139"}}},"pull_request":{"url":"https://api.github.com/repos/samuel/go-zookeeper/pulls/139","id":83284838,"html_url":"https://github.com/samuel/go-zookeeper/pull/139","diff_url":"https://github.com/samuel/go-zookeeper/pull/139.diff","patch_url":"https://github.com/samuel/go-zookeeper/pull/139.patch","issue_url":"https://api.github.com/repos/samuel/go-zookeeper/issues/139","number":139,"state":"open","locked":false,"title":"Re-submit authentication data on reconnect","user":{"login":"vespian","id":2124609,"avatar_url":"https://avatars.githubusercontent.com/u/2124609?v=3","gravatar_id":"","url":"https://api.github.com/users/vespian","html_url":"https://github.com/vespian","followers_url":"https://api.github.com/users/vespian/followers","following_url":"https://api.github.com/users/vespian/following{/other_user}","gists_url":"https://api.github.com/users/vespian/gists{/gist_id}","starred_url":"https://api.github.com/users/vespian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vespian/subscriptions","organizations_url":"https://api.github.com/users/vespian/orgs","repos_url":"https://api.github.com/users/vespian/repos","events_url":"https://api.github.com/users/vespian/events{/privacy}","received_events_url":"https://api.github.com/users/vespian/received_events","type":"User","site_admin":false},"body":"In case when reconnection occurs, it is necessary to re-authenticate with ZK because it \"forgets\" the authentication data. Otherwise, the connection is unusable with messages like below popping up in the logs:\r\n```\r\n2016/08/29 12:08:36 [ERR] core: failed to write seal configuration: zk: not authenticated\r\n2016/08/29 12:08:46 [ERR] core: failed to write seal configuration: zk: not authenticated\r\n2016/08/29 12:08:56 [ERR] core: failed to write seal configuration: zk: not authenticated\r\n```\r\n\r\nThe problem can be reproduced with this simple program:\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"time\"\r\n\r\n\t\"github.com/samuel/go-zookeeper/zk\"\r\n)\r\n\r\nfunc main() {\r\n\tc, _, err := zk.Connect([]string{\"127.0.0.1\"}, time.Second) //*10)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tdefer c.Close()\r\n\r\n\tfor c.State() != zk.StateHasSession {\r\n\t\tfmt.Println(\"State: \", c.State())\r\n\t\ttime.Sleep(time.Second)\r\n\t}\r\n\tfmt.Printf(\"Connected to %s\\n\", c.Server())\r\n\r\n\tc.AddAuth(\"digest\", []byte(\"userfoo:passbar\"))\r\n\r\n\tacl := zk.DigestACL(zk.PermAll, \"userfoo\", \"passbar\")\r\n\r\n\t_, err = c.Create(\"/dir\", nil, 0, acl)\r\n\tif err != nil && err != zk.ErrNodeExists {\r\n\t\tpanic(err)\r\n\t}\r\n\r\n\tfor {\r\n\t\tres_path, err := c.Create(\"/dir/dupa\", []byte(\"maryna\"), zk.FlagEphemeral|zk.FlagSequence, acl)\r\n\t\tif err != nil {\r\n\t\t\tfmt.Printf(\"Error creating ephemeral node: %s\\n\", err)\r\n\t\t} else {\r\n\t\t\tfmt.Printf(\"Created node %s\\n\", res_path)\r\n\t\t}\r\n\t\ttime.Sleep(time.Second)\r\n\t}\r\n}\r\n\r\n```\r\n\r\nOne only needs to block tcp port 2181 traffic or pause/unpause ZK container/process.\r\n\r\nI have not found official ZK protocol specification but instead based my work on what ZK Python client `Kazoo` does: https://github.com/python-zk/kazoo/blob/master/kazoo/client.py#L722 The change basically stores all submitted auth credentials in connection structure, and on reconnect the sendLoop is stalled until all authentication data has been resubmitted. The re-submission happens synchronously, without involving sendLoop. After all data has been submitted, send loop starts and submits all queued requests. The recieveLoop is unchanged due to the fact that outstanding responses are purged on reconnect.\r\n\r\nThis patch may probably be still improved (not re-submitting the same auth data, de-duplicating auth data for `digest` schema, etc...) and I am not sure if this is the right approach, but I think this is a step into right direction :)\r\n\r\nI would be grateful for feedback.\r\n\r\nThanks!\r\npr","created_at":"2016-08-30T14:43:24Z","updated_at":"2016-09-01T08:51:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7f652f420c2458606293f99d7aed77b8b23458af","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/samuel/go-zookeeper/pulls/139/commits","review_comments_url":"https://api.github.com/repos/samuel/go-zookeeper/pulls/139/comments","review_comment_url":"https://api.github.com/repos/samuel/go-zookeeper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/samuel/go-zookeeper/issues/139/comments","statuses_url":"https://api.github.com/repos/samuel/go-zookeeper/statuses/49f877f7828d18a24e961166f1f85dca5ea2e49f","head":{"label":"vespian:vespian/reauth-on-reconnect","ref":"vespian/reauth-on-reconnect","sha":"49f877f7828d18a24e961166f1f85dca5ea2e49f","user":{"login":"vespian","id":2124609,"avatar_url":"https://avatars.githubusercontent.com/u/2124609?v=3","gravatar_id":"","url":"https://api.github.com/users/vespian","html_url":"https://github.com/vespian","followers_url":"https://api.github.com/users/vespian/followers","following_url":"https://api.github.com/users/vespian/following{/other_user}","gists_url":"https://api.github.com/users/vespian/gists{/gist_id}","starred_url":"https://api.github.com/users/vespian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vespian/subscriptions","organizations_url":"https://api.github.com/users/vespian/orgs","repos_url":"https://api.github.com/users/vespian/repos","events_url":"https://api.github.com/users/vespian/events{/privacy}","received_events_url":"https://api.github.com/users/vespian/received_events","type":"User","site_admin":false},"repo":{"id":62196416,"name":"go-zookeeper","full_name":"vespian/go-zookeeper","owner":{"login":"vespian","id":2124609,"avatar_url":"https://avatars.githubusercontent.com/u/2124609?v=3","gravatar_id":"","url":"https://api.github.com/users/vespian","html_url":"https://github.com/vespian","followers_url":"https://api.github.com/users/vespian/followers","following_url":"https://api.github.com/users/vespian/following{/other_user}","gists_url":"https://api.github.com/users/vespian/gists{/gist_id}","starred_url":"https://api.github.com/users/vespian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vespian/subscriptions","organizations_url":"https://api.github.com/users/vespian/orgs","repos_url":"https://api.github.com/users/vespian/repos","events_url":"https://api.github.com/users/vespian/events{/privacy}","received_events_url":"https://api.github.com/users/vespian/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vespian/go-zookeeper","description":"Native ZooKeeper client for Go","fork":true,"url":"https://api.github.com/repos/vespian/go-zookeeper","forks_url":"https://api.github.com/repos/vespian/go-zookeeper/forks","keys_url":"https://api.github.com/repos/vespian/go-zookeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vespian/go-zookeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vespian/go-zookeeper/teams","hooks_url":"https://api.github.com/repos/vespian/go-zookeeper/hooks","issue_events_url":"https://api.github.com/repos/vespian/go-zookeeper/issues/events{/number}","events_url":"https://api.github.com/repos/vespian/go-zookeeper/events","assignees_url":"https://api.github.com/repos/vespian/go-zookeeper/assignees{/user}","branches_url":"https://api.github.com/repos/vespian/go-zookeeper/branches{/branch}","tags_url":"https://api.github.com/repos/vespian/go-zookeeper/tags","blobs_url":"https://api.github.com/repos/vespian/go-zookeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vespian/go-zookeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vespian/go-zookeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/vespian/go-zookeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vespian/go-zookeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/vespian/go-zookeeper/languages","stargazers_url":"https://api.github.com/repos/vespian/go-zookeeper/stargazers","contributors_url":"https://api.github.com/repos/vespian/go-zookeeper/contributors","subscribers_url":"https://api.github.com/repos/vespian/go-zookeeper/subscribers","subscription_url":"https://api.github.com/repos/vespian/go-zookeeper/subscription","commits_url":"https://api.github.com/repos/vespian/go-zookeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/vespian/go-zookeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/vespian/go-zookeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/vespian/go-zookeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/vespian/go-zookeeper/contents/{+path}","compare_url":"https://api.github.com/repos/vespian/go-zookeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vespian/go-zookeeper/merges","archive_url":"https://api.github.com/repos/vespian/go-zookeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vespian/go-zookeeper/downloads","issues_url":"https://api.github.com/repos/vespian/go-zookeeper/issues{/number}","pulls_url":"https://api.github.com/repos/vespian/go-zookeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/vespian/go-zookeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/vespian/go-zookeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vespian/go-zookeeper/labels{/name}","releases_url":"https://api.github.com/repos/vespian/go-zookeeper/releases{/id}","deployments_url":"https://api.github.com/repos/vespian/go-zookeeper/deployments","created_at":"2016-06-29T04:50:50Z","updated_at":"2016-06-29T04:50:51Z","pushed_at":"2016-08-31T15:29:21Z","git_url":"git://github.com/vespian/go-zookeeper.git","ssh_url":"git@github.com:vespian/go-zookeeper.git","clone_url":"https://github.com/vespian/go-zookeeper.git","svn_url":"https://github.com/vespian/go-zookeeper","homepage":null,"size":224,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"samuel:master","ref":"master","sha":"8c6a1d79a44d2742da3660540d1fd43f4ddcfc8c","user":{"login":"samuel","id":8503,"avatar_url":"https://avatars.githubusercontent.com/u/8503?v=3","gravatar_id":"","url":"https://api.github.com/users/samuel","html_url":"https://github.com/samuel","followers_url":"https://api.github.com/users/samuel/followers","following_url":"https://api.github.com/users/samuel/following{/other_user}","gists_url":"https://api.github.com/users/samuel/gists{/gist_id}","starred_url":"https://api.github.com/users/samuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuel/subscriptions","organizations_url":"https://api.github.com/users/samuel/orgs","repos_url":"https://api.github.com/users/samuel/repos","events_url":"https://api.github.com/users/samuel/events{/privacy}","received_events_url":"https://api.github.com/users/samuel/received_events","type":"User","site_admin":false},"repo":{"id":4767354,"name":"go-zookeeper","full_name":"samuel/go-zookeeper","owner":{"login":"samuel","id":8503,"avatar_url":"https://avatars.githubusercontent.com/u/8503?v=3","gravatar_id":"","url":"https://api.github.com/users/samuel","html_url":"https://github.com/samuel","followers_url":"https://api.github.com/users/samuel/followers","following_url":"https://api.github.com/users/samuel/following{/other_user}","gists_url":"https://api.github.com/users/samuel/gists{/gist_id}","starred_url":"https://api.github.com/users/samuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuel/subscriptions","organizations_url":"https://api.github.com/users/samuel/orgs","repos_url":"https://api.github.com/users/samuel/repos","events_url":"https://api.github.com/users/samuel/events{/privacy}","received_events_url":"https://api.github.com/users/samuel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samuel/go-zookeeper","description":"Native ZooKeeper client for Go","fork":false,"url":"https://api.github.com/repos/samuel/go-zookeeper","forks_url":"https://api.github.com/repos/samuel/go-zookeeper/forks","keys_url":"https://api.github.com/repos/samuel/go-zookeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samuel/go-zookeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samuel/go-zookeeper/teams","hooks_url":"https://api.github.com/repos/samuel/go-zookeeper/hooks","issue_events_url":"https://api.github.com/repos/samuel/go-zookeeper/issues/events{/number}","events_url":"https://api.github.com/repos/samuel/go-zookeeper/events","assignees_url":"https://api.github.com/repos/samuel/go-zookeeper/assignees{/user}","branches_url":"https://api.github.com/repos/samuel/go-zookeeper/branches{/branch}","tags_url":"https://api.github.com/repos/samuel/go-zookeeper/tags","blobs_url":"https://api.github.com/repos/samuel/go-zookeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samuel/go-zookeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samuel/go-zookeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/samuel/go-zookeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samuel/go-zookeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/samuel/go-zookeeper/languages","stargazers_url":"https://api.github.com/repos/samuel/go-zookeeper/stargazers","contributors_url":"https://api.github.com/repos/samuel/go-zookeeper/contributors","subscribers_url":"https://api.github.com/repos/samuel/go-zookeeper/subscribers","subscription_url":"https://api.github.com/repos/samuel/go-zookeeper/subscription","commits_url":"https://api.github.com/repos/samuel/go-zookeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/samuel/go-zookeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/samuel/go-zookeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/samuel/go-zookeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/samuel/go-zookeeper/contents/{+path}","compare_url":"https://api.github.com/repos/samuel/go-zookeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samuel/go-zookeeper/merges","archive_url":"https://api.github.com/repos/samuel/go-zookeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samuel/go-zookeeper/downloads","issues_url":"https://api.github.com/repos/samuel/go-zookeeper/issues{/number}","pulls_url":"https://api.github.com/repos/samuel/go-zookeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/samuel/go-zookeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/samuel/go-zookeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samuel/go-zookeeper/labels{/name}","releases_url":"https://api.github.com/repos/samuel/go-zookeeper/releases{/id}","deployments_url":"https://api.github.com/repos/samuel/go-zookeeper/deployments","created_at":"2012-06-23T20:22:18Z","updated_at":"2016-09-01T06:44:25Z","pushed_at":"2016-08-31T15:29:22Z","git_url":"git://github.com/samuel/go-zookeeper.git","ssh_url":"git@github.com:samuel/go-zookeeper.git","clone_url":"https://github.com/samuel/go-zookeeper.git","svn_url":"https://github.com/samuel/go-zookeeper","homepage":null,"size":405,"stargazers_count":482,"watchers_count":482,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":215,"mirror_url":null,"open_issues_count":57,"forks":215,"open_issues":57,"watchers":482,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/samuel/go-zookeeper/pulls/139"},"html":{"href":"https://github.com/samuel/go-zookeeper/pull/139"},"issue":{"href":"https://api.github.com/repos/samuel/go-zookeeper/issues/139"},"comments":{"href":"https://api.github.com/repos/samuel/go-zookeeper/issues/139/comments"},"review_comments":{"href":"https://api.github.com/repos/samuel/go-zookeeper/pulls/139/comments"},"review_comment":{"href":"https://api.github.com/repos/samuel/go-zookeeper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/samuel/go-zookeeper/pulls/139/commits"},"statuses":{"href":"https://api.github.com/repos/samuel/go-zookeeper/statuses/49f877f7828d18a24e961166f1f85dca5ea2e49f"}}}}
{"actor":{"display_login":"alberts"}}