{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/51662195","id":51662195,"diff_hunk":"@@ -33,79 +43,217 @@ type RouteController struct {\n \tkubeClient  client.Interface\n \tclusterName string\n \tclusterCIDR *net.IPNet\n+\n+\t// To allow injection of syncRoutine for testing.\n+\tsyncHandler func(key string) error\n+\n+\t// Node framework and store\n+\tnodeController *framework.Controller\n+\tnodeStore      cache.StoreToNodeLister\n+\n+\t// routes that need to be created\n+\tqueue *workqueue.Type\n }\n \n-func New(routes cloudprovider.Routes, kubeClient client.Interface, clusterName string, clusterCIDR *net.IPNet) *RouteController {\n-\treturn &RouteController{\n+func NewRouteController(routes cloudprovider.Routes, client client.Interface, resyncPeriod controller.ResyncPeriodFunc, clusterName string, clusterCIDR *net.IPNet) *RouteController {\n+\trc := &RouteController{\n \t\troutes:      routes,\n-\t\tkubeClient:  kubeClient,\n+\t\tkubeClient:  client,\n \t\tclusterName: clusterName,\n \t\tclusterCIDR: clusterCIDR,\n+\t\tqueue:       workqueue.New(),\n \t}\n+\n+\trc.nodeStore.Store, rc.nodeController = framework.NewInformer(\n+\t\t&cache.ListWatch{\n+\t\t\tListFunc: func(options api.ListOptions) (runtime.Object, error) {\n+\t\t\t\treturn rc.kubeClient.Nodes().List(options)\n+\t\t\t},\n+\t\t\tWatchFunc: func(options api.ListOptions) (watch.Interface, error) {\n+\t\t\t\treturn rc.kubeClient.Nodes().Watch(options)\n+\t\t\t},\n+\t\t},\n+\t\t&api.Node{},\n+\t\tresyncPeriod(),\n+\t\tframework.ResourceEventHandlerFuncs{\n+\t\t\tAddFunc: rc.enqueueNode,\n+\t\t\tUpdateFunc: func(old, cur interface{}) {\n+\t\t\t\toldNode := old.(*api.Node)\n+\t\t\t\tcurNode := cur.(*api.Node)\n+\t\t\t\t// if PodCIDR of node changed, we need recreate the route\n+\t\t\t\tif oldNode.Spec.PodCIDR != curNode.Spec.PodCIDR {\n+\t\t\t\t\tglog.V(4).Infof(\"Observed PodCIDR updated for node: %v, %v->%v\", curNode.Name, oldNode.Spec.PodCIDR, curNode.Spec.PodCIDR)\n+\t\t\t\t\trc.enqueueNode(cur)\n+\t\t\t\t}\n+\t\t\t},\n+\t\t\tDeleteFunc: rc.enqueueNode,","path":"pkg/controller/route/routecontroller.go","position":70,"original_position":70,"commit_id":"db365c8a3d17682a87f7785062441da90e96f1cd","original_commit_id":"db365c8a3d17682a87f7785062441da90e96f1cd","user":{"login":"cjcullen","id":7154008,"avatar_url":"https://avatars.githubusercontent.com/u/7154008?v=3","gravatar_id":"","url":"https://api.github.com/users/cjcullen","html_url":"https://github.com/cjcullen","followers_url":"https://api.github.com/users/cjcullen/followers","following_url":"https://api.github.com/users/cjcullen/following{/other_user}","gists_url":"https://api.github.com/users/cjcullen/gists{/gist_id}","starred_url":"https://api.github.com/users/cjcullen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjcullen/subscriptions","organizations_url":"https://api.github.com/users/cjcullen/orgs","repos_url":"https://api.github.com/users/cjcullen/repos","events_url":"https://api.github.com/users/cjcullen/events{/privacy}","received_events_url":"https://api.github.com/users/cjcullen/received_events","type":"User","site_admin":false},"body":"Having Add, Update, and Delete all use the same function makes the function necessarily more complicated. Do we need to do it this way? Is there a way to organize it so that we have three easy to understand helper functions?","created_at":"2016-02-03T00:40:21Z","updated_at":"2016-02-03T00:40:21Z","html_url":"https://github.com/kubernetes/kubernetes/pull/19117#discussion_r51662195","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/19117","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/51662195"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/19117#discussion_r51662195"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/19117"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/19117","id":54616654,"html_url":"https://github.com/kubernetes/kubernetes/pull/19117","diff_url":"https://github.com/kubernetes/kubernetes/pull/19117.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/19117.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/19117","number":19117,"state":"open","locked":false,"title":"add informer to route controller","user":{"login":"mqliang","id":12423751,"avatar_url":"https://avatars.githubusercontent.com/u/12423751?v=3","gravatar_id":"","url":"https://api.github.com/users/mqliang","html_url":"https://github.com/mqliang","followers_url":"https://api.github.com/users/mqliang/followers","following_url":"https://api.github.com/users/mqliang/following{/other_user}","gists_url":"https://api.github.com/users/mqliang/gists{/gist_id}","starred_url":"https://api.github.com/users/mqliang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqliang/subscriptions","organizations_url":"https://api.github.com/users/mqliang/orgs","repos_url":"https://api.github.com/users/mqliang/repos","events_url":"https://api.github.com/users/mqliang/events{/privacy}","received_events_url":"https://api.github.com/users/mqliang/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-27T12:19:49Z","updated_at":"2016-02-03T00:40:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f284b0744cc5522be072413e3637e61195393ee8","assignee":{"login":"cjcullen","id":7154008,"avatar_url":"https://avatars.githubusercontent.com/u/7154008?v=3","gravatar_id":"","url":"https://api.github.com/users/cjcullen","html_url":"https://github.com/cjcullen","followers_url":"https://api.github.com/users/cjcullen/followers","following_url":"https://api.github.com/users/cjcullen/following{/other_user}","gists_url":"https://api.github.com/users/cjcullen/gists{/gist_id}","starred_url":"https://api.github.com/users/cjcullen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjcullen/subscriptions","organizations_url":"https://api.github.com/users/cjcullen/orgs","repos_url":"https://api.github.com/users/cjcullen/repos","events_url":"https://api.github.com/users/cjcullen/events{/privacy}","received_events_url":"https://api.github.com/users/cjcullen/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/19117/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/19117/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/19117/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/db365c8a3d17682a87f7785062441da90e96f1cd","head":{"label":"mqliang:routineInformer","ref":"routineInformer","sha":"db365c8a3d17682a87f7785062441da90e96f1cd","user":{"login":"mqliang","id":12423751,"avatar_url":"https://avatars.githubusercontent.com/u/12423751?v=3","gravatar_id":"","url":"https://api.github.com/users/mqliang","html_url":"https://github.com/mqliang","followers_url":"https://api.github.com/users/mqliang/followers","following_url":"https://api.github.com/users/mqliang/following{/other_user}","gists_url":"https://api.github.com/users/mqliang/gists{/gist_id}","starred_url":"https://api.github.com/users/mqliang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqliang/subscriptions","organizations_url":"https://api.github.com/users/mqliang/orgs","repos_url":"https://api.github.com/users/mqliang/repos","events_url":"https://api.github.com/users/mqliang/events{/privacy}","received_events_url":"https://api.github.com/users/mqliang/received_events","type":"User","site_admin":false},"repo":{"id":42916417,"name":"kubernetes","full_name":"mqliang/kubernetes","owner":{"login":"mqliang","id":12423751,"avatar_url":"https://avatars.githubusercontent.com/u/12423751?v=3","gravatar_id":"","url":"https://api.github.com/users/mqliang","html_url":"https://github.com/mqliang","followers_url":"https://api.github.com/users/mqliang/followers","following_url":"https://api.github.com/users/mqliang/following{/other_user}","gists_url":"https://api.github.com/users/mqliang/gists{/gist_id}","starred_url":"https://api.github.com/users/mqliang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqliang/subscriptions","organizations_url":"https://api.github.com/users/mqliang/orgs","repos_url":"https://api.github.com/users/mqliang/repos","events_url":"https://api.github.com/users/mqliang/events{/privacy}","received_events_url":"https://api.github.com/users/mqliang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mqliang/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/mqliang/kubernetes","forks_url":"https://api.github.com/repos/mqliang/kubernetes/forks","keys_url":"https://api.github.com/repos/mqliang/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mqliang/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mqliang/kubernetes/teams","hooks_url":"https://api.github.com/repos/mqliang/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/mqliang/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/mqliang/kubernetes/events","assignees_url":"https://api.github.com/repos/mqliang/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/mqliang/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/mqliang/kubernetes/tags","blobs_url":"https://api.github.com/repos/mqliang/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mqliang/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mqliang/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/mqliang/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mqliang/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/mqliang/kubernetes/languages","stargazers_url":"https://api.github.com/repos/mqliang/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/mqliang/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/mqliang/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/mqliang/kubernetes/subscription","commits_url":"https://api.github.com/repos/mqliang/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/mqliang/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/mqliang/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/mqliang/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/mqliang/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/mqliang/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mqliang/kubernetes/merges","archive_url":"https://api.github.com/repos/mqliang/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mqliang/kubernetes/downloads","issues_url":"https://api.github.com/repos/mqliang/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/mqliang/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/mqliang/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/mqliang/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mqliang/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/mqliang/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/mqliang/kubernetes/deployments","created_at":"2015-09-22T06:44:47Z","updated_at":"2016-01-29T08:29:39Z","pushed_at":"2016-02-03T00:06:32Z","git_url":"git://github.com/mqliang/kubernetes.git","ssh_url":"git@github.com:mqliang/kubernetes.git","clone_url":"https://github.com/mqliang/kubernetes.git","svn_url":"https://github.com/mqliang/kubernetes","homepage":"http://kubernetes.io","size":155789,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"kubernetes:master","ref":"master","sha":"5007d7c4a9758ca778db2dcd3f2c283fef2357be","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"kubernetes/kubernetes","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/kubernetes/kubernetes","forks_url":"https://api.github.com/repos/kubernetes/kubernetes/forks","keys_url":"https://api.github.com/repos/kubernetes/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/kubernetes/teams","hooks_url":"https://api.github.com/repos/kubernetes/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/kubernetes/events","assignees_url":"https://api.github.com/repos/kubernetes/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/kubernetes/tags","blobs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/kubernetes/languages","stargazers_url":"https://api.github.com/repos/kubernetes/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/kubernetes/subscription","commits_url":"https://api.github.com/repos/kubernetes/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/kubernetes/merges","archive_url":"https://api.github.com/repos/kubernetes/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/kubernetes/downloads","issues_url":"https://api.github.com/repos/kubernetes/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes/kubernetes/deployments","created_at":"2014-06-06T22:56:04Z","updated_at":"2016-02-02T21:06:36Z","pushed_at":"2016-02-03T00:26:42Z","git_url":"git://github.com/kubernetes/kubernetes.git","ssh_url":"git@github.com:kubernetes/kubernetes.git","clone_url":"https://github.com/kubernetes/kubernetes.git","svn_url":"https://github.com/kubernetes/kubernetes","homepage":"http://kubernetes.io","size":315681,"stargazers_count":12474,"watchers_count":12474,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3529,"mirror_url":null,"open_issues_count":2819,"forks":3529,"open_issues":2819,"watchers":12474,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/19117"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/19117"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/19117"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/19117/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/19117/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/19117/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/db365c8a3d17682a87f7785062441da90e96f1cd"}}}}