{"action":"created","comment":{"url":"https://api.github.com/repos/romana/core/pulls/comments/60491532","id":60491532,"diff_hunk":"@@ -0,0 +1,76 @@\n+// Copyright (c) 2016 Pani Networks\n+// All Rights Reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+// not use this file except in compliance with the License. You may obtain\n+// a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+// License for the specific language governing permissions and limitations\n+// under the License.\n+\n+package kubernetes\n+\n+import (\n+\t\"log\"\n+)\n+\n+// manageResources manages map of termination channels and fires up new\n+// per-namespace gorotines when needed.\n+func (l *kubeListener) manageResources(ns Event, terminators map[string]chan Done, out chan Event) {\n+\tuid := ns.Object.Metadata.Uid\n+\tif ns.Type == KubeEventAdded {\n+\t\tif _, ok := terminators[uid]; ok {\n+\t\t\tlog.Println(\"Received ADDED event for uid that is already known, ignoring \", uid)\n+\t\t\treturn\n+\t\t}\n+\n+\t\tdone := make(chan Done)\n+\t\tterminators[uid] = done\n+\t\tns.Object.produce(out, terminators[uid], l)\n+\t} else if ns.Type == KubeEventDeleted {\n+\t\tif _, ok := terminators[uid]; !ok {\n+\t\t\tlog.Println(\"Received DELETED event for uid that is not known, ignoring \", uid)\n+\t\t\treturn\n+\t\t}\n+\t\t\n+\t\tclose(terminators[uid])\n+\t\tdelete(terminators, uid)\n+\t} else if ns.Type == InternalEventDeleteAll {\n+\t\tfor uid, c := range terminators {\n+\t\t\tclose(c)\n+\t\t\tdelete(terminators, uid)\n+\t\t}\n+\t}\n+}\n+\n+// Conductor manages a set of goroutines one per namespace.\n+func (l *kubeListener) conductor(in <-chan Event, done <-chan Done) <-chan Event {\n+\t// done in arguments is a channel that can be used to stop Conductor itsefl","path":"romana/kubernetes/conductor.go","position":53,"original_position":53,"commit_id":"86f7b465badc9b53beb0936898a6741920382b96","original_commit_id":"86f7b465badc9b53beb0936898a6741920382b96","user":{"login":"jbrendel","id":233741,"avatar_url":"https://avatars.githubusercontent.com/u/233741?v=3","gravatar_id":"","url":"https://api.github.com/users/jbrendel","html_url":"https://github.com/jbrendel","followers_url":"https://api.github.com/users/jbrendel/followers","following_url":"https://api.github.com/users/jbrendel/following{/other_user}","gists_url":"https://api.github.com/users/jbrendel/gists{/gist_id}","starred_url":"https://api.github.com/users/jbrendel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbrendel/subscriptions","organizations_url":"https://api.github.com/users/jbrendel/orgs","repos_url":"https://api.github.com/users/jbrendel/repos","events_url":"https://api.github.com/users/jbrendel/events{/privacy}","received_events_url":"https://api.github.com/users/jbrendel/received_events","type":"User","site_admin":false},"body":"\"itself\"","created_at":"2016-04-20T21:31:14Z","updated_at":"2016-04-20T21:31:14Z","html_url":"https://github.com/romana/core/pull/71#discussion_r60491532","pull_request_url":"https://api.github.com/repos/romana/core/pulls/71","_links":{"self":{"href":"https://api.github.com/repos/romana/core/pulls/comments/60491532"},"html":{"href":"https://github.com/romana/core/pull/71#discussion_r60491532"},"pull_request":{"href":"https://api.github.com/repos/romana/core/pulls/71"}}},"pull_request":{"url":"https://api.github.com/repos/romana/core/pulls/71","id":67102355,"html_url":"https://github.com/romana/core/pull/71","diff_url":"https://github.com/romana/core/pull/71.diff","patch_url":"https://github.com/romana/core/pull/71.patch","issue_url":"https://api.github.com/repos/romana/core/issues/71","number":71,"state":"open","locked":false,"title":"Kubernetes listener and attendant changes","user":{"login":"debedb","id":619943,"avatar_url":"https://avatars.githubusercontent.com/u/619943?v=3","gravatar_id":"","url":"https://api.github.com/users/debedb","html_url":"https://github.com/debedb","followers_url":"https://api.github.com/users/debedb/followers","following_url":"https://api.github.com/users/debedb/following{/other_user}","gists_url":"https://api.github.com/users/debedb/gists{/gist_id}","starred_url":"https://api.github.com/users/debedb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/debedb/subscriptions","organizations_url":"https://api.github.com/users/debedb/orgs","repos_url":"https://api.github.com/users/debedb/repos","events_url":"https://api.github.com/users/debedb/events{/privacy}","received_events_url":"https://api.github.com/users/debedb/received_events","type":"User","site_admin":false},"body":"1. Copied relevant code to listen to kubernetes for namespace and policy updates from https://github.com/romana/contrib/tree/dev/rsearch/rsearch and added code to translate policy requests to Romana (https://paninetworks.kanbanize.com/ctrl_board/3/cards/306/details). The listener is yet another Romana service.\r\n2. Implemented structure for policy (https://paninetworks.kanbanize.com/ctrl_board/3/cards/240/details)\r\n3. Skeleton for policy server so that the listener has something to POST updates to\r\n4. Added ExternalID capability to Segments and fixed tests. (This raises a question - should we improve it to first check our internal IDs? Meaning, if there is a tenant with internal ID 4 and another with external ID 4, we will find both, but in this case should we be finding only the first one?)\r\n5. Improved RestClient to provide common functionality.","created_at":"2016-04-19T22:43:24Z","updated_at":"2016-04-20T21:31:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a30cbe6a367042e085de2be5a016457c90650288","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/romana/core/pulls/71/commits","review_comments_url":"https://api.github.com/repos/romana/core/pulls/71/comments","review_comment_url":"https://api.github.com/repos/romana/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/romana/core/issues/71/comments","statuses_url":"https://api.github.com/repos/romana/core/statuses/86f7b465badc9b53beb0936898a6741920382b96","head":{"label":"romana:feature/gg/k8s-listener","ref":"feature/gg/k8s-listener","sha":"86f7b465badc9b53beb0936898a6741920382b96","user":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"repo":{"id":43855674,"name":"core","full_name":"romana/core","owner":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/romana/core","description":"Romana core components - Micro services written in Go.","fork":false,"url":"https://api.github.com/repos/romana/core","forks_url":"https://api.github.com/repos/romana/core/forks","keys_url":"https://api.github.com/repos/romana/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romana/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romana/core/teams","hooks_url":"https://api.github.com/repos/romana/core/hooks","issue_events_url":"https://api.github.com/repos/romana/core/issues/events{/number}","events_url":"https://api.github.com/repos/romana/core/events","assignees_url":"https://api.github.com/repos/romana/core/assignees{/user}","branches_url":"https://api.github.com/repos/romana/core/branches{/branch}","tags_url":"https://api.github.com/repos/romana/core/tags","blobs_url":"https://api.github.com/repos/romana/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romana/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romana/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/romana/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romana/core/statuses/{sha}","languages_url":"https://api.github.com/repos/romana/core/languages","stargazers_url":"https://api.github.com/repos/romana/core/stargazers","contributors_url":"https://api.github.com/repos/romana/core/contributors","subscribers_url":"https://api.github.com/repos/romana/core/subscribers","subscription_url":"https://api.github.com/repos/romana/core/subscription","commits_url":"https://api.github.com/repos/romana/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/romana/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/romana/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/romana/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/romana/core/contents/{+path}","compare_url":"https://api.github.com/repos/romana/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romana/core/merges","archive_url":"https://api.github.com/repos/romana/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romana/core/downloads","issues_url":"https://api.github.com/repos/romana/core/issues{/number}","pulls_url":"https://api.github.com/repos/romana/core/pulls{/number}","milestones_url":"https://api.github.com/repos/romana/core/milestones{/number}","notifications_url":"https://api.github.com/repos/romana/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romana/core/labels{/name}","releases_url":"https://api.github.com/repos/romana/core/releases{/id}","deployments_url":"https://api.github.com/repos/romana/core/deployments","created_at":"2015-10-08T01:45:35Z","updated_at":"2016-04-13T22:10:15Z","pushed_at":"2016-04-19T22:46:48Z","git_url":"git://github.com/romana/core.git","ssh_url":"git@github.com:romana/core.git","clone_url":"https://github.com/romana/core.git","svn_url":"https://github.com/romana/core","homepage":"","size":559,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":10,"default_branch":"master"}},"base":{"label":"romana:master","ref":"master","sha":"3ffd3cd97d8c28f6987b0d79e0b42f3547bba00c","user":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"repo":{"id":43855674,"name":"core","full_name":"romana/core","owner":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/romana/core","description":"Romana core components - Micro services written in Go.","fork":false,"url":"https://api.github.com/repos/romana/core","forks_url":"https://api.github.com/repos/romana/core/forks","keys_url":"https://api.github.com/repos/romana/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romana/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romana/core/teams","hooks_url":"https://api.github.com/repos/romana/core/hooks","issue_events_url":"https://api.github.com/repos/romana/core/issues/events{/number}","events_url":"https://api.github.com/repos/romana/core/events","assignees_url":"https://api.github.com/repos/romana/core/assignees{/user}","branches_url":"https://api.github.com/repos/romana/core/branches{/branch}","tags_url":"https://api.github.com/repos/romana/core/tags","blobs_url":"https://api.github.com/repos/romana/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romana/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romana/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/romana/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romana/core/statuses/{sha}","languages_url":"https://api.github.com/repos/romana/core/languages","stargazers_url":"https://api.github.com/repos/romana/core/stargazers","contributors_url":"https://api.github.com/repos/romana/core/contributors","subscribers_url":"https://api.github.com/repos/romana/core/subscribers","subscription_url":"https://api.github.com/repos/romana/core/subscription","commits_url":"https://api.github.com/repos/romana/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/romana/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/romana/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/romana/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/romana/core/contents/{+path}","compare_url":"https://api.github.com/repos/romana/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romana/core/merges","archive_url":"https://api.github.com/repos/romana/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romana/core/downloads","issues_url":"https://api.github.com/repos/romana/core/issues{/number}","pulls_url":"https://api.github.com/repos/romana/core/pulls{/number}","milestones_url":"https://api.github.com/repos/romana/core/milestones{/number}","notifications_url":"https://api.github.com/repos/romana/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romana/core/labels{/name}","releases_url":"https://api.github.com/repos/romana/core/releases{/id}","deployments_url":"https://api.github.com/repos/romana/core/deployments","created_at":"2015-10-08T01:45:35Z","updated_at":"2016-04-13T22:10:15Z","pushed_at":"2016-04-19T22:46:48Z","git_url":"git://github.com/romana/core.git","ssh_url":"git@github.com:romana/core.git","clone_url":"https://github.com/romana/core.git","svn_url":"https://github.com/romana/core","homepage":"","size":559,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/romana/core/pulls/71"},"html":{"href":"https://github.com/romana/core/pull/71"},"issue":{"href":"https://api.github.com/repos/romana/core/issues/71"},"comments":{"href":"https://api.github.com/repos/romana/core/issues/71/comments"},"review_comments":{"href":"https://api.github.com/repos/romana/core/pulls/71/comments"},"review_comment":{"href":"https://api.github.com/repos/romana/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/romana/core/pulls/71/commits"},"statuses":{"href":"https://api.github.com/repos/romana/core/statuses/86f7b465badc9b53beb0936898a6741920382b96"}}}}