{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/45322483","id":45322483,"diff_hunk":"@@ -22,79 +22,314 @@ import (\n \t\"time\"\n \n \t\"github.com/golang/glog\"\n+\n \t\"k8s.io/kubernetes/pkg/api\"\n \t\"k8s.io/kubernetes/pkg/apis/extensions\"\n+\t\"k8s.io/kubernetes/pkg/client/cache\"\n \t\"k8s.io/kubernetes/pkg/client/record\"\n \tclient \"k8s.io/kubernetes/pkg/client/unversioned\"\n+\t\"k8s.io/kubernetes/pkg/controller\"\n+\t\"k8s.io/kubernetes/pkg/controller/framework\"\n \t\"k8s.io/kubernetes/pkg/fields\"\n \t\"k8s.io/kubernetes/pkg/labels\"\n+\t\"k8s.io/kubernetes/pkg/runtime\"\n \t\"k8s.io/kubernetes/pkg/util\"\n \tdeploymentutil \"k8s.io/kubernetes/pkg/util/deployment\"\n+\t\"k8s.io/kubernetes/pkg/util/workqueue\"\n+\t\"k8s.io/kubernetes/pkg/watch\"\n+)\n+\n+const (\n+\t// FullDeploymentResyncPeriod means we'll attempt to recompute the required replicas\n+\t// of all deployments that have fulfilled their expectations at least this often.\n+\t// This recomputation happens based on contents in the local caches.\n+\tFullDeploymentResyncPeriod = 30 * time.Second\n+\n+\t// ControllerRelistPeriod means we'll keep replication controller watches open up to this long.\n+\t// In the unlikely case that a watch misdelivers info about an RC, it'll take this long for\n+\t// that mistake to be rectified.\n+\tControllerRelistPeriod = 5 * time.Minute\n+\n+\t// PodRelistPeriod means we'll keep pod watches open up to this long. In the unlikely case\n+\t// that a watch misdelivers info about a pod, it'll take this long for\n+\t// that mistake to be rectified.\n+\tPodRelistPeriod = 5 * time.Minute\n )\n \n+// DeploymentController is responsible for synchronizing Deployment objects stored\n+// in the system with actual running rcs and pods.\n type DeploymentController struct {\n \tclient        client.Interface\n \texpClient     client.ExtensionsInterface\n \teventRecorder record.EventRecorder\n+\n+\t// To allow injection of syncDeployment for testing.\n+\tsyncHandler func(dKey string) error\n+\n+\t// A store of deployments, populated by the dController\n+\tdStore cache.StoreToDeploymentLister\n+\t// Watches changes to all deployments\n+\tdController *framework.Controller\n+\t// A store of replication controllers, populated by the rcController\n+\trcStore cache.StoreToReplicationControllerLister\n+\t// Watches changes to all replication controllers\n+\trcController *framework.Controller\n+\t// rcStoreSynced returns true if the RC store has been synced at least once.\n+\t// Added as a member to the struct to allow injection for testing.\n+\trcStoreSynced func() bool\n+\t// A store of pods, populated by the podController\n+\tpodStore cache.StoreToPodLister\n+\t// Watches changes to all pods\n+\tpodController *framework.Controller\n+\t// podStoreSynced returns true if the pod store has been synced at least once.\n+\t// Added as a member to the struct to allow injection for testing.\n+\tpodStoreSynced func() bool\n+\n+\t// Deployments that need to be synced\n+\tqueue *workqueue.Type\n }\n \n-func New(client client.Interface) *DeploymentController {\n+// NewDeploymentController creates a new DeploymentController.\n+func NewDeploymentController(client client.Interface) *DeploymentController {\n \teventBroadcaster := record.NewBroadcaster()\n \teventBroadcaster.StartLogging(glog.Infof)\n \teventBroadcaster.StartRecordingToSink(client.Events(\"\"))\n \n-\treturn &DeploymentController{\n+\tdc := &DeploymentController{\n \t\tclient:        client,\n \t\texpClient:     client.Extensions(),\n \t\teventRecorder: eventBroadcaster.NewRecorder(api.EventSource{Component: \"deployment-controller\"}),\n+\t\tqueue:         workqueue.New(),\n+\t}\n+\n+\tdc.dStore.Store, dc.dController = framework.NewInformer(\n+\t\t&cache.ListWatch{\n+\t\t\tListFunc: func() (runtime.Object, error) {\n+\t\t\t\treturn dc.expClient.Deployments(api.NamespaceAll).List(labels.Everything(), fields.Everything())\n+\t\t\t},\n+\t\t\tWatchFunc: func(options api.ListOptions) (watch.Interface, error) {\n+\t\t\t\treturn dc.expClient.Deployments(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), options)\n+\t\t\t},\n+\t\t},\n+\t\t&extensions.Deployment{},\n+\t\tFullDeploymentResyncPeriod,\n+\t\tframework.ResourceEventHandlerFuncs{\n+\t\t\tAddFunc: dc.enqueueDeployment,\n+\t\t\tUpdateFunc: func(old, cur interface{}) {\n+\t\t\t\t// Resync on deployment object relist.\n+\t\t\t\tdc.enqueueDeployment(cur)\n+\t\t\t},\n+\t\t\t// This will enter the sync loop and no-op, because the deployment has been deleted from the store.\n+\t\t\t// Note that deleting a controller immediately after scaling it to 0 will not work. The recommended\n+\t\t\t// way of achieving this is by performing a `stop` operation on the deployment.","path":"pkg/controller/deployment/deployment_controller.go","position":105,"original_position":105,"commit_id":"17960e6116471acee8fcfd81079d785be4a666d9","original_commit_id":"17960e6116471acee8fcfd81079d785be4a666d9","user":{"login":"kargakis","id":3900799,"avatar_url":"https://avatars.githubusercontent.com/u/3900799?v=3","gravatar_id":"","url":"https://api.github.com/users/kargakis","html_url":"https://github.com/kargakis","followers_url":"https://api.github.com/users/kargakis/followers","following_url":"https://api.github.com/users/kargakis/following{/other_user}","gists_url":"https://api.github.com/users/kargakis/gists{/gist_id}","starred_url":"https://api.github.com/users/kargakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kargakis/subscriptions","organizations_url":"https://api.github.com/users/kargakis/orgs","repos_url":"https://api.github.com/users/kargakis/repos","events_url":"https://api.github.com/users/kargakis/events{/privacy}","received_events_url":"https://api.github.com/users/kargakis/received_events","type":"User","site_admin":false},"body":"No, deployments don't have a stop operation currently. I think @bgrant0607 was advocating over doing this in the server vs in the client where all stop operations are currently implemented.","created_at":"2015-11-19T10:17:42Z","updated_at":"2015-11-19T10:17:42Z","html_url":"https://github.com/kubernetes/kubernetes/pull/17398#discussion_r45322483","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/17398","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/45322483"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/17398#discussion_r45322483"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/17398"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/17398","id":51019193,"html_url":"https://github.com/kubernetes/kubernetes/pull/17398","diff_url":"https://github.com/kubernetes/kubernetes/pull/17398.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/17398.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/17398","number":17398,"state":"open","locked":false,"title":"Add informers to deployment controller","user":{"login":"janetkuo","id":4876867,"avatar_url":"https://avatars.githubusercontent.com/u/4876867?v=3","gravatar_id":"","url":"https://api.github.com/users/janetkuo","html_url":"https://github.com/janetkuo","followers_url":"https://api.github.com/users/janetkuo/followers","following_url":"https://api.github.com/users/janetkuo/following{/other_user}","gists_url":"https://api.github.com/users/janetkuo/gists{/gist_id}","starred_url":"https://api.github.com/users/janetkuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janetkuo/subscriptions","organizations_url":"https://api.github.com/users/janetkuo/orgs","repos_url":"https://api.github.com/users/janetkuo/repos","events_url":"https://api.github.com/users/janetkuo/events{/privacy}","received_events_url":"https://api.github.com/users/janetkuo/received_events","type":"User","site_admin":false},"body":"Supersedes  #14130 \r\n\r\ncc @ghodss @ironcladlou @nikhiljindal @bprashanth @kargakis @bgrant0607 ","created_at":"2015-11-17T23:09:00Z","updated_at":"2015-11-19T10:17:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"639729eabd84684e010ba06ed849e0d883057d3c","assignee":{"login":"nikhiljindal","id":10199099,"avatar_url":"https://avatars.githubusercontent.com/u/10199099?v=3","gravatar_id":"","url":"https://api.github.com/users/nikhiljindal","html_url":"https://github.com/nikhiljindal","followers_url":"https://api.github.com/users/nikhiljindal/followers","following_url":"https://api.github.com/users/nikhiljindal/following{/other_user}","gists_url":"https://api.github.com/users/nikhiljindal/gists{/gist_id}","starred_url":"https://api.github.com/users/nikhiljindal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikhiljindal/subscriptions","organizations_url":"https://api.github.com/users/nikhiljindal/orgs","repos_url":"https://api.github.com/users/nikhiljindal/repos","events_url":"https://api.github.com/users/nikhiljindal/events{/privacy}","received_events_url":"https://api.github.com/users/nikhiljindal/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/17398/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/17398/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/17398/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/17960e6116471acee8fcfd81079d785be4a666d9","head":{"label":"janetkuo:deployment-controller-informer","ref":"deployment-controller-informer","sha":"17960e6116471acee8fcfd81079d785be4a666d9","user":{"login":"janetkuo","id":4876867,"avatar_url":"https://avatars.githubusercontent.com/u/4876867?v=3","gravatar_id":"","url":"https://api.github.com/users/janetkuo","html_url":"https://github.com/janetkuo","followers_url":"https://api.github.com/users/janetkuo/followers","following_url":"https://api.github.com/users/janetkuo/following{/other_user}","gists_url":"https://api.github.com/users/janetkuo/gists{/gist_id}","starred_url":"https://api.github.com/users/janetkuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janetkuo/subscriptions","organizations_url":"https://api.github.com/users/janetkuo/orgs","repos_url":"https://api.github.com/users/janetkuo/repos","events_url":"https://api.github.com/users/janetkuo/events{/privacy}","received_events_url":"https://api.github.com/users/janetkuo/received_events","type":"User","site_admin":false},"repo":{"id":37748937,"name":"kubernetes","full_name":"janetkuo/kubernetes","owner":{"login":"janetkuo","id":4876867,"avatar_url":"https://avatars.githubusercontent.com/u/4876867?v=3","gravatar_id":"","url":"https://api.github.com/users/janetkuo","html_url":"https://github.com/janetkuo","followers_url":"https://api.github.com/users/janetkuo/followers","following_url":"https://api.github.com/users/janetkuo/following{/other_user}","gists_url":"https://api.github.com/users/janetkuo/gists{/gist_id}","starred_url":"https://api.github.com/users/janetkuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janetkuo/subscriptions","organizations_url":"https://api.github.com/users/janetkuo/orgs","repos_url":"https://api.github.com/users/janetkuo/repos","events_url":"https://api.github.com/users/janetkuo/events{/privacy}","received_events_url":"https://api.github.com/users/janetkuo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/janetkuo/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/janetkuo/kubernetes","forks_url":"https://api.github.com/repos/janetkuo/kubernetes/forks","keys_url":"https://api.github.com/repos/janetkuo/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/janetkuo/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/janetkuo/kubernetes/teams","hooks_url":"https://api.github.com/repos/janetkuo/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/janetkuo/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/janetkuo/kubernetes/events","assignees_url":"https://api.github.com/repos/janetkuo/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/janetkuo/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/janetkuo/kubernetes/tags","blobs_url":"https://api.github.com/repos/janetkuo/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/janetkuo/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/janetkuo/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/janetkuo/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/janetkuo/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/janetkuo/kubernetes/languages","stargazers_url":"https://api.github.com/repos/janetkuo/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/janetkuo/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/janetkuo/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/janetkuo/kubernetes/subscription","commits_url":"https://api.github.com/repos/janetkuo/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/janetkuo/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/janetkuo/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/janetkuo/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/janetkuo/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/janetkuo/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/janetkuo/kubernetes/merges","archive_url":"https://api.github.com/repos/janetkuo/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/janetkuo/kubernetes/downloads","issues_url":"https://api.github.com/repos/janetkuo/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/janetkuo/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/janetkuo/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/janetkuo/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/janetkuo/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/janetkuo/kubernetes/releases{/id}","created_at":"2015-06-19T22:29:18Z","updated_at":"2015-06-19T22:29:25Z","pushed_at":"2015-11-19T00:39:57Z","git_url":"git://github.com/janetkuo/kubernetes.git","ssh_url":"git@github.com:janetkuo/kubernetes.git","clone_url":"https://github.com/janetkuo/kubernetes.git","svn_url":"https://github.com/janetkuo/kubernetes","homepage":"http://kubernetes.io","size":137546,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"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":"742243bb4adc9dc83411354566667259bcd7d7ee","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}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-11-19T09:32:50Z","pushed_at":"2015-11-19T09:41:31Z","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":288273,"stargazers_count":11332,"watchers_count":11332,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2999,"mirror_url":null,"open_issues_count":2367,"forks":2999,"open_issues":2367,"watchers":11332,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/17398"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/17398"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/17398"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/17398/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/17398/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/17398/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/17960e6116471acee8fcfd81079d785be4a666d9"}}}}