{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/25989363","id":25989363,"diff_hunk":"@@ -24,53 +24,109 @@ import (\n \t\"time\"\n \n \t\"github.com/GoogleCloudPlatform/kubernetes/pkg/api\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools\"\n \t\"github.com/GoogleCloudPlatform/kubernetes/pkg/probe\"\n \texecprobe \"github.com/GoogleCloudPlatform/kubernetes/pkg/probe/exec\"\n \thttprobe \"github.com/GoogleCloudPlatform/kubernetes/pkg/probe/http\"\n \ttcprobe \"github.com/GoogleCloudPlatform/kubernetes/pkg/probe/tcp\"\n-\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/types\"\n \t\"github.com/GoogleCloudPlatform/kubernetes/pkg/util\"\n \t\"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec\"\n-\n \t\"github.com/fsouza/go-dockerclient\"\n+\n \t\"github.com/golang/glog\"\n )\n \n const maxProbeRetries = 3\n \n-// probeContainer executes the given probe on a container and returns the result.\n-// If the probe is nil this returns Success. If the probe's initial delay has not passed\n-// since the creation of the container, this returns the defaultResult. It will then attempt\n-// to execute the probe repeatedly up to maxProbeRetries times, and return on the first\n-// successful result, else returning the last unsucessful result and error.\n-func (kl *Kubelet) probeContainer(p *api.Probe,\n-\tpodFullName string,\n-\tpodUID types.UID,\n-\tstatus api.PodStatus,\n-\tcontainer api.Container,\n-\tdockerContainer *docker.APIContainers,\n-\tdefaultResult probe.Result) (probe.Result, error) {\n+// probeContainer probes the liveness/readiness of the given container.\n+// If the container's liveness probe is unsuccessful, set readiness to false.\n+// If liveness is successful, do a readiness check and set readiness accordingly.\n+func (kl *Kubelet) probeContainer(pod *api.BoundPod, status api.PodStatus, container api.Container, dockerContainer *docker.APIContainers) (probe.Result, error) {\n+\t// Probe liveness.\n+\tlive, err := kl.probeContainerLiveness(pod, status, container, dockerContainer)\n+\tif err != nil {\n+\t\tglog.V(1).Infof(\"liveness probe errored: %v\", err)\n+\t\tkl.readiness.set(dockerContainer.ID, false)\n+\t\treturn probe.Unknown, err\n+\t}\n+\tif live != probe.Success {\n+\t\tglog.V(1).Infof(\"liveness probe unsuccessful: %v\", live)\n+\t\tkl.readiness.set(dockerContainer.ID, false)\n+\t\treturn live, nil\n+\t}\n+\n+\t// Probe readiness.\n+\tready, err := kl.probeContainerReadiness(pod, status, container, dockerContainer)\n+\tif err == nil && ready == probe.Success {\n+\t\tglog.V(1).Infof(\"readiness probe successful: %v\", ready)\n+\t\tkl.readiness.set(dockerContainer.ID, true)\n+\t\treturn probe.Success, nil\n+\t}\n+\n+\tglog.V(1).Infof(\"readiness probe failed/errored: %v, %v\", ready, err)\n+\tkl.readiness.set(dockerContainer.ID, false)\n+\n+\tcontainerID := dockertools.DockerID(dockerContainer.ID)\n+\tref, ok := kl.getRef(containerID)\n+\tif !ok {\n+\t\tglog.Warningf(\"No ref for pod '%v' - '%v'\", containerID, container.Name)\n+\t} else {\n+\t\tkl.recorder.Eventf(ref, \"unhealthy\", \"Liveness Probe Failed %v - %v\", containerID, container.Name)\n+\t}\n+\treturn ready, err\n+}\n+\n+// probeContainerLiveness probes the liveness of a container.\n+// If the initalDelay since container creation on liveness probe has not passed the probe will return probe.Success.\n+func (kl *Kubelet) probeContainerLiveness(pod *api.BoundPod, status api.PodStatus, container api.Container, dockerContainer *docker.APIContainers) (probe.Result, error) {","path":"pkg/kubelet/probe.go","position":72,"original_position":72,"commit_id":"5b67183c1c92ab93b1445af8e408b8b80a101549","original_commit_id":"5b67183c1c92ab93b1445af8e408b8b80a101549","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":"I think we can collapse these back into one function that takes the probe and the defaultResult. The code is near identical.","created_at":"2015-03-07T00:22:10Z","updated_at":"2015-03-07T00:22:10Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5148#discussion_r25989363","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5148","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/25989363"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5148#discussion_r25989363"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5148"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5148","id":30687150,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5148","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5148.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5148.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5148","number":5148,"state":"open","locked":false,"title":"Refactor pkg/kubelet/kubelet.go: probeContainer().","user":{"login":"yifan-gu","id":3278588,"avatar_url":"https://avatars.githubusercontent.com/u/3278588?v=3","gravatar_id":"","url":"https://api.github.com/users/yifan-gu","html_url":"https://github.com/yifan-gu","followers_url":"https://api.github.com/users/yifan-gu/followers","following_url":"https://api.github.com/users/yifan-gu/following{/other_user}","gists_url":"https://api.github.com/users/yifan-gu/gists{/gist_id}","starred_url":"https://api.github.com/users/yifan-gu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yifan-gu/subscriptions","organizations_url":"https://api.github.com/users/yifan-gu/orgs","repos_url":"https://api.github.com/users/yifan-gu/repos","events_url":"https://api.github.com/users/yifan-gu/events{/privacy}","received_events_url":"https://api.github.com/users/yifan-gu/received_events","type":"User","site_admin":false},"body":"Split the function into probeContainerLiveness() and\r\nprobeContainerReadiness(). Also add tests.","created_at":"2015-03-06T22:55:05Z","updated_at":"2015-03-07T00:22:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d0341051de79c9d9dd58fd1b46b0183224e6fd4","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/5148/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5148/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5148/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/5b67183c1c92ab93b1445af8e408b8b80a101549","head":{"label":"yifan-gu:clean_prober","ref":"clean_prober","sha":"5b67183c1c92ab93b1445af8e408b8b80a101549","user":{"login":"yifan-gu","id":3278588,"avatar_url":"https://avatars.githubusercontent.com/u/3278588?v=3","gravatar_id":"","url":"https://api.github.com/users/yifan-gu","html_url":"https://github.com/yifan-gu","followers_url":"https://api.github.com/users/yifan-gu/followers","following_url":"https://api.github.com/users/yifan-gu/following{/other_user}","gists_url":"https://api.github.com/users/yifan-gu/gists{/gist_id}","starred_url":"https://api.github.com/users/yifan-gu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yifan-gu/subscriptions","organizations_url":"https://api.github.com/users/yifan-gu/orgs","repos_url":"https://api.github.com/users/yifan-gu/repos","events_url":"https://api.github.com/users/yifan-gu/events{/privacy}","received_events_url":"https://api.github.com/users/yifan-gu/received_events","type":"User","site_admin":false},"repo":{"id":21830645,"name":"kubernetes","full_name":"yifan-gu/kubernetes","owner":{"login":"yifan-gu","id":3278588,"avatar_url":"https://avatars.githubusercontent.com/u/3278588?v=3","gravatar_id":"","url":"https://api.github.com/users/yifan-gu","html_url":"https://github.com/yifan-gu","followers_url":"https://api.github.com/users/yifan-gu/followers","following_url":"https://api.github.com/users/yifan-gu/following{/other_user}","gists_url":"https://api.github.com/users/yifan-gu/gists{/gist_id}","starred_url":"https://api.github.com/users/yifan-gu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yifan-gu/subscriptions","organizations_url":"https://api.github.com/users/yifan-gu/orgs","repos_url":"https://api.github.com/users/yifan-gu/repos","events_url":"https://api.github.com/users/yifan-gu/events{/privacy}","received_events_url":"https://api.github.com/users/yifan-gu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yifan-gu/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/yifan-gu/kubernetes","forks_url":"https://api.github.com/repos/yifan-gu/kubernetes/forks","keys_url":"https://api.github.com/repos/yifan-gu/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yifan-gu/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yifan-gu/kubernetes/teams","hooks_url":"https://api.github.com/repos/yifan-gu/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/yifan-gu/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/yifan-gu/kubernetes/events","assignees_url":"https://api.github.com/repos/yifan-gu/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/yifan-gu/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/yifan-gu/kubernetes/tags","blobs_url":"https://api.github.com/repos/yifan-gu/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yifan-gu/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yifan-gu/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/yifan-gu/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yifan-gu/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/yifan-gu/kubernetes/languages","stargazers_url":"https://api.github.com/repos/yifan-gu/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/yifan-gu/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/yifan-gu/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/yifan-gu/kubernetes/subscription","commits_url":"https://api.github.com/repos/yifan-gu/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/yifan-gu/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/yifan-gu/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/yifan-gu/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/yifan-gu/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/yifan-gu/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yifan-gu/kubernetes/merges","archive_url":"https://api.github.com/repos/yifan-gu/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yifan-gu/kubernetes/downloads","issues_url":"https://api.github.com/repos/yifan-gu/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/yifan-gu/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/yifan-gu/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/yifan-gu/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yifan-gu/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/yifan-gu/kubernetes/releases{/id}","created_at":"2014-07-14T18:29:14Z","updated_at":"2015-02-12T18:54:51Z","pushed_at":"2015-03-07T00:00:44Z","git_url":"git://github.com/yifan-gu/kubernetes.git","ssh_url":"git@github.com:yifan-gu/kubernetes.git","clone_url":"https://github.com/yifan-gu/kubernetes.git","svn_url":"https://github.com/yifan-gu/kubernetes","homepage":null,"size":32512,"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":"GoogleCloudPlatform:master","ref":"master","sha":"a858c7423e0940f4abb1b9eb9565fc5aafb71451","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","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-07T00:04:26Z","pushed_at":"2015-03-07T00:04:26Z","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":94575,"stargazers_count":6469,"watchers_count":6469,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1154,"mirror_url":null,"open_issues_count":770,"forks":1154,"open_issues":770,"watchers":6469,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5148"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5148"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5148"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5148/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5148/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5148/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/5b67183c1c92ab93b1445af8e408b8b80a101549"}}}}