{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/67622677","id":67622677,"diff_hunk":"@@ -54,166 +56,193 @@ func NewDockercfgController(cl client.Interface, options DockercfgControllerOpti\n \t\t&api.ServiceAccount{},\n \t\toptions.Resync,\n \t\tframework.ResourceEventHandlerFuncs{\n-\t\t\tAddFunc:    e.serviceAccountAdded,\n-\t\t\tUpdateFunc: e.serviceAccountUpdated,\n+\t\t\tAddFunc: func(obj interface{}) {\n+\t\t\t\tserviceAccount := obj.(*api.ServiceAccount)\n+\t\t\t\tglog.V(4).Infof(\"Adding service account %s\", serviceAccount.Name)\n+\t\t\t\te.enqueueServiceAccount(serviceAccount)\n+\t\t\t},\n+\t\t\tUpdateFunc: func(old, cur interface{}) {\n+\t\t\t\tserviceAccount := cur.(*api.ServiceAccount)\n+\t\t\t\tglog.V(4).Infof(\"Updating service account %s\", serviceAccount.Name)\n+\t\t\t\t// Resync on service object relist.\n+\t\t\t\te.enqueueServiceAccount(serviceAccount)\n+\t\t\t},\n \t\t},\n \t)\n \n+\te.syncHandler = e.syncServiceAccount\n \te.dockerURL = options.DefaultDockerURL\n \n \treturn e\n }\n \n // DockercfgController manages dockercfg secrets for ServiceAccount objects\n type DockercfgController struct {\n-\tstopChan chan struct{}\n-\n \tclient client.Interface\n \n \tdockerURL     string\n \tdockerURLLock sync.Mutex\n \n+\tserviceAccountCache      cache.Store\n \tserviceAccountController *framework.Controller\n+\n+\tqueue workqueue.RateLimitingInterface\n+\n+\t// syncHandler does the work. It's factored out for unit testing\n+\tsyncHandler func(serviceKey string) error\n+}\n+\n+func (e *DockercfgController) Run(workers int, stopCh <-chan struct{}) {\n+\tdefer utilruntime.HandleCrash()\n+\tgo e.serviceAccountController.Run(stopCh)\n+\tfor i := 0; i < workers; i++ {\n+\t\tgo wait.Until(e.worker, time.Second, stopCh)\n+\t}\n+\n+\t<-stopCh\n+\tglog.Infof(\"Shutting down dockercfg secret controller\")\n+\te.queue.ShutDown()\n }\n \n-// Runs controller loops and returns immediately\n-func (e *DockercfgController) Run() {\n-\tif e.stopChan == nil {\n-\t\te.stopChan = make(chan struct{})\n-\t\tgo e.serviceAccountController.Run(e.stopChan)\n+func (e *DockercfgController) enqueueServiceAccount(serviceAccount *api.ServiceAccount) {\n+\tif !needsDockercfgSecret(serviceAccount) {\n+\t\treturn\n \t}\n+\n+\tkey, err := controller.KeyFunc(serviceAccount)\n+\tif err != nil {\n+\t\tglog.Errorf(\"Couldn't get key for object %+v: %v\", serviceAccount, err)\n+\t\treturn\n+\t}\n+\n+\te.queue.Add(key)\n }\n \n-// Stop gracefully shuts down this controller\n-func (e *DockercfgController) Stop() {\n-\tif e.stopChan != nil {\n-\t\tclose(e.stopChan)\n-\t\te.stopChan = nil\n+// worker runs a worker thread that just dequeues items, processes them, and marks them done.\n+// It enforces that the syncHandler is never invoked concurrently with the same key.\n+func (e *DockercfgController) worker() {\n+\tfor {\n+\t\tif !e.worker_inner() {\n+\t\t\treturn\n+\t\t}\n \t}\n }\n \n+// worker_inner returns true if the worker thread should continue\n+func (e *DockercfgController) worker_inner() bool {\n+\tkey, quit := e.queue.Get()\n+\tif quit {\n+\t\treturn false\n+\t}\n+\tdefer e.queue.Done(key)\n+\n+\tif err := e.syncHandler(key.(string)); err == nil {\n+\t\t// this means the request was successfully handled.  We should \"forget\" the item so that any retry\n+\t\t// later on is reset\n+\t\te.queue.Forget(key)\n+\n+\t} else {\n+\t\t// if we had an error it means that we didn't handle it, which means that we want to requeue the work\n+\t\tutilruntime.HandleError(fmt.Errorf(\"error syncing service, it will be retried: %v\", err))\n+\t\te.queue.AddRateLimited(key)","path":"pkg/serviceaccounts/controllers/create_dockercfg_secrets.go","position":144,"original_position":142,"commit_id":"bee987e75f512d4d16107aa73ea289faa07df353","original_commit_id":"e87d933b6db77eee464f446ed60249f18f590440","user":{"login":"deads2k","id":8225098,"avatar_url":"https://avatars.githubusercontent.com/u/8225098?v=3","gravatar_id":"","url":"https://api.github.com/users/deads2k","html_url":"https://github.com/deads2k","followers_url":"https://api.github.com/users/deads2k/followers","following_url":"https://api.github.com/users/deads2k/following{/other_user}","gists_url":"https://api.github.com/users/deads2k/gists{/gist_id}","starred_url":"https://api.github.com/users/deads2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads2k/subscriptions","organizations_url":"https://api.github.com/users/deads2k/orgs","repos_url":"https://api.github.com/users/deads2k/repos","events_url":"https://api.github.com/users/deads2k/events{/privacy}","received_events_url":"https://api.github.com/users/deads2k/received_events","type":"User","site_admin":false},"body":"> max number of retries?\r\n\r\nUnless we flag permanent failures, we'll just pick up on the next resync.  I wasn't prepared to say that.","created_at":"2016-06-19T19:44:07Z","updated_at":"2016-06-19T19:44:07Z","html_url":"https://github.com/openshift/origin/pull/9342#discussion_r67622677","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/9342","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/67622677"},"html":{"href":"https://github.com/openshift/origin/pull/9342#discussion_r67622677"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/9342"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/9342","id":73910666,"html_url":"https://github.com/openshift/origin/pull/9342","diff_url":"https://github.com/openshift/origin/pull/9342.diff","patch_url":"https://github.com/openshift/origin/pull/9342.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/9342","number":9342,"state":"open","locked":false,"title":"mutated cache filter","user":{"login":"deads2k","id":8225098,"avatar_url":"https://avatars.githubusercontent.com/u/8225098?v=3","gravatar_id":"","url":"https://api.github.com/users/deads2k","html_url":"https://github.com/deads2k","followers_url":"https://api.github.com/users/deads2k/followers","following_url":"https://api.github.com/users/deads2k/following{/other_user}","gists_url":"https://api.github.com/users/deads2k/gists{/gist_id}","starred_url":"https://api.github.com/users/deads2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads2k/subscriptions","organizations_url":"https://api.github.com/users/deads2k/orgs","repos_url":"https://api.github.com/users/deads2k/repos","events_url":"https://api.github.com/users/deads2k/events{/privacy}","received_events_url":"https://api.github.com/users/deads2k/received_events","type":"User","site_admin":false},"body":"Last two commits.  This makes it possible to avoid getting back a stale object if you're the client that updated that same object.\r\n\r\n@liggitt @derekwaynecarr @smarterclayton  I could actually make this a generic filter sitting on top of an indexer used by a `SharedIndexInformer` if we wanted to trust people to ONLY called `Mutation` when they've gotten back a confirmed correct object from `Update`.  There's certainly some utility to such an approach, but it does require some trust.","created_at":"2016-06-15T13:25:08Z","updated_at":"2016-06-19T19:44:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3bdec836172da155d66fbf2f31e50a969e1d3b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openshift/origin/pulls/9342/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/9342/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/9342/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/bee987e75f512d4d16107aa73ea289faa07df353","head":{"label":"deads2k:mutated-cache","ref":"mutated-cache","sha":"bee987e75f512d4d16107aa73ea289faa07df353","user":{"login":"deads2k","id":8225098,"avatar_url":"https://avatars.githubusercontent.com/u/8225098?v=3","gravatar_id":"","url":"https://api.github.com/users/deads2k","html_url":"https://github.com/deads2k","followers_url":"https://api.github.com/users/deads2k/followers","following_url":"https://api.github.com/users/deads2k/following{/other_user}","gists_url":"https://api.github.com/users/deads2k/gists{/gist_id}","starred_url":"https://api.github.com/users/deads2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads2k/subscriptions","organizations_url":"https://api.github.com/users/deads2k/orgs","repos_url":"https://api.github.com/users/deads2k/repos","events_url":"https://api.github.com/users/deads2k/events{/privacy}","received_events_url":"https://api.github.com/users/deads2k/received_events","type":"User","site_admin":false},"repo":{"id":24424126,"name":"origin","full_name":"deads2k/origin","owner":{"login":"deads2k","id":8225098,"avatar_url":"https://avatars.githubusercontent.com/u/8225098?v=3","gravatar_id":"","url":"https://api.github.com/users/deads2k","html_url":"https://github.com/deads2k","followers_url":"https://api.github.com/users/deads2k/followers","following_url":"https://api.github.com/users/deads2k/following{/other_user}","gists_url":"https://api.github.com/users/deads2k/gists{/gist_id}","starred_url":"https://api.github.com/users/deads2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads2k/subscriptions","organizations_url":"https://api.github.com/users/deads2k/orgs","repos_url":"https://api.github.com/users/deads2k/repos","events_url":"https://api.github.com/users/deads2k/events{/privacy}","received_events_url":"https://api.github.com/users/deads2k/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/deads2k/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/deads2k/origin","forks_url":"https://api.github.com/repos/deads2k/origin/forks","keys_url":"https://api.github.com/repos/deads2k/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/deads2k/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/deads2k/origin/teams","hooks_url":"https://api.github.com/repos/deads2k/origin/hooks","issue_events_url":"https://api.github.com/repos/deads2k/origin/issues/events{/number}","events_url":"https://api.github.com/repos/deads2k/origin/events","assignees_url":"https://api.github.com/repos/deads2k/origin/assignees{/user}","branches_url":"https://api.github.com/repos/deads2k/origin/branches{/branch}","tags_url":"https://api.github.com/repos/deads2k/origin/tags","blobs_url":"https://api.github.com/repos/deads2k/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/deads2k/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/deads2k/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/deads2k/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/deads2k/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/deads2k/origin/languages","stargazers_url":"https://api.github.com/repos/deads2k/origin/stargazers","contributors_url":"https://api.github.com/repos/deads2k/origin/contributors","subscribers_url":"https://api.github.com/repos/deads2k/origin/subscribers","subscription_url":"https://api.github.com/repos/deads2k/origin/subscription","commits_url":"https://api.github.com/repos/deads2k/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/deads2k/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/deads2k/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/deads2k/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/deads2k/origin/contents/{+path}","compare_url":"https://api.github.com/repos/deads2k/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/deads2k/origin/merges","archive_url":"https://api.github.com/repos/deads2k/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/deads2k/origin/downloads","issues_url":"https://api.github.com/repos/deads2k/origin/issues{/number}","pulls_url":"https://api.github.com/repos/deads2k/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/deads2k/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/deads2k/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/deads2k/origin/labels{/name}","releases_url":"https://api.github.com/repos/deads2k/origin/releases{/id}","deployments_url":"https://api.github.com/repos/deads2k/origin/deployments","created_at":"2014-09-24T17:02:12Z","updated_at":"2016-01-11T17:58:27Z","pushed_at":"2016-06-17T14:21:27Z","git_url":"git://github.com/deads2k/origin.git","ssh_url":"git@github.com:deads2k/origin.git","clone_url":"https://github.com/deads2k/origin.git","svn_url":"https://github.com/deads2k/origin","homepage":"https://openshift.github.io","size":289486,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"openshift:master","ref":"master","sha":"78c5c8ea49a278590f578fa6f9fd8adda0263745","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":22442668,"name":"origin","full_name":"openshift/origin","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/origin","description":"Enterprise-Ready Kubernetes for Developers","fork":false,"url":"https://api.github.com/repos/openshift/origin","forks_url":"https://api.github.com/repos/openshift/origin/forks","keys_url":"https://api.github.com/repos/openshift/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/origin/teams","hooks_url":"https://api.github.com/repos/openshift/origin/hooks","issue_events_url":"https://api.github.com/repos/openshift/origin/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/origin/events","assignees_url":"https://api.github.com/repos/openshift/origin/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/origin/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/origin/tags","blobs_url":"https://api.github.com/repos/openshift/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/origin/languages","stargazers_url":"https://api.github.com/repos/openshift/origin/stargazers","contributors_url":"https://api.github.com/repos/openshift/origin/contributors","subscribers_url":"https://api.github.com/repos/openshift/origin/subscribers","subscription_url":"https://api.github.com/repos/openshift/origin/subscription","commits_url":"https://api.github.com/repos/openshift/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/origin/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/origin/merges","archive_url":"https://api.github.com/repos/openshift/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/origin/downloads","issues_url":"https://api.github.com/repos/openshift/origin/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/origin/labels{/name}","releases_url":"https://api.github.com/repos/openshift/origin/releases{/id}","deployments_url":"https://api.github.com/repos/openshift/origin/deployments","created_at":"2014-07-30T20:04:05Z","updated_at":"2016-06-19T15:44:51Z","pushed_at":"2016-06-19T18:59:03Z","git_url":"git://github.com/openshift/origin.git","ssh_url":"git@github.com:openshift/origin.git","clone_url":"https://github.com/openshift/origin.git","svn_url":"https://github.com/openshift/origin","homepage":"http://www.openshift.org","size":514312,"stargazers_count":1388,"watchers_count":1388,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":829,"mirror_url":null,"open_issues_count":1039,"forks":829,"open_issues":1039,"watchers":1388,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/9342"},"html":{"href":"https://github.com/openshift/origin/pull/9342"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/9342"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/9342/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/9342/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/9342/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/bee987e75f512d4d16107aa73ea289faa07df353"}}}}
{"actor":{"display_login":"deads2k"}}