{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments/174377513","pull_request_review_id":103719660,"id":174377513,"diff_hunk":"@@ -126,15 +150,30 @@ func getCheckLatestEvents(w http.ResponseWriter, r *http.Request) {\n \n func getPodMetadata(w http.ResponseWriter, r *http.Request) {\n \tvars := mux.Vars(r)\n+\tvar err error\n+\tvar slcB []byte\n \tnodeName := vars[\"nodeName\"]\n \tpodName := vars[\"podName\"]\n-\tsvcList := as.GetPodServiceNames(nodeName, podName)\n \n-\tslcB, err := json.Marshal(svcList)\n+\tif podName == \"*\" {\n+\t\tlog.Info(\"Computing service map on all nodes ...\")\n+\t\tsvcList, errNodes := as.GetServiceMapBundleOnNode(nodeName)\n+\t\tif errNodes != nil {\n+\t\t\tlog.Errorf(\"could not collect the service map for %s: %s\", nodeName, errNodes.Error())\n+\t\t}\n+\t\tslcB, err = json.Marshal(svcList)","path":"cmd/cluster-agent/api/agent/agent.go","position":74,"original_position":80,"commit_id":"1c98dbcee5176af0aff52eb84514343b4e5cd117","original_commit_id":"c975efae77f542530ff62665d35f69077bbc2b66","user":{"login":"JulienBalestra","id":8077192,"avatar_url":"https://avatars2.githubusercontent.com/u/8077192?v=4","gravatar_id":"","url":"https://api.github.com/users/JulienBalestra","html_url":"https://github.com/JulienBalestra","followers_url":"https://api.github.com/users/JulienBalestra/followers","following_url":"https://api.github.com/users/JulienBalestra/following{/other_user}","gists_url":"https://api.github.com/users/JulienBalestra/gists{/gist_id}","starred_url":"https://api.github.com/users/JulienBalestra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JulienBalestra/subscriptions","organizations_url":"https://api.github.com/users/JulienBalestra/orgs","repos_url":"https://api.github.com/users/JulienBalestra/repos","events_url":"https://api.github.com/users/JulienBalestra/events{/privacy}","received_events_url":"https://api.github.com/users/JulienBalestra/received_events","type":"User","site_admin":false},"body":"I think this controller need to be tested because you have a lot of conditions cascading on errors.\r\nI don't think we should return something different than a json in case of 404.\r\n\r\nThis controller should be cut, fail fast and not carrying too much contexts between conditions to use an unique return point.\r\n\r\nI feel like the error management inside maps is cumbersome and it's complex to keep a track of them. \r\nBecause you are still returning a map fulfilled with the error and the error as error...\r\nMaybe the aggregation of the errors should be done in the controller who needs to provide a json response.","created_at":"2018-03-14T08:07:13Z","updated_at":"2018-03-14T08:54:01Z","html_url":"https://github.com/DataDog/datadog-agent/pull/1427#discussion_r174377513","pull_request_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1427","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments/174377513"},"html":{"href":"https://github.com/DataDog/datadog-agent/pull/1427#discussion_r174377513"},"pull_request":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1427"}},"in_reply_to_id":173398349},"pull_request":{"url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1427","id":173904156,"html_url":"https://github.com/DataDog/datadog-agent/pull/1427","diff_url":"https://github.com/DataDog/datadog-agent/pull/1427.diff","patch_url":"https://github.com/DataDog/datadog-agent/pull/1427.patch","issue_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/1427","number":1427,"state":"open","locked":false,"title":"Adding Service Mapper command to the DCA","user":{"login":"CharlyF","id":7433560,"avatar_url":"https://avatars2.githubusercontent.com/u/7433560?v=4","gravatar_id":"","url":"https://api.github.com/users/CharlyF","html_url":"https://github.com/CharlyF","followers_url":"https://api.github.com/users/CharlyF/followers","following_url":"https://api.github.com/users/CharlyF/following{/other_user}","gists_url":"https://api.github.com/users/CharlyF/gists{/gist_id}","starred_url":"https://api.github.com/users/CharlyF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CharlyF/subscriptions","organizations_url":"https://api.github.com/users/CharlyF/orgs","repos_url":"https://api.github.com/users/CharlyF/repos","events_url":"https://api.github.com/users/CharlyF/events{/privacy}","received_events_url":"https://api.github.com/users/CharlyF/received_events","type":"User","site_admin":false},"body":"## What does this PR do?\r\nBreaking #1356 into smaller PRs.\r\nBuilding on top of #1401.\r\n\r\n## Motivation\r\nEase review.\r\n\r\n## Notes for Review\r\n\r\nThis is built on top of #1424 one can review the actual changes starting from:\r\n[here](https://github.com/DataDog/datadog-agent/pull/1427/commits/a8cf900ff1afafbd85ce55b86878aa9231efd944).\r\nI mostly built on top to have an image with the bundle and to make sure gitlab does not fail.\r\n\r\n## Result\r\n\r\nError handling:\r\n```\r\nubuntu@ci-charly:/go/src/github.com/DataDog/datadog-agent$ docker exec -ti dd-agent datadog-cluster-agent svcmap sd\r\n1520562053786755235 [Debug] Config read from env variables\r\n\r\n==============\r\nService Mapper\r\n=============\r\n\r\nCould not run the service mapper: The key agent/KubernetesServiceMapping/sd was not found in the cache\r\n```\r\n\r\nError handling:\r\n```\r\nubuntu@ci-charly:/go/src/github.com/DataDog/datadog-agent$ docker exec -ti dd-agent datadog-cluster-agent svcmap \"*\"\r\n1520562063765527066 [Debug] Config read from env variables\r\n\r\n==============\r\nService Mapper\r\n=============\r\n\r\nCould not run the service mapper: temporary failure in apiserver, will retry later: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined\r\n```\r\n\r\nOn a real cluster:\r\n```\r\nroot@datadog-cluster-agent-latest-sljxl:/# datadog-cluster-agent svcmap -c c.yaml \"*\"\r\n==============\r\nService Mapper\r\n=============\r\nNode name: ip-172-29-32-171\r\n -  Pod name: calico-etcd-d49km\r\n    Service list: [calico-etcd]\r\n -  Pod name: calico-kube-controllers-59fdddb87d-gl6lr\r\n    Service list: [calico-etcd]\r\n -  Pod name: calico-node-tc2dh\r\n    Service list: [calico-etcd]\r\n -  Pod name: etcd-ip-172-29-32-171\r\n    Service list: [calico-etcd]\r\n -  Pod name: kube-apiserver-ip-172-29-32-171\r\n    Service list: [calico-etcd]\r\n -  Pod name: kube-controller-manager-ip-172-29-32-171\r\n    Service list: [calico-etcd]\r\n -  Pod name: kube-proxy-rl8hm\r\n    Service list: [calico-etcd]\r\n -  Pod name: kube-scheduler-ip-172-29-32-171\r\n    Service list: [calico-etcd]\r\nNode name: ip-172-29-7-129\r\n -  Pod name: custom-metrics-apiserver-78c744b98f-578hj\r\n    Service list: [api]\r\n -  Pod name: metrics-server-8555b5f58f-b6f68\r\n    Service list: [metrics-server]\r\n -  Pod name: php-apache-6b749bb748-vx92n\r\n    Service list: [php-apache]\r\nNode name: ip-172-29-8-192\r\n -  Pod name: kube-dns-545bc4bfd4-8cc67\r\n    Service list: [kube-dns]\r\n -  Pod name: kube-state-metrics-57ddbb4745-zkr8m\r\n    Service list: [kube-state-metrics]\r\n```\r\n\r\nNote, the \"*\" usage is mainly available for the flare command.","created_at":"2018-03-09T02:32:05Z","updated_at":"2018-03-14T08:54:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"601c46430941f120edc5aa09e0dea6038b0b562e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[{"name":"Croissant","id":1224133,"slug":"croissant","description":"Agent and Integrations","privacy":"closed","url":"https://api.github.com/teams/1224133","members_url":"https://api.github.com/teams/1224133/members{/member}","repositories_url":"https://api.github.com/teams/1224133/repos","permission":"pull"},{"name":"Burrito","id":2159346,"slug":"burrito","description":"","privacy":"closed","url":"https://api.github.com/teams/2159346","members_url":"https://api.github.com/teams/2159346/members{/member}","repositories_url":"https://api.github.com/teams/2159346/repos","permission":"pull"}],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1427/commits","review_comments_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1427/comments","review_comment_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/1427/comments","statuses_url":"https://api.github.com/repos/DataDog/datadog-agent/statuses/1c98dbcee5176af0aff52eb84514343b4e5cd117","head":{"label":"DataDog:dca_svcmapper","ref":"dca_svcmapper","sha":"1c98dbcee5176af0aff52eb84514343b4e5cd117","user":{"login":"DataDog","id":365230,"avatar_url":"https://avatars1.githubusercontent.com/u/365230?v=4","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":49970739,"name":"datadog-agent","full_name":"DataDog/datadog-agent","owner":{"login":"DataDog","id":365230,"avatar_url":"https://avatars1.githubusercontent.com/u/365230?v=4","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataDog/datadog-agent","description":"Datadog Agent ","fork":false,"url":"https://api.github.com/repos/DataDog/datadog-agent","forks_url":"https://api.github.com/repos/DataDog/datadog-agent/forks","keys_url":"https://api.github.com/repos/DataDog/datadog-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/datadog-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/datadog-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/datadog-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/datadog-agent/events","assignees_url":"https://api.github.com/repos/DataDog/datadog-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/datadog-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/datadog-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/datadog-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/datadog-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/datadog-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/datadog-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/datadog-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/datadog-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/datadog-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/datadog-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/datadog-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/datadog-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/datadog-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/datadog-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/datadog-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/datadog-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/datadog-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/datadog-agent/merges","archive_url":"https://api.github.com/repos/DataDog/datadog-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/datadog-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/datadog-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/datadog-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/datadog-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/datadog-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/datadog-agent/releases{/id}","deployments_url":"https://api.github.com/repos/DataDog/datadog-agent/deployments","created_at":"2016-01-19T17:40:41Z","updated_at":"2018-03-13T23:08:43Z","pushed_at":"2018-03-14T00:50:17Z","git_url":"git://github.com/DataDog/datadog-agent.git","ssh_url":"git@github.com:DataDog/datadog-agent.git","clone_url":"https://github.com/DataDog/datadog-agent.git","svn_url":"https://github.com/DataDog/datadog-agent","homepage":"https://docs.datadoghq.com/","size":17775,"stargazers_count":96,"watchers_count":96,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"archived":false,"open_issues_count":54,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":26,"open_issues":54,"watchers":96,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"fc51df248be3f8727158f2ea3fb4e0a9b9268e3d","user":{"login":"DataDog","id":365230,"avatar_url":"https://avatars1.githubusercontent.com/u/365230?v=4","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":49970739,"name":"datadog-agent","full_name":"DataDog/datadog-agent","owner":{"login":"DataDog","id":365230,"avatar_url":"https://avatars1.githubusercontent.com/u/365230?v=4","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataDog/datadog-agent","description":"Datadog Agent ","fork":false,"url":"https://api.github.com/repos/DataDog/datadog-agent","forks_url":"https://api.github.com/repos/DataDog/datadog-agent/forks","keys_url":"https://api.github.com/repos/DataDog/datadog-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/datadog-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/datadog-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/datadog-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/datadog-agent/events","assignees_url":"https://api.github.com/repos/DataDog/datadog-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/datadog-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/datadog-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/datadog-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/datadog-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/datadog-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/datadog-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/datadog-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/datadog-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/datadog-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/datadog-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/datadog-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/datadog-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/datadog-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/datadog-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/datadog-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/datadog-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/datadog-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/datadog-agent/merges","archive_url":"https://api.github.com/repos/DataDog/datadog-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/datadog-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/datadog-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/datadog-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/datadog-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/datadog-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/datadog-agent/releases{/id}","deployments_url":"https://api.github.com/repos/DataDog/datadog-agent/deployments","created_at":"2016-01-19T17:40:41Z","updated_at":"2018-03-13T23:08:43Z","pushed_at":"2018-03-14T00:50:17Z","git_url":"git://github.com/DataDog/datadog-agent.git","ssh_url":"git@github.com:DataDog/datadog-agent.git","clone_url":"https://github.com/DataDog/datadog-agent.git","svn_url":"https://github.com/DataDog/datadog-agent","homepage":"https://docs.datadoghq.com/","size":17775,"stargazers_count":96,"watchers_count":96,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"archived":false,"open_issues_count":54,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":26,"open_issues":54,"watchers":96,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1427"},"html":{"href":"https://github.com/DataDog/datadog-agent/pull/1427"},"issue":{"href":"https://api.github.com/repos/DataDog/datadog-agent/issues/1427"},"comments":{"href":"https://api.github.com/repos/DataDog/datadog-agent/issues/1427/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1427/comments"},"review_comment":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1427/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/datadog-agent/statuses/1c98dbcee5176af0aff52eb84514343b4e5cd117"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"JulienBalestra"}}