{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/62548779","id":62548779,"diff_hunk":"@@ -0,0 +1,373 @@\n+/*\n+Copyright 2015 The Kubernetes Authors 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 pod\n+\n+import (\n+\t\"sync\"\n+\t\"time\"\n+\n+\t\"github.com/golang/glog\"\n+\t\"k8s.io/kubernetes/pkg/api\"\n+\t\"k8s.io/kubernetes/pkg/api/errors\"\n+\tclientset \"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset\"\n+\tkubecontainer \"k8s.io/kubernetes/pkg/kubelet/container\"\n+\tkubetypes \"k8s.io/kubernetes/pkg/kubelet/types\"\n+\t\"k8s.io/kubernetes/pkg/kubelet/util/format\"\n+\t\"k8s.io/kubernetes/pkg/types\"\n+\t\"k8s.io/kubernetes/pkg/util/wait\"\n+)\n+\n+// Mirror pod manager stores and manages all the mirror pods.\n+//\n+// Kubelet discovers pod updates from 3 sources: file, http, and apiserver.\n+// Pods from non-apiserver sources are called static pods, and API server is\n+// not aware of the existence of static pods. In order to monitor the status of\n+// such pods, kubelet creates a mirror pod for each static pod via the API\n+// server.\n+//\n+// A mirror pod has the same pod full name (name and namespace) as its static\n+// counterpart (albeit different metadata such as UID, etc). By leveraging the\n+// fact that kubelet reports the pod status using the pod full name, the status\n+// of the mirror pod always reflects the actual status of the static pod.\n+// When a static pod gets deleted, the associated orphaned mirror pod will\n+// also be removed.\n+type MirrorManager interface {\n+\t// Start starts the mirror pod manager.\n+\tStart()\n+\n+\t// AddMirrorPod adds a mirror pod, mirror pod will be automatically recreated when needed\n+\tAddMirrorPod(mirrorPod *api.Pod)","path":"pkg/kubelet/pod/mirror_manager.go","position":53,"original_position":53,"commit_id":"341db2e8090c6b19fc2e373b64ed65c602cbb9ed","original_commit_id":"398476bfa9271c2073b87bb77246aa037c591a59","user":{"login":"yujuhong","id":10524058,"avatar_url":"https://avatars.githubusercontent.com/u/10524058?v=3","gravatar_id":"","url":"https://api.github.com/users/yujuhong","html_url":"https://github.com/yujuhong","followers_url":"https://api.github.com/users/yujuhong/followers","following_url":"https://api.github.com/users/yujuhong/following{/other_user}","gists_url":"https://api.github.com/users/yujuhong/gists{/gist_id}","starred_url":"https://api.github.com/users/yujuhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yujuhong/subscriptions","organizations_url":"https://api.github.com/users/yujuhong/orgs","repos_url":"https://api.github.com/users/yujuhong/repos","events_url":"https://api.github.com/users/yujuhong/events{/privacy}","received_events_url":"https://api.github.com/users/yujuhong/received_events","type":"User","site_admin":false},"body":"Ah...I see (from the later commits) that you embed MirrorManager in the PodManager. Is this to reduce the need of passing MirrorManager to all the components? ","created_at":"2016-05-09T18:31:02Z","updated_at":"2016-05-09T18:31:02Z","html_url":"https://github.com/kubernetes/kubernetes/pull/18638#discussion_r62548779","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/18638","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/62548779"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/18638#discussion_r62548779"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/18638"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/18638","id":53537706,"html_url":"https://github.com/kubernetes/kubernetes/pull/18638","diff_url":"https://github.com/kubernetes/kubernetes/pull/18638.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/18638.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/18638","number":18638,"state":"open","locked":false,"title":"kubelet: refactor mirror pod implementation, add mirror pod manager","user":{"login":"Random-Liu","id":5821883,"avatar_url":"https://avatars.githubusercontent.com/u/5821883?v=3","gravatar_id":"","url":"https://api.github.com/users/Random-Liu","html_url":"https://github.com/Random-Liu","followers_url":"https://api.github.com/users/Random-Liu/followers","following_url":"https://api.github.com/users/Random-Liu/following{/other_user}","gists_url":"https://api.github.com/users/Random-Liu/gists{/gist_id}","starred_url":"https://api.github.com/users/Random-Liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Random-Liu/subscriptions","organizations_url":"https://api.github.com/users/Random-Liu/orgs","repos_url":"https://api.github.com/users/Random-Liu/repos","events_url":"https://api.github.com/users/Random-Liu/events{/privacy}","received_events_url":"https://api.github.com/users/Random-Liu/received_events","type":"User","site_admin":false},"body":"For issue #17251 \r\n\r\nIn this PR, I try to move all the mirror pod related logic into a new module **Mirror Pod Manager**.\r\n\r\n*Mirror Pod Manager* is very similar with *status manager*:\r\n* It handles the creation, recreation and deletion of all mirror pods.\r\n* All of its methods are non-blocking, the caller will never be blocked.\r\n* It should be treated as the source of truth of mirror pod in kubelet.\r\n\r\nAfter adding *Mirror Pod Manager*, we should be able to let mirror pod be invisible for most kubelet components, except that:\r\n* **Pod manager** should be aware of *static pod* and set mirror pod manager properly.\r\n* **Status manager** should be aware of *mirror pod* only before updating status to apiserver.\r\n\r\nHowever, this may need a lot of refactoring. The preliminary roadmap could be:\r\n- [x] Implement preliminary *Mirror Pod Manager*\r\n- [x] Double check mirror pod related code carefully, to make sure the functionality of *Mirror Pod Manager* is enough.\r\n- [x] Add test for *Mirror Pod Manager*\r\n- [x] Use *Mirror Pod Manager* in kubelet sync loop.\r\n- [x] Remove mirror pod from `syncPod()` and remove old mirror pod client.\r\n- [x] Modify *kubelet* to use *Mirror Pod Manager* function instead of pod manager functions.\r\n- [x] Remove complicated mirror pod related functions from pod manager.\r\n\r\nThis could be a big change, I didn't expect to finish or merge this any time soon. However, I believe this change worths more effort, because mirror pod things are really hard to understand and mess up our code now. If we can limit the mirror pod related code in one module and one or two places in status manager, I believe it will be easier for understanding and bug shooting.\r\n\r\n@yujuhong This stuff is out of our 1.2 plan and with low priority, if you don't have time, feel free to ignore it, :). I'll also only work on this with my free time.\r\n\r\n/cc @kubernetes/goog-node ","created_at":"2015-12-14T08:50:33Z","updated_at":"2016-05-09T18:31:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"119a47e51bd331c98795e1421ceff229b81f71f5","assignee":{"login":"yujuhong","id":10524058,"avatar_url":"https://avatars.githubusercontent.com/u/10524058?v=3","gravatar_id":"","url":"https://api.github.com/users/yujuhong","html_url":"https://github.com/yujuhong","followers_url":"https://api.github.com/users/yujuhong/followers","following_url":"https://api.github.com/users/yujuhong/following{/other_user}","gists_url":"https://api.github.com/users/yujuhong/gists{/gist_id}","starred_url":"https://api.github.com/users/yujuhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yujuhong/subscriptions","organizations_url":"https://api.github.com/users/yujuhong/orgs","repos_url":"https://api.github.com/users/yujuhong/repos","events_url":"https://api.github.com/users/yujuhong/events{/privacy}","received_events_url":"https://api.github.com/users/yujuhong/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/18638/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/18638/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/18638/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/341db2e8090c6b19fc2e373b64ed65c602cbb9ed","head":{"label":"Random-Liu:add-mirror-pod-manager","ref":"add-mirror-pod-manager","sha":"341db2e8090c6b19fc2e373b64ed65c602cbb9ed","user":{"login":"Random-Liu","id":5821883,"avatar_url":"https://avatars.githubusercontent.com/u/5821883?v=3","gravatar_id":"","url":"https://api.github.com/users/Random-Liu","html_url":"https://github.com/Random-Liu","followers_url":"https://api.github.com/users/Random-Liu/followers","following_url":"https://api.github.com/users/Random-Liu/following{/other_user}","gists_url":"https://api.github.com/users/Random-Liu/gists{/gist_id}","starred_url":"https://api.github.com/users/Random-Liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Random-Liu/subscriptions","organizations_url":"https://api.github.com/users/Random-Liu/orgs","repos_url":"https://api.github.com/users/Random-Liu/repos","events_url":"https://api.github.com/users/Random-Liu/events{/privacy}","received_events_url":"https://api.github.com/users/Random-Liu/received_events","type":"User","site_admin":false},"repo":{"id":44042241,"name":"kubernetes","full_name":"Random-Liu/kubernetes","owner":{"login":"Random-Liu","id":5821883,"avatar_url":"https://avatars.githubusercontent.com/u/5821883?v=3","gravatar_id":"","url":"https://api.github.com/users/Random-Liu","html_url":"https://github.com/Random-Liu","followers_url":"https://api.github.com/users/Random-Liu/followers","following_url":"https://api.github.com/users/Random-Liu/following{/other_user}","gists_url":"https://api.github.com/users/Random-Liu/gists{/gist_id}","starred_url":"https://api.github.com/users/Random-Liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Random-Liu/subscriptions","organizations_url":"https://api.github.com/users/Random-Liu/orgs","repos_url":"https://api.github.com/users/Random-Liu/repos","events_url":"https://api.github.com/users/Random-Liu/events{/privacy}","received_events_url":"https://api.github.com/users/Random-Liu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Random-Liu/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/Random-Liu/kubernetes","forks_url":"https://api.github.com/repos/Random-Liu/kubernetes/forks","keys_url":"https://api.github.com/repos/Random-Liu/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Random-Liu/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Random-Liu/kubernetes/teams","hooks_url":"https://api.github.com/repos/Random-Liu/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/Random-Liu/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/Random-Liu/kubernetes/events","assignees_url":"https://api.github.com/repos/Random-Liu/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/Random-Liu/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/Random-Liu/kubernetes/tags","blobs_url":"https://api.github.com/repos/Random-Liu/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Random-Liu/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Random-Liu/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/Random-Liu/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Random-Liu/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/Random-Liu/kubernetes/languages","stargazers_url":"https://api.github.com/repos/Random-Liu/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/Random-Liu/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/Random-Liu/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/Random-Liu/kubernetes/subscription","commits_url":"https://api.github.com/repos/Random-Liu/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/Random-Liu/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/Random-Liu/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/Random-Liu/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/Random-Liu/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/Random-Liu/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Random-Liu/kubernetes/merges","archive_url":"https://api.github.com/repos/Random-Liu/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Random-Liu/kubernetes/downloads","issues_url":"https://api.github.com/repos/Random-Liu/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/Random-Liu/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/Random-Liu/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/Random-Liu/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Random-Liu/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/Random-Liu/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/Random-Liu/kubernetes/deployments","created_at":"2015-10-11T06:51:00Z","updated_at":"2016-02-04T00:52:34Z","pushed_at":"2016-05-09T06:45:07Z","git_url":"git://github.com/Random-Liu/kubernetes.git","ssh_url":"git@github.com:Random-Liu/kubernetes.git","clone_url":"https://github.com/Random-Liu/kubernetes.git","svn_url":"https://github.com/Random-Liu/kubernetes","homepage":"http://kubernetes.io","size":188166,"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":"2ebd77191592a76283c2e36baa575b4f37c96472","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-05-09T14:41:06Z","pushed_at":"2016-05-09T18:29:03Z","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":411438,"stargazers_count":14281,"watchers_count":14281,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4276,"mirror_url":null,"open_issues_count":3566,"forks":4276,"open_issues":3566,"watchers":14281,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/18638"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/18638"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/18638"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/18638/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/18638/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/18638/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/341db2e8090c6b19fc2e373b64ed65c602cbb9ed"}}}}