{"action":"created","comment":{"url":"https://api.github.com/repos/runconduit/conduit/pulls/comments/182214467","pull_request_review_id":112977901,"id":182214467,"diff_hunk":"@@ -85,9 +86,13 @@ func (l *endpointListener) toWeightedAddrSet(endpoints []common.TcpAddress) *pb.\n \t\t\tif len(resultingPods) == 0 || resultingPods[0] == nil {\n \t\t\t\tlog.Errorf(\"Could not find pod for IP [%s], this IP will be sent with no metric labels.\", ipAsString)\n \t\t\t} else {\n-\t\t\t\tpod := resultingPods[0]\n-\t\t\t\tmetricLabelsForPod = pkgK8s.GetOwnerLabels(pod.ObjectMeta)\n-\t\t\t\tmetricLabelsForPod[\"pod\"] = pod.Name\n+\t\t\t\tfor _, pod := range resultingPods {\n+\t\t\t\t\tif pod.Status.Phase == coreV1.PodRunning {\n+\t\t\t\t\t\tmetricLabelsForPod = pkgK8s.GetOwnerLabels(pod.ObjectMeta)\n+\t\t\t\t\t\tmetricLabelsForPod[\"pod\"] = pod.Name\n+\t\t\t\t\t\tbreak\n+\t\t\t\t\t}\n+\t\t\t\t}","path":"controller/destination/listener.go","position":21,"original_position":21,"commit_id":"57c418712beeb311cc2131852d8828da71dc0380","original_commit_id":"57c418712beeb311cc2131852d8828da71dc0380","user":{"login":"olix0r","id":240738,"avatar_url":"https://avatars3.githubusercontent.com/u/240738?v=4","gravatar_id":"","url":"https://api.github.com/users/olix0r","html_url":"https://github.com/olix0r","followers_url":"https://api.github.com/users/olix0r/followers","following_url":"https://api.github.com/users/olix0r/following{/other_user}","gists_url":"https://api.github.com/users/olix0r/gists{/gist_id}","starred_url":"https://api.github.com/users/olix0r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olix0r/subscriptions","organizations_url":"https://api.github.com/users/olix0r/orgs","repos_url":"https://api.github.com/users/olix0r/repos","events_url":"https://api.github.com/users/olix0r/events{/privacy}","received_events_url":"https://api.github.com/users/olix0r/received_events","type":"User","site_admin":false},"body":"tioli: if you split out a smaller method:\r\n\r\n```go\r\nfunc (l *endpointListener) toWeightedAddrSet(endpoints []common.TcpAddress) *pb.WeightedAddrSet {\r\n \taddrs := make([]*pb.WeightedAddr, 0)\r\n \tfor i, address := range endpoints {\r\n        a, err := l.toWeightedAddr(address)\r\n        if err != nil {\r\n          // ...\r\n        }\r\n\t\taddrs = append(addrs, a)\r\n\t}\r\n\r\n\treturn &pb.WeightedAddrSet{\r\n\t\tAddrs:        addrs,\r\n\t\tMetricLabels: l.labels,\r\n    }\r\n}\r\n\r\nfunc (l *endpointListener) toWeightedAddr(address common.TcpAddress) (*pb.WeightedAddr, error) {\r\n    wa := pb.WeightedAddr{\r\n\t\tAddr:         endpoints,\r\n\t\tWeight:       1,\r\n\t\tMetricLabels: map[string]string{},\r\n     }\r\n\r\n\tipAsString := util.IPToString(address.Ip)\r\n\tresultingPods, err := l.podsByIp.GetPodsByIndex(ipAsString)\r\n\tif err != nil {\r\n        return err\r\n\t}\r\n\r\n\tif len(resultingPods) == 0 || resultingPods[0] == nil {\r\n\t\tlog.Errorf(\"Could not find pod for IP [%s], this IP will be sent with no metric labels.\", ipAsString)\r\n        return wa, nil\r\n\t}\r\n\r\n\tfor _, pod := range resultingPods {\r\n\t\tif pod.Status.Phase == coreV1.PodRunning {\r\n\t\t\twa.MetricLabels = pkgK8s.GetOwnerLabels(pod.ObjectMeta)\r\n\t\t\twa.MetricLabels[\"pod\"] = pod.Name\r\n\t\t\tbreak\r\n\t\t}\r\n\t}\r\n    return wa, nil\r\n}\r\n```\r\n\r\nI find this to be slightly more readable, as the control flow in `toWeightedAddr` is easier for me to follow.","created_at":"2018-04-17T20:26:39Z","updated_at":"2018-04-17T20:32:56Z","html_url":"https://github.com/runconduit/conduit/pull/781#discussion_r182214467","pull_request_url":"https://api.github.com/repos/runconduit/conduit/pulls/781","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/comments/182214467"},"html":{"href":"https://github.com/runconduit/conduit/pull/781#discussion_r182214467"},"pull_request":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/781"}}},"pull_request":{"url":"https://api.github.com/repos/runconduit/conduit/pulls/781","id":182279442,"html_url":"https://github.com/runconduit/conduit/pull/781","diff_url":"https://github.com/runconduit/conduit/pull/781.diff","patch_url":"https://github.com/runconduit/conduit/pull/781.patch","issue_url":"https://api.github.com/repos/runconduit/conduit/issues/781","number":781,"state":"open","locked":false,"title":"Destination service returns \"Running\" pod labels","user":{"login":"siggy","id":236915,"avatar_url":"https://avatars2.githubusercontent.com/u/236915?v=4","gravatar_id":"","url":"https://api.github.com/users/siggy","html_url":"https://github.com/siggy","followers_url":"https://api.github.com/users/siggy/followers","following_url":"https://api.github.com/users/siggy/following{/other_user}","gists_url":"https://api.github.com/users/siggy/gists{/gist_id}","starred_url":"https://api.github.com/users/siggy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siggy/subscriptions","organizations_url":"https://api.github.com/users/siggy/orgs","repos_url":"https://api.github.com/users/siggy/repos","events_url":"https://api.github.com/users/siggy/events{/privacy}","received_events_url":"https://api.github.com/users/siggy/received_events","type":"User","site_admin":false},"body":"When the Destination sees an IP address, it looks up Pods by that IP,\r\nand associates Pod label data to it. If the lookup by IP returned more\r\nthan one Pod, it simply picked the first one. This is not correct,\r\nspecifically in cases where one pod is in a Running state, and others\r\nare not.\r\n\r\nModify the Destination service to only return label data for Pods in the\r\nRunning state.\r\n\r\nFixes #773\r\n\r\nSigned-off-by: Andrew Seigner <siggy@buoyant.io>","created_at":"2018-04-17T20:06:26Z","updated_at":"2018-04-17T20:32:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c3152b4a4f1e2a344283f3ccbfa0066f339e9189","assignee":{"login":"siggy","id":236915,"avatar_url":"https://avatars2.githubusercontent.com/u/236915?v=4","gravatar_id":"","url":"https://api.github.com/users/siggy","html_url":"https://github.com/siggy","followers_url":"https://api.github.com/users/siggy/followers","following_url":"https://api.github.com/users/siggy/following{/other_user}","gists_url":"https://api.github.com/users/siggy/gists{/gist_id}","starred_url":"https://api.github.com/users/siggy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siggy/subscriptions","organizations_url":"https://api.github.com/users/siggy/orgs","repos_url":"https://api.github.com/users/siggy/repos","events_url":"https://api.github.com/users/siggy/events{/privacy}","received_events_url":"https://api.github.com/users/siggy/received_events","type":"User","site_admin":false},"assignees":[{"login":"siggy","id":236915,"avatar_url":"https://avatars2.githubusercontent.com/u/236915?v=4","gravatar_id":"","url":"https://api.github.com/users/siggy","html_url":"https://github.com/siggy","followers_url":"https://api.github.com/users/siggy/followers","following_url":"https://api.github.com/users/siggy/following{/other_user}","gists_url":"https://api.github.com/users/siggy/gists{/gist_id}","starred_url":"https://api.github.com/users/siggy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siggy/subscriptions","organizations_url":"https://api.github.com/users/siggy/orgs","repos_url":"https://api.github.com/users/siggy/repos","events_url":"https://api.github.com/users/siggy/events{/privacy}","received_events_url":"https://api.github.com/users/siggy/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":773710190,"url":"https://api.github.com/repos/runconduit/conduit/labels/area/controller","name":"area/controller","color":"0052CC","default":false},{"id":866158135,"url":"https://api.github.com/repos/runconduit/conduit/labels/review","name":"review","color":"f4bffc","default":false}],"milestone":{"url":"https://api.github.com/repos/runconduit/conduit/milestones/10","html_url":"https://github.com/runconduit/conduit/milestone/10","labels_url":"https://api.github.com/repos/runconduit/conduit/milestones/10/labels","id":3272052,"number":10,"title":"0.4.1","description":"Rich, Kubernetes-aware debugging","creator":{"login":"olix0r","id":240738,"avatar_url":"https://avatars3.githubusercontent.com/u/240738?v=4","gravatar_id":"","url":"https://api.github.com/users/olix0r","html_url":"https://github.com/olix0r","followers_url":"https://api.github.com/users/olix0r/followers","following_url":"https://api.github.com/users/olix0r/following{/other_user}","gists_url":"https://api.github.com/users/olix0r/gists{/gist_id}","starred_url":"https://api.github.com/users/olix0r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olix0r/subscriptions","organizations_url":"https://api.github.com/users/olix0r/orgs","repos_url":"https://api.github.com/users/olix0r/repos","events_url":"https://api.github.com/users/olix0r/events{/privacy}","received_events_url":"https://api.github.com/users/olix0r/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":3,"state":"open","created_at":"2018-04-16T21:05:23Z","updated_at":"2018-04-17T20:06:26Z","due_on":"2018-04-26T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/runconduit/conduit/pulls/781/commits","review_comments_url":"https://api.github.com/repos/runconduit/conduit/pulls/781/comments","review_comment_url":"https://api.github.com/repos/runconduit/conduit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/runconduit/conduit/issues/781/comments","statuses_url":"https://api.github.com/repos/runconduit/conduit/statuses/57c418712beeb311cc2131852d8828da71dc0380","head":{"label":"runconduit:siggy/destination-running","ref":"siggy/destination-running","sha":"57c418712beeb311cc2131852d8828da71dc0380","user":{"login":"runconduit","id":33942733,"avatar_url":"https://avatars2.githubusercontent.com/u/33942733?v=4","gravatar_id":"","url":"https://api.github.com/users/runconduit","html_url":"https://github.com/runconduit","followers_url":"https://api.github.com/users/runconduit/followers","following_url":"https://api.github.com/users/runconduit/following{/other_user}","gists_url":"https://api.github.com/users/runconduit/gists{/gist_id}","starred_url":"https://api.github.com/users/runconduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runconduit/subscriptions","organizations_url":"https://api.github.com/users/runconduit/orgs","repos_url":"https://api.github.com/users/runconduit/repos","events_url":"https://api.github.com/users/runconduit/events{/privacy}","received_events_url":"https://api.github.com/users/runconduit/received_events","type":"Organization","site_admin":false},"repo":{"id":113106184,"name":"conduit","full_name":"runconduit/conduit","owner":{"login":"runconduit","id":33942733,"avatar_url":"https://avatars2.githubusercontent.com/u/33942733?v=4","gravatar_id":"","url":"https://api.github.com/users/runconduit","html_url":"https://github.com/runconduit","followers_url":"https://api.github.com/users/runconduit/followers","following_url":"https://api.github.com/users/runconduit/following{/other_user}","gists_url":"https://api.github.com/users/runconduit/gists{/gist_id}","starred_url":"https://api.github.com/users/runconduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runconduit/subscriptions","organizations_url":"https://api.github.com/users/runconduit/orgs","repos_url":"https://api.github.com/users/runconduit/repos","events_url":"https://api.github.com/users/runconduit/events{/privacy}","received_events_url":"https://api.github.com/users/runconduit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/runconduit/conduit","description":"Ultralight service mesh for Kubernetes","fork":false,"url":"https://api.github.com/repos/runconduit/conduit","forks_url":"https://api.github.com/repos/runconduit/conduit/forks","keys_url":"https://api.github.com/repos/runconduit/conduit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runconduit/conduit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runconduit/conduit/teams","hooks_url":"https://api.github.com/repos/runconduit/conduit/hooks","issue_events_url":"https://api.github.com/repos/runconduit/conduit/issues/events{/number}","events_url":"https://api.github.com/repos/runconduit/conduit/events","assignees_url":"https://api.github.com/repos/runconduit/conduit/assignees{/user}","branches_url":"https://api.github.com/repos/runconduit/conduit/branches{/branch}","tags_url":"https://api.github.com/repos/runconduit/conduit/tags","blobs_url":"https://api.github.com/repos/runconduit/conduit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runconduit/conduit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runconduit/conduit/git/refs{/sha}","trees_url":"https://api.github.com/repos/runconduit/conduit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runconduit/conduit/statuses/{sha}","languages_url":"https://api.github.com/repos/runconduit/conduit/languages","stargazers_url":"https://api.github.com/repos/runconduit/conduit/stargazers","contributors_url":"https://api.github.com/repos/runconduit/conduit/contributors","subscribers_url":"https://api.github.com/repos/runconduit/conduit/subscribers","subscription_url":"https://api.github.com/repos/runconduit/conduit/subscription","commits_url":"https://api.github.com/repos/runconduit/conduit/commits{/sha}","git_commits_url":"https://api.github.com/repos/runconduit/conduit/git/commits{/sha}","comments_url":"https://api.github.com/repos/runconduit/conduit/comments{/number}","issue_comment_url":"https://api.github.com/repos/runconduit/conduit/issues/comments{/number}","contents_url":"https://api.github.com/repos/runconduit/conduit/contents/{+path}","compare_url":"https://api.github.com/repos/runconduit/conduit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runconduit/conduit/merges","archive_url":"https://api.github.com/repos/runconduit/conduit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runconduit/conduit/downloads","issues_url":"https://api.github.com/repos/runconduit/conduit/issues{/number}","pulls_url":"https://api.github.com/repos/runconduit/conduit/pulls{/number}","milestones_url":"https://api.github.com/repos/runconduit/conduit/milestones{/number}","notifications_url":"https://api.github.com/repos/runconduit/conduit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runconduit/conduit/labels{/name}","releases_url":"https://api.github.com/repos/runconduit/conduit/releases{/id}","deployments_url":"https://api.github.com/repos/runconduit/conduit/deployments","created_at":"2017-12-04T23:16:56Z","updated_at":"2018-04-17T19:53:24Z","pushed_at":"2018-04-17T20:07:29Z","git_url":"git://github.com/runconduit/conduit.git","ssh_url":"git@github.com:runconduit/conduit.git","clone_url":"https://github.com/runconduit/conduit.git","svn_url":"https://github.com/runconduit/conduit","homepage":"https://conduit.io","size":4756,"stargazers_count":1435,"watchers_count":1435,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":78,"mirror_url":null,"archived":false,"open_issues_count":158,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":78,"open_issues":158,"watchers":1435,"default_branch":"master"}},"base":{"label":"runconduit:master","ref":"master","sha":"3cd16e8e40d4831b10b5b0f3f69006997406c293","user":{"login":"runconduit","id":33942733,"avatar_url":"https://avatars2.githubusercontent.com/u/33942733?v=4","gravatar_id":"","url":"https://api.github.com/users/runconduit","html_url":"https://github.com/runconduit","followers_url":"https://api.github.com/users/runconduit/followers","following_url":"https://api.github.com/users/runconduit/following{/other_user}","gists_url":"https://api.github.com/users/runconduit/gists{/gist_id}","starred_url":"https://api.github.com/users/runconduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runconduit/subscriptions","organizations_url":"https://api.github.com/users/runconduit/orgs","repos_url":"https://api.github.com/users/runconduit/repos","events_url":"https://api.github.com/users/runconduit/events{/privacy}","received_events_url":"https://api.github.com/users/runconduit/received_events","type":"Organization","site_admin":false},"repo":{"id":113106184,"name":"conduit","full_name":"runconduit/conduit","owner":{"login":"runconduit","id":33942733,"avatar_url":"https://avatars2.githubusercontent.com/u/33942733?v=4","gravatar_id":"","url":"https://api.github.com/users/runconduit","html_url":"https://github.com/runconduit","followers_url":"https://api.github.com/users/runconduit/followers","following_url":"https://api.github.com/users/runconduit/following{/other_user}","gists_url":"https://api.github.com/users/runconduit/gists{/gist_id}","starred_url":"https://api.github.com/users/runconduit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runconduit/subscriptions","organizations_url":"https://api.github.com/users/runconduit/orgs","repos_url":"https://api.github.com/users/runconduit/repos","events_url":"https://api.github.com/users/runconduit/events{/privacy}","received_events_url":"https://api.github.com/users/runconduit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/runconduit/conduit","description":"Ultralight service mesh for Kubernetes","fork":false,"url":"https://api.github.com/repos/runconduit/conduit","forks_url":"https://api.github.com/repos/runconduit/conduit/forks","keys_url":"https://api.github.com/repos/runconduit/conduit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runconduit/conduit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runconduit/conduit/teams","hooks_url":"https://api.github.com/repos/runconduit/conduit/hooks","issue_events_url":"https://api.github.com/repos/runconduit/conduit/issues/events{/number}","events_url":"https://api.github.com/repos/runconduit/conduit/events","assignees_url":"https://api.github.com/repos/runconduit/conduit/assignees{/user}","branches_url":"https://api.github.com/repos/runconduit/conduit/branches{/branch}","tags_url":"https://api.github.com/repos/runconduit/conduit/tags","blobs_url":"https://api.github.com/repos/runconduit/conduit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runconduit/conduit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runconduit/conduit/git/refs{/sha}","trees_url":"https://api.github.com/repos/runconduit/conduit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runconduit/conduit/statuses/{sha}","languages_url":"https://api.github.com/repos/runconduit/conduit/languages","stargazers_url":"https://api.github.com/repos/runconduit/conduit/stargazers","contributors_url":"https://api.github.com/repos/runconduit/conduit/contributors","subscribers_url":"https://api.github.com/repos/runconduit/conduit/subscribers","subscription_url":"https://api.github.com/repos/runconduit/conduit/subscription","commits_url":"https://api.github.com/repos/runconduit/conduit/commits{/sha}","git_commits_url":"https://api.github.com/repos/runconduit/conduit/git/commits{/sha}","comments_url":"https://api.github.com/repos/runconduit/conduit/comments{/number}","issue_comment_url":"https://api.github.com/repos/runconduit/conduit/issues/comments{/number}","contents_url":"https://api.github.com/repos/runconduit/conduit/contents/{+path}","compare_url":"https://api.github.com/repos/runconduit/conduit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runconduit/conduit/merges","archive_url":"https://api.github.com/repos/runconduit/conduit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runconduit/conduit/downloads","issues_url":"https://api.github.com/repos/runconduit/conduit/issues{/number}","pulls_url":"https://api.github.com/repos/runconduit/conduit/pulls{/number}","milestones_url":"https://api.github.com/repos/runconduit/conduit/milestones{/number}","notifications_url":"https://api.github.com/repos/runconduit/conduit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runconduit/conduit/labels{/name}","releases_url":"https://api.github.com/repos/runconduit/conduit/releases{/id}","deployments_url":"https://api.github.com/repos/runconduit/conduit/deployments","created_at":"2017-12-04T23:16:56Z","updated_at":"2018-04-17T19:53:24Z","pushed_at":"2018-04-17T20:07:29Z","git_url":"git://github.com/runconduit/conduit.git","ssh_url":"git@github.com:runconduit/conduit.git","clone_url":"https://github.com/runconduit/conduit.git","svn_url":"https://github.com/runconduit/conduit","homepage":"https://conduit.io","size":4756,"stargazers_count":1435,"watchers_count":1435,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":78,"mirror_url":null,"archived":false,"open_issues_count":158,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":78,"open_issues":158,"watchers":1435,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/781"},"html":{"href":"https://github.com/runconduit/conduit/pull/781"},"issue":{"href":"https://api.github.com/repos/runconduit/conduit/issues/781"},"comments":{"href":"https://api.github.com/repos/runconduit/conduit/issues/781/comments"},"review_comments":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/781/comments"},"review_comment":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/runconduit/conduit/pulls/781/commits"},"statuses":{"href":"https://api.github.com/repos/runconduit/conduit/statuses/57c418712beeb311cc2131852d8828da71dc0380"}},"author_association":"OWNER"}}
{"actor":{"display_login":"olix0r"}}