{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/26857508","id":26857508,"diff_hunk":"@@ -0,0 +1,120 @@\n+/*\n+Copyright 2014 Google Inc. All rights reserved.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain 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,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*/\n+\n+package kubelet\n+\n+import (\n+\t\"reflect\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/api\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/client\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/util\"\n+\t\"github.com/golang/glog\"\n+)\n+\n+type podSyncStatus struct {\n+\tapi.PodStatus\n+\tsynced bool\n+}\n+\n+type statusSyncer struct {\n+\tkubeClient client.Interface\n+\t// Map from pod full name to sync status of the corresponding pod.\n+\tpodStatusesLock sync.RWMutex\n+\tpodStatuses     map[string]podSyncStatus\n+\n+\t// TODO(filipg): Remove, unused\n+\tpodStatusUpdateFrequency time.Duration\n+}\n+\n+func newStatusSyncer(kubeClient client.Interface) *statusSyncer {\n+\treturn &statusSyncer{\n+\t\tkubeClient:  kubeClient,\n+\t\tpodStatuses: make(map[string]podSyncStatus),\n+\t}\n+}\n+\n+func (s *statusSyncer) Run() {\n+\t// We can run Sync() often because it will only update statuses that have\n+\t// changed and is cheap if there are none.\n+\tgo util.Forever(s.Sync, 5*time.Second)\n+}\n+\n+func (s *statusSyncer) GetPodStatus(podFullName string) (api.PodStatus, bool) {\n+\ts.podStatusesLock.RLock()\n+\tdefer s.podStatusesLock.RUnlock()\n+\tstatus, ok := s.podStatuses[podFullName]\n+\treturn status.PodStatus, ok\n+}\n+\n+func (s *statusSyncer) SetPodStatus(podFullName string, status api.PodStatus) {\n+\ts.podStatusesLock.Lock()\n+\tdefer s.podStatusesLock.Unlock()\n+\toldSyncStatus, found := s.podStatuses[podFullName]\n+\tif !found || !reflect.DeepEqual(oldSyncStatus.PodStatus, status) {\n+\t\ts.podStatuses[podFullName] = podSyncStatus{status, false}\n+\t} else {\n+\t\tglog.Infof(\"Ignoring same pod status for %s - old: %s new: %s\", podFullName, oldSyncStatus.PodStatus, status)\n+\t}\n+}\n+\n+// TODO(filipg): It'd be cleaner if we can do this without signal from user.","path":"pkg/kubelet/status_syncer.go","position":76,"original_position":76,"commit_id":"d48fa4ea42a14107cafd660493c7fa9ec5608cde","original_commit_id":"d48fa4ea42a14107cafd660493c7fa9ec5608cde","user":{"login":"vmarmol","id":985208,"avatar_url":"https://avatars.githubusercontent.com/u/985208?v=3","gravatar_id":"","url":"https://api.github.com/users/vmarmol","html_url":"https://github.com/vmarmol","followers_url":"https://api.github.com/users/vmarmol/followers","following_url":"https://api.github.com/users/vmarmol/following{/other_user}","gists_url":"https://api.github.com/users/vmarmol/gists{/gist_id}","starred_url":"https://api.github.com/users/vmarmol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmarmol/subscriptions","organizations_url":"https://api.github.com/users/vmarmol/orgs","repos_url":"https://api.github.com/users/vmarmol/repos","events_url":"https://api.github.com/users/vmarmol/events{/privacy}","received_events_url":"https://api.github.com/users/vmarmol/received_events","type":"User","site_admin":false},"body":"+1 we may get there when we have an explicit \"Remove\", but agree it's a TODO.","created_at":"2015-03-20T17:17:53Z","updated_at":"2015-03-20T17:17:53Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5714#discussion_r26857508","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5714","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/26857508"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5714#discussion_r26857508"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5714"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5714","id":31630568,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5714","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5714.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5714.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5714","number":5714,"state":"open","locked":false,"title":"Update pod status only when it changes.","user":{"login":"fgrzadkowski","id":10820726,"avatar_url":"https://avatars.githubusercontent.com/u/10820726?v=3","gravatar_id":"","url":"https://api.github.com/users/fgrzadkowski","html_url":"https://github.com/fgrzadkowski","followers_url":"https://api.github.com/users/fgrzadkowski/followers","following_url":"https://api.github.com/users/fgrzadkowski/following{/other_user}","gists_url":"https://api.github.com/users/fgrzadkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/fgrzadkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgrzadkowski/subscriptions","organizations_url":"https://api.github.com/users/fgrzadkowski/orgs","repos_url":"https://api.github.com/users/fgrzadkowski/repos","events_url":"https://api.github.com/users/fgrzadkowski/events{/privacy}","received_events_url":"https://api.github.com/users/fgrzadkowski/received_events","type":"User","site_admin":false},"body":"* Update pod status only when it changes.\r\n* Refactor syncing logic into a separate struct\r\n\r\nThis PR is ready for review, but I haven't run e2e tests. I'm sending this now so that I can address comments on Monday CET time.\r\n\r\nThis fixes #5624 and #5693\r\n\r\nI plan to apply the same logic (update upon change) for node status updates.\r\n\r\n@vmarmol @bgrant0607 @dchen1107 @smarterclayton ","created_at":"2015-03-20T16:42:51Z","updated_at":"2015-03-20T17:17:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a00dfdda369ae1bc6fbb092816d756278e13d49","assignee":{"login":"vmarmol","id":985208,"avatar_url":"https://avatars.githubusercontent.com/u/985208?v=3","gravatar_id":"","url":"https://api.github.com/users/vmarmol","html_url":"https://github.com/vmarmol","followers_url":"https://api.github.com/users/vmarmol/followers","following_url":"https://api.github.com/users/vmarmol/following{/other_user}","gists_url":"https://api.github.com/users/vmarmol/gists{/gist_id}","starred_url":"https://api.github.com/users/vmarmol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmarmol/subscriptions","organizations_url":"https://api.github.com/users/vmarmol/orgs","repos_url":"https://api.github.com/users/vmarmol/repos","events_url":"https://api.github.com/users/vmarmol/events{/privacy}","received_events_url":"https://api.github.com/users/vmarmol/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5714/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5714/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5714/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/d48fa4ea42a14107cafd660493c7fa9ec5608cde","head":{"label":"fgrzadkowski:update_status_on_change","ref":"update_status_on_change","sha":"d48fa4ea42a14107cafd660493c7fa9ec5608cde","user":{"login":"fgrzadkowski","id":10820726,"avatar_url":"https://avatars.githubusercontent.com/u/10820726?v=3","gravatar_id":"","url":"https://api.github.com/users/fgrzadkowski","html_url":"https://github.com/fgrzadkowski","followers_url":"https://api.github.com/users/fgrzadkowski/followers","following_url":"https://api.github.com/users/fgrzadkowski/following{/other_user}","gists_url":"https://api.github.com/users/fgrzadkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/fgrzadkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgrzadkowski/subscriptions","organizations_url":"https://api.github.com/users/fgrzadkowski/orgs","repos_url":"https://api.github.com/users/fgrzadkowski/repos","events_url":"https://api.github.com/users/fgrzadkowski/events{/privacy}","received_events_url":"https://api.github.com/users/fgrzadkowski/received_events","type":"User","site_admin":false},"repo":{"id":30216861,"name":"kubernetes","full_name":"fgrzadkowski/kubernetes","owner":{"login":"fgrzadkowski","id":10820726,"avatar_url":"https://avatars.githubusercontent.com/u/10820726?v=3","gravatar_id":"","url":"https://api.github.com/users/fgrzadkowski","html_url":"https://github.com/fgrzadkowski","followers_url":"https://api.github.com/users/fgrzadkowski/followers","following_url":"https://api.github.com/users/fgrzadkowski/following{/other_user}","gists_url":"https://api.github.com/users/fgrzadkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/fgrzadkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgrzadkowski/subscriptions","organizations_url":"https://api.github.com/users/fgrzadkowski/orgs","repos_url":"https://api.github.com/users/fgrzadkowski/repos","events_url":"https://api.github.com/users/fgrzadkowski/events{/privacy}","received_events_url":"https://api.github.com/users/fgrzadkowski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fgrzadkowski/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/fgrzadkowski/kubernetes","forks_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/forks","keys_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/teams","hooks_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/events","assignees_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/tags","blobs_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/languages","stargazers_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/subscription","commits_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/merges","archive_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/downloads","issues_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/fgrzadkowski/kubernetes/releases{/id}","created_at":"2015-02-03T00:40:39Z","updated_at":"2015-03-20T09:51:54Z","pushed_at":"2015-03-20T16:39:13Z","git_url":"git://github.com/fgrzadkowski/kubernetes.git","ssh_url":"git@github.com:fgrzadkowski/kubernetes.git","clone_url":"https://github.com/fgrzadkowski/kubernetes.git","svn_url":"https://github.com/fgrzadkowski/kubernetes","homepage":"http://kubernetes.io","size":37484,"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":"GoogleCloudPlatform:master","ref":"master","sha":"bae91aed480ab3d1398ed9071a4df270988c4899","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"GoogleCloudPlatform/kubernetes","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-03-20T17:00:50Z","pushed_at":"2015-03-20T17:17:10Z","git_url":"git://github.com/GoogleCloudPlatform/kubernetes.git","ssh_url":"git@github.com:GoogleCloudPlatform/kubernetes.git","clone_url":"https://github.com/GoogleCloudPlatform/kubernetes.git","svn_url":"https://github.com/GoogleCloudPlatform/kubernetes","homepage":"http://kubernetes.io","size":108762,"stargazers_count":6670,"watchers_count":6670,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1246,"mirror_url":null,"open_issues_count":781,"forks":1246,"open_issues":781,"watchers":6670,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5714"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5714"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5714"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5714/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5714/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5714/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/d48fa4ea42a14107cafd660493c7fa9ec5608cde"}}}}