{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/mongodb/pulls/comments/54878249","id":54878249,"diff_hunk":"@@ -117,23 +117,60 @@ function mongo_initiate() {\n \n # get the address of the current primary member\n function mongo_primary_member_addr() {\n-  local current_endpoints=$(endpoints)\n-  local mongo_node=\"$(echo \"${current_endpoints}\" | grep -v \"$(container_addr)\" | head -1):${CONTAINER_PORT}\"\n-  echo -n $(mongo admin -u admin -p \"${MONGODB_ADMIN_PASSWORD}\" --host ${mongo_node} --quiet --eval \"print(rs.isMaster().primary);\")\n+  endpoints | grep -v \"$(container_addr)\" | while read mongo_node; do\n+    cmd_output=\"$(mongo admin -u admin -p \"$MONGODB_ADMIN_PASSWORD\" --host \"$mongo_node:$CONTAINER_PORT\" --eval 'print(rs.isMaster().primary)' --quiet || true)\"","path":"2.4/root/usr/share/container-scripts/mongodb/common.sh","position":8,"original_position":8,"commit_id":"03715bc5929aad12ecce18cd95ae7c2684d6c2a8","original_commit_id":"03715bc5929aad12ecce18cd95ae7c2684d6c2a8","user":{"login":"rhcarvalho","id":88819,"avatar_url":"https://avatars.githubusercontent.com/u/88819?v=3","gravatar_id":"","url":"https://api.github.com/users/rhcarvalho","html_url":"https://github.com/rhcarvalho","followers_url":"https://api.github.com/users/rhcarvalho/followers","following_url":"https://api.github.com/users/rhcarvalho/following{/other_user}","gists_url":"https://api.github.com/users/rhcarvalho/gists{/gist_id}","starred_url":"https://api.github.com/users/rhcarvalho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhcarvalho/subscriptions","organizations_url":"https://api.github.com/users/rhcarvalho/orgs","repos_url":"https://api.github.com/users/rhcarvalho/repos","events_url":"https://api.github.com/users/rhcarvalho/events{/privacy}","received_events_url":"https://api.github.com/users/rhcarvalho/received_events","type":"User","site_admin":false},"body":"> I believe that we can't inline the cmd1 | cmd2 here.\r\n\r\nLet's try:\r\n\r\n```bash\r\n\r\nlocal addr\r\nif addr=\"$(mongo admin -u admin -p \"$MONGODB_ADMIN_PASSWORD\" --host \"$mongo_node:$CONTAINER_PORT\" --eval 'print(rs.isMaster().primary)' --quiet | grep -x \"$ip_and_port_regexp\")\"; then\r\n  echo \"$addr\"\r\n  exit 0\r\nfi\r\n\r\n# ...\r\n```\r\n\r\nAnd I really think we don't need the `grep` part.\r\n\r\nWDYT? :)","created_at":"2016-03-03T13:23:41Z","updated_at":"2016-03-03T13:23:41Z","html_url":"https://github.com/openshift/mongodb/pull/133#discussion_r54878249","pull_request_url":"https://api.github.com/repos/openshift/mongodb/pulls/133","_links":{"self":{"href":"https://api.github.com/repos/openshift/mongodb/pulls/comments/54878249"},"html":{"href":"https://github.com/openshift/mongodb/pull/133#discussion_r54878249"},"pull_request":{"href":"https://api.github.com/repos/openshift/mongodb/pulls/133"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/mongodb/pulls/133","id":61284181,"html_url":"https://github.com/openshift/mongodb/pull/133","diff_url":"https://github.com/openshift/mongodb/pull/133.diff","patch_url":"https://github.com/openshift/mongodb/pull/133.patch","issue_url":"https://api.github.com/repos/openshift/mongodb/issues/133","number":133,"state":"open","locked":false,"title":"Fix getting of primary member","user":{"login":"php-coder","id":87088,"avatar_url":"https://avatars.githubusercontent.com/u/87088?v=3","gravatar_id":"","url":"https://api.github.com/users/php-coder","html_url":"https://github.com/php-coder","followers_url":"https://api.github.com/users/php-coder/followers","following_url":"https://api.github.com/users/php-coder/following{/other_user}","gists_url":"https://api.github.com/users/php-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/php-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-coder/subscriptions","organizations_url":"https://api.github.com/users/php-coder/orgs","repos_url":"https://api.github.com/users/php-coder/repos","events_url":"https://api.github.com/users/php-coder/events{/privacy}","received_events_url":"https://api.github.com/users/php-coder/received_events","type":"User","site_admin":false},"body":"Modified logic for getting address of primary member: try to ask all neighbour nodes. Also mongo may print error message to stdout and I've added fix for that too. Plus minor improvements (like adding quotes).\r\n\r\nPTAL @bparees @rhcarvalho\r\n\r\nFixes #125","created_at":"2016-03-01T18:13:47Z","updated_at":"2016-03-03T13:23:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f79269ec5339aa80de13f9ed53b53a7128533c0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openshift/mongodb/pulls/133/commits","review_comments_url":"https://api.github.com/repos/openshift/mongodb/pulls/133/comments","review_comment_url":"https://api.github.com/repos/openshift/mongodb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/mongodb/issues/133/comments","statuses_url":"https://api.github.com/repos/openshift/mongodb/statuses/03715bc5929aad12ecce18cd95ae7c2684d6c2a8","head":{"label":"php-coder:fix_gettting_of_primary_member","ref":"fix_gettting_of_primary_member","sha":"03715bc5929aad12ecce18cd95ae7c2684d6c2a8","user":{"login":"php-coder","id":87088,"avatar_url":"https://avatars.githubusercontent.com/u/87088?v=3","gravatar_id":"","url":"https://api.github.com/users/php-coder","html_url":"https://github.com/php-coder","followers_url":"https://api.github.com/users/php-coder/followers","following_url":"https://api.github.com/users/php-coder/following{/other_user}","gists_url":"https://api.github.com/users/php-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/php-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-coder/subscriptions","organizations_url":"https://api.github.com/users/php-coder/orgs","repos_url":"https://api.github.com/users/php-coder/repos","events_url":"https://api.github.com/users/php-coder/events{/privacy}","received_events_url":"https://api.github.com/users/php-coder/received_events","type":"User","site_admin":false},"repo":{"id":50997677,"name":"mongodb","full_name":"php-coder/mongodb","owner":{"login":"php-coder","id":87088,"avatar_url":"https://avatars.githubusercontent.com/u/87088?v=3","gravatar_id":"","url":"https://api.github.com/users/php-coder","html_url":"https://github.com/php-coder","followers_url":"https://api.github.com/users/php-coder/followers","following_url":"https://api.github.com/users/php-coder/following{/other_user}","gists_url":"https://api.github.com/users/php-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/php-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-coder/subscriptions","organizations_url":"https://api.github.com/users/php-coder/orgs","repos_url":"https://api.github.com/users/php-coder/repos","events_url":"https://api.github.com/users/php-coder/events{/privacy}","received_events_url":"https://api.github.com/users/php-coder/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/php-coder/mongodb","description":"","fork":true,"url":"https://api.github.com/repos/php-coder/mongodb","forks_url":"https://api.github.com/repos/php-coder/mongodb/forks","keys_url":"https://api.github.com/repos/php-coder/mongodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/php-coder/mongodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/php-coder/mongodb/teams","hooks_url":"https://api.github.com/repos/php-coder/mongodb/hooks","issue_events_url":"https://api.github.com/repos/php-coder/mongodb/issues/events{/number}","events_url":"https://api.github.com/repos/php-coder/mongodb/events","assignees_url":"https://api.github.com/repos/php-coder/mongodb/assignees{/user}","branches_url":"https://api.github.com/repos/php-coder/mongodb/branches{/branch}","tags_url":"https://api.github.com/repos/php-coder/mongodb/tags","blobs_url":"https://api.github.com/repos/php-coder/mongodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/php-coder/mongodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/php-coder/mongodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/php-coder/mongodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/php-coder/mongodb/statuses/{sha}","languages_url":"https://api.github.com/repos/php-coder/mongodb/languages","stargazers_url":"https://api.github.com/repos/php-coder/mongodb/stargazers","contributors_url":"https://api.github.com/repos/php-coder/mongodb/contributors","subscribers_url":"https://api.github.com/repos/php-coder/mongodb/subscribers","subscription_url":"https://api.github.com/repos/php-coder/mongodb/subscription","commits_url":"https://api.github.com/repos/php-coder/mongodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/php-coder/mongodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/php-coder/mongodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/php-coder/mongodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/php-coder/mongodb/contents/{+path}","compare_url":"https://api.github.com/repos/php-coder/mongodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/php-coder/mongodb/merges","archive_url":"https://api.github.com/repos/php-coder/mongodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/php-coder/mongodb/downloads","issues_url":"https://api.github.com/repos/php-coder/mongodb/issues{/number}","pulls_url":"https://api.github.com/repos/php-coder/mongodb/pulls{/number}","milestones_url":"https://api.github.com/repos/php-coder/mongodb/milestones{/number}","notifications_url":"https://api.github.com/repos/php-coder/mongodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/php-coder/mongodb/labels{/name}","releases_url":"https://api.github.com/repos/php-coder/mongodb/releases{/id}","deployments_url":"https://api.github.com/repos/php-coder/mongodb/deployments","created_at":"2016-02-03T12:18:53Z","updated_at":"2016-02-03T12:18:55Z","pushed_at":"2016-03-02T15:19:59Z","git_url":"git://github.com/php-coder/mongodb.git","ssh_url":"git@github.com:php-coder/mongodb.git","clone_url":"https://github.com/php-coder/mongodb.git","svn_url":"https://github.com/php-coder/mongodb","homepage":null,"size":176,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"openshift:master","ref":"master","sha":"a0427282f0fc35ac1c2ba516811c88ef6478d897","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":31970825,"name":"mongodb","full_name":"openshift/mongodb","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/mongodb","description":"","fork":false,"url":"https://api.github.com/repos/openshift/mongodb","forks_url":"https://api.github.com/repos/openshift/mongodb/forks","keys_url":"https://api.github.com/repos/openshift/mongodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/mongodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/mongodb/teams","hooks_url":"https://api.github.com/repos/openshift/mongodb/hooks","issue_events_url":"https://api.github.com/repos/openshift/mongodb/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/mongodb/events","assignees_url":"https://api.github.com/repos/openshift/mongodb/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/mongodb/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/mongodb/tags","blobs_url":"https://api.github.com/repos/openshift/mongodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/mongodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/mongodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/mongodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/mongodb/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/mongodb/languages","stargazers_url":"https://api.github.com/repos/openshift/mongodb/stargazers","contributors_url":"https://api.github.com/repos/openshift/mongodb/contributors","subscribers_url":"https://api.github.com/repos/openshift/mongodb/subscribers","subscription_url":"https://api.github.com/repos/openshift/mongodb/subscription","commits_url":"https://api.github.com/repos/openshift/mongodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/mongodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/mongodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/mongodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/mongodb/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/mongodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/mongodb/merges","archive_url":"https://api.github.com/repos/openshift/mongodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/mongodb/downloads","issues_url":"https://api.github.com/repos/openshift/mongodb/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/mongodb/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/mongodb/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/mongodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/mongodb/labels{/name}","releases_url":"https://api.github.com/repos/openshift/mongodb/releases{/id}","deployments_url":"https://api.github.com/repos/openshift/mongodb/deployments","created_at":"2015-03-10T17:15:19Z","updated_at":"2016-02-25T17:29:54Z","pushed_at":"2016-03-03T12:12:42Z","git_url":"git://github.com/openshift/mongodb.git","ssh_url":"git@github.com:openshift/mongodb.git","clone_url":"https://github.com/openshift/mongodb.git","svn_url":"https://github.com/openshift/mongodb","homepage":null,"size":267,"stargazers_count":6,"watchers_count":6,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":19,"forks":48,"open_issues":19,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/mongodb/pulls/133"},"html":{"href":"https://github.com/openshift/mongodb/pull/133"},"issue":{"href":"https://api.github.com/repos/openshift/mongodb/issues/133"},"comments":{"href":"https://api.github.com/repos/openshift/mongodb/issues/133/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/mongodb/pulls/133/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/mongodb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/mongodb/pulls/133/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/mongodb/statuses/03715bc5929aad12ecce18cd95ae7c2684d6c2a8"}}}}