{"action":"created","comment":{"url":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/comments/177743712","pull_request_review_id":107670111,"id":177743712,"diff_hunk":"@@ -1042,27 +1043,47 @@ json::value KubernetesReader::FindTopLevelOwner(\n #endif\n   const json::Object* metadata = obj->Get<json::Object>(\"metadata\");\n #ifdef VERBOSE\n-  LOG(DEBUG) << \"FindTopLevelOwner: metadata is \" << *metadata;\n+  LOG(DEBUG) << \"FindTopLevelController: metadata is \" << *metadata;\n #endif\n   if (!metadata->Has(\"ownerReferences\")) {\n #ifdef VERBOSE\n-    LOG(DEBUG) << \"FindTopLevelOwner: no owner references in \" << *metadata;\n+    LOG(DEBUG) << \"FindTopLevelController: no owner references in \"\n+               << *metadata;\n #endif\n     return object;\n   }\n   const json::Array* refs = metadata->Get<json::Array>(\"ownerReferences\");\n #ifdef VERBOSE\n-  LOG(DEBUG) << \"FindTopLevelOwner: refs is \" << *refs;\n+  LOG(DEBUG) << \"FindTopLevelController: refs is \" << *refs;\n #endif\n-  if (refs->size() > 1) {\n-    LOG(WARNING) << \"Found multiple owner references for \" << *obj\n+  std::vector<const json::Object*> controller_refs;\n+  for (const json::value& ref : *refs) {\n+    const json::Object* ref_obj = ref->As<json::Object>();\n+    if (ref_obj->Has(\"controller\") &&\n+        ref_obj->Get<json::Boolean>(\"controller\")) {\n+      controller_refs.emplace_back(ref_obj);\n+    }\n+  }\n+#ifdef VERBOSE\n+  LOG(DEBUG) << \"FindTopLevelController: contoller_refs is \"\n+             << controller_refs;\n+#endif\n+  if (controller_refs.size() == 0) {\n+#ifdef VERBOSE\n+    LOG(DEBUG) << \"FindTopLevelController: no controller owner references in \"\n+               << *metadata;\n+#endif\n+    return object;\n+  }\n+  if (controller_refs.size() > 1) {","path":"src/kubernetes.cc","position":60,"original_position":60,"commit_id":"00bd7c276f8a59ed7b4f4dd2ec69b91d1bdf6889","original_commit_id":"00bd7c276f8a59ed7b4f4dd2ec69b91d1bdf6889","user":{"login":"supriyagarg","id":11726936,"avatar_url":"https://avatars2.githubusercontent.com/u/11726936?v=4","gravatar_id":"","url":"https://api.github.com/users/supriyagarg","html_url":"https://github.com/supriyagarg","followers_url":"https://api.github.com/users/supriyagarg/followers","following_url":"https://api.github.com/users/supriyagarg/following{/other_user}","gists_url":"https://api.github.com/users/supriyagarg/gists{/gist_id}","starred_url":"https://api.github.com/users/supriyagarg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supriyagarg/subscriptions","organizations_url":"https://api.github.com/users/supriyagarg/orgs","repos_url":"https://api.github.com/users/supriyagarg/repos","events_url":"https://api.github.com/users/supriyagarg/events{/privacy}","received_events_url":"https://api.github.com/users/supriyagarg/received_events","type":"User","site_admin":false},"body":"Correct - this was more for defensive programming, just in case.\r\n\r\nIf we want to ignore any controller after the first one, I can simplify the for loop above to store just the first controller, and break after it finds one. WDYT?","created_at":"2018-03-28T13:12:09Z","updated_at":"2018-03-28T13:12:30Z","html_url":"https://github.com/Stackdriver/metadata-agent/pull/95#discussion_r177743712","pull_request_url":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/95","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/comments/177743712"},"html":{"href":"https://github.com/Stackdriver/metadata-agent/pull/95#discussion_r177743712"},"pull_request":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/95"}},"in_reply_to_id":177665023},"pull_request":{"url":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/95","id":177908636,"html_url":"https://github.com/Stackdriver/metadata-agent/pull/95","diff_url":"https://github.com/Stackdriver/metadata-agent/pull/95.diff","patch_url":"https://github.com/Stackdriver/metadata-agent/pull/95.patch","issue_url":"https://api.github.com/repos/Stackdriver/metadata-agent/issues/95","number":95,"state":"open","locked":false,"title":"Update the FindTopLevelOwner function to extract only controllers.","user":{"login":"supriyagarg","id":11726936,"avatar_url":"https://avatars2.githubusercontent.com/u/11726936?v=4","gravatar_id":"","url":"https://api.github.com/users/supriyagarg","html_url":"https://github.com/supriyagarg","followers_url":"https://api.github.com/users/supriyagarg/followers","following_url":"https://api.github.com/users/supriyagarg/following{/other_user}","gists_url":"https://api.github.com/users/supriyagarg/gists{/gist_id}","starred_url":"https://api.github.com/users/supriyagarg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supriyagarg/subscriptions","organizations_url":"https://api.github.com/users/supriyagarg/orgs","repos_url":"https://api.github.com/users/supriyagarg/repos","events_url":"https://api.github.com/users/supriyagarg/events{/privacy}","received_events_url":"https://api.github.com/users/supriyagarg/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-28T01:40:34Z","updated_at":"2018-03-28T13:12:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"722c014b04e8197263dbfe4b48607a51317990f1","assignee":{"login":"supriyagarg","id":11726936,"avatar_url":"https://avatars2.githubusercontent.com/u/11726936?v=4","gravatar_id":"","url":"https://api.github.com/users/supriyagarg","html_url":"https://github.com/supriyagarg","followers_url":"https://api.github.com/users/supriyagarg/followers","following_url":"https://api.github.com/users/supriyagarg/following{/other_user}","gists_url":"https://api.github.com/users/supriyagarg/gists{/gist_id}","starred_url":"https://api.github.com/users/supriyagarg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supriyagarg/subscriptions","organizations_url":"https://api.github.com/users/supriyagarg/orgs","repos_url":"https://api.github.com/users/supriyagarg/repos","events_url":"https://api.github.com/users/supriyagarg/events{/privacy}","received_events_url":"https://api.github.com/users/supriyagarg/received_events","type":"User","site_admin":false},"assignees":[{"login":"supriyagarg","id":11726936,"avatar_url":"https://avatars2.githubusercontent.com/u/11726936?v=4","gravatar_id":"","url":"https://api.github.com/users/supriyagarg","html_url":"https://github.com/supriyagarg","followers_url":"https://api.github.com/users/supriyagarg/followers","following_url":"https://api.github.com/users/supriyagarg/following{/other_user}","gists_url":"https://api.github.com/users/supriyagarg/gists{/gist_id}","starred_url":"https://api.github.com/users/supriyagarg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supriyagarg/subscriptions","organizations_url":"https://api.github.com/users/supriyagarg/orgs","repos_url":"https://api.github.com/users/supriyagarg/repos","events_url":"https://api.github.com/users/supriyagarg/events{/privacy}","received_events_url":"https://api.github.com/users/supriyagarg/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/95/commits","review_comments_url":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/95/comments","review_comment_url":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Stackdriver/metadata-agent/issues/95/comments","statuses_url":"https://api.github.com/repos/Stackdriver/metadata-agent/statuses/00bd7c276f8a59ed7b4f4dd2ec69b91d1bdf6889","head":{"label":"supriyagarg:controller_fix","ref":"controller_fix","sha":"00bd7c276f8a59ed7b4f4dd2ec69b91d1bdf6889","user":{"login":"supriyagarg","id":11726936,"avatar_url":"https://avatars2.githubusercontent.com/u/11726936?v=4","gravatar_id":"","url":"https://api.github.com/users/supriyagarg","html_url":"https://github.com/supriyagarg","followers_url":"https://api.github.com/users/supriyagarg/followers","following_url":"https://api.github.com/users/supriyagarg/following{/other_user}","gists_url":"https://api.github.com/users/supriyagarg/gists{/gist_id}","starred_url":"https://api.github.com/users/supriyagarg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supriyagarg/subscriptions","organizations_url":"https://api.github.com/users/supriyagarg/orgs","repos_url":"https://api.github.com/users/supriyagarg/repos","events_url":"https://api.github.com/users/supriyagarg/events{/privacy}","received_events_url":"https://api.github.com/users/supriyagarg/received_events","type":"User","site_admin":false},"repo":{"id":118942349,"name":"metadata-agent","full_name":"supriyagarg/metadata-agent","owner":{"login":"supriyagarg","id":11726936,"avatar_url":"https://avatars2.githubusercontent.com/u/11726936?v=4","gravatar_id":"","url":"https://api.github.com/users/supriyagarg","html_url":"https://github.com/supriyagarg","followers_url":"https://api.github.com/users/supriyagarg/followers","following_url":"https://api.github.com/users/supriyagarg/following{/other_user}","gists_url":"https://api.github.com/users/supriyagarg/gists{/gist_id}","starred_url":"https://api.github.com/users/supriyagarg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supriyagarg/subscriptions","organizations_url":"https://api.github.com/users/supriyagarg/orgs","repos_url":"https://api.github.com/users/supriyagarg/repos","events_url":"https://api.github.com/users/supriyagarg/events{/privacy}","received_events_url":"https://api.github.com/users/supriyagarg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/supriyagarg/metadata-agent","description":"Stackdriver metadata agent","fork":true,"url":"https://api.github.com/repos/supriyagarg/metadata-agent","forks_url":"https://api.github.com/repos/supriyagarg/metadata-agent/forks","keys_url":"https://api.github.com/repos/supriyagarg/metadata-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/supriyagarg/metadata-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/supriyagarg/metadata-agent/teams","hooks_url":"https://api.github.com/repos/supriyagarg/metadata-agent/hooks","issue_events_url":"https://api.github.com/repos/supriyagarg/metadata-agent/issues/events{/number}","events_url":"https://api.github.com/repos/supriyagarg/metadata-agent/events","assignees_url":"https://api.github.com/repos/supriyagarg/metadata-agent/assignees{/user}","branches_url":"https://api.github.com/repos/supriyagarg/metadata-agent/branches{/branch}","tags_url":"https://api.github.com/repos/supriyagarg/metadata-agent/tags","blobs_url":"https://api.github.com/repos/supriyagarg/metadata-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/supriyagarg/metadata-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/supriyagarg/metadata-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/supriyagarg/metadata-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/supriyagarg/metadata-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/supriyagarg/metadata-agent/languages","stargazers_url":"https://api.github.com/repos/supriyagarg/metadata-agent/stargazers","contributors_url":"https://api.github.com/repos/supriyagarg/metadata-agent/contributors","subscribers_url":"https://api.github.com/repos/supriyagarg/metadata-agent/subscribers","subscription_url":"https://api.github.com/repos/supriyagarg/metadata-agent/subscription","commits_url":"https://api.github.com/repos/supriyagarg/metadata-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/supriyagarg/metadata-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/supriyagarg/metadata-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/supriyagarg/metadata-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/supriyagarg/metadata-agent/contents/{+path}","compare_url":"https://api.github.com/repos/supriyagarg/metadata-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/supriyagarg/metadata-agent/merges","archive_url":"https://api.github.com/repos/supriyagarg/metadata-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/supriyagarg/metadata-agent/downloads","issues_url":"https://api.github.com/repos/supriyagarg/metadata-agent/issues{/number}","pulls_url":"https://api.github.com/repos/supriyagarg/metadata-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/supriyagarg/metadata-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/supriyagarg/metadata-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/supriyagarg/metadata-agent/labels{/name}","releases_url":"https://api.github.com/repos/supriyagarg/metadata-agent/releases{/id}","deployments_url":"https://api.github.com/repos/supriyagarg/metadata-agent/deployments","created_at":"2018-01-25T17:03:49Z","updated_at":"2018-03-28T01:24:04Z","pushed_at":"2018-03-28T03:39:50Z","git_url":"git://github.com/supriyagarg/metadata-agent.git","ssh_url":"git@github.com:supriyagarg/metadata-agent.git","clone_url":"https://github.com/supriyagarg/metadata-agent.git","svn_url":"https://github.com/supriyagarg/metadata-agent","homepage":"","size":343,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Stackdriver:master","ref":"master","sha":"e872d00eca53bad39294d18214bbcce58319c1ae","user":{"login":"Stackdriver","id":2104369,"avatar_url":"https://avatars3.githubusercontent.com/u/2104369?v=4","gravatar_id":"","url":"https://api.github.com/users/Stackdriver","html_url":"https://github.com/Stackdriver","followers_url":"https://api.github.com/users/Stackdriver/followers","following_url":"https://api.github.com/users/Stackdriver/following{/other_user}","gists_url":"https://api.github.com/users/Stackdriver/gists{/gist_id}","starred_url":"https://api.github.com/users/Stackdriver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stackdriver/subscriptions","organizations_url":"https://api.github.com/users/Stackdriver/orgs","repos_url":"https://api.github.com/users/Stackdriver/repos","events_url":"https://api.github.com/users/Stackdriver/events{/privacy}","received_events_url":"https://api.github.com/users/Stackdriver/received_events","type":"Organization","site_admin":false},"repo":{"id":81396310,"name":"metadata-agent","full_name":"Stackdriver/metadata-agent","owner":{"login":"Stackdriver","id":2104369,"avatar_url":"https://avatars3.githubusercontent.com/u/2104369?v=4","gravatar_id":"","url":"https://api.github.com/users/Stackdriver","html_url":"https://github.com/Stackdriver","followers_url":"https://api.github.com/users/Stackdriver/followers","following_url":"https://api.github.com/users/Stackdriver/following{/other_user}","gists_url":"https://api.github.com/users/Stackdriver/gists{/gist_id}","starred_url":"https://api.github.com/users/Stackdriver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stackdriver/subscriptions","organizations_url":"https://api.github.com/users/Stackdriver/orgs","repos_url":"https://api.github.com/users/Stackdriver/repos","events_url":"https://api.github.com/users/Stackdriver/events{/privacy}","received_events_url":"https://api.github.com/users/Stackdriver/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Stackdriver/metadata-agent","description":"Stackdriver metadata agent","fork":false,"url":"https://api.github.com/repos/Stackdriver/metadata-agent","forks_url":"https://api.github.com/repos/Stackdriver/metadata-agent/forks","keys_url":"https://api.github.com/repos/Stackdriver/metadata-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Stackdriver/metadata-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Stackdriver/metadata-agent/teams","hooks_url":"https://api.github.com/repos/Stackdriver/metadata-agent/hooks","issue_events_url":"https://api.github.com/repos/Stackdriver/metadata-agent/issues/events{/number}","events_url":"https://api.github.com/repos/Stackdriver/metadata-agent/events","assignees_url":"https://api.github.com/repos/Stackdriver/metadata-agent/assignees{/user}","branches_url":"https://api.github.com/repos/Stackdriver/metadata-agent/branches{/branch}","tags_url":"https://api.github.com/repos/Stackdriver/metadata-agent/tags","blobs_url":"https://api.github.com/repos/Stackdriver/metadata-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Stackdriver/metadata-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Stackdriver/metadata-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/Stackdriver/metadata-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Stackdriver/metadata-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/Stackdriver/metadata-agent/languages","stargazers_url":"https://api.github.com/repos/Stackdriver/metadata-agent/stargazers","contributors_url":"https://api.github.com/repos/Stackdriver/metadata-agent/contributors","subscribers_url":"https://api.github.com/repos/Stackdriver/metadata-agent/subscribers","subscription_url":"https://api.github.com/repos/Stackdriver/metadata-agent/subscription","commits_url":"https://api.github.com/repos/Stackdriver/metadata-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/Stackdriver/metadata-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/Stackdriver/metadata-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/Stackdriver/metadata-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/Stackdriver/metadata-agent/contents/{+path}","compare_url":"https://api.github.com/repos/Stackdriver/metadata-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Stackdriver/metadata-agent/merges","archive_url":"https://api.github.com/repos/Stackdriver/metadata-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Stackdriver/metadata-agent/downloads","issues_url":"https://api.github.com/repos/Stackdriver/metadata-agent/issues{/number}","pulls_url":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/Stackdriver/metadata-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/Stackdriver/metadata-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Stackdriver/metadata-agent/labels{/name}","releases_url":"https://api.github.com/repos/Stackdriver/metadata-agent/releases{/id}","deployments_url":"https://api.github.com/repos/Stackdriver/metadata-agent/deployments","created_at":"2017-02-09T01:48:50Z","updated_at":"2018-03-28T12:30:57Z","pushed_at":"2018-03-28T12:57:41Z","git_url":"git://github.com/Stackdriver/metadata-agent.git","ssh_url":"git@github.com:Stackdriver/metadata-agent.git","clone_url":"https://github.com/Stackdriver/metadata-agent.git","svn_url":"https://github.com/Stackdriver/metadata-agent","homepage":"","size":337,"stargazers_count":4,"watchers_count":4,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":9,"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":2,"open_issues":9,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/95"},"html":{"href":"https://github.com/Stackdriver/metadata-agent/pull/95"},"issue":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/issues/95"},"comments":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/issues/95/comments"},"review_comments":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/95/comments"},"review_comment":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/pulls/95/commits"},"statuses":{"href":"https://api.github.com/repos/Stackdriver/metadata-agent/statuses/00bd7c276f8a59ed7b4f4dd2ec69b91d1bdf6889"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"supriyagarg"}}