{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/83859074","pull_request_review_id":4673832,"id":83859074,"diff_hunk":"@@ -496,37 +496,81 @@ func GetTaintsFromNodeAnnotations(annotations map[string]string) ([]Taint, error\n }\n \n // TolerationToleratesTaint checks if the toleration tolerates the taint.\n-func TolerationToleratesTaint(toleration *Toleration, taint *Taint) bool {\n-\tif len(toleration.Effect) != 0 && toleration.Effect != taint.Effect {\n+func (t *Toleration) ToleratesTaint(taint *Taint) bool {\n+\tif len(t.Effect) != 0 && t.Effect != taint.Effect {\n \t\treturn false\n \t}\n \n-\tif toleration.Key != taint.Key {\n+\tif t.Key != taint.Key {\n \t\treturn false\n \t}\n-\t// TODO: Use proper defaulting when Toleration becomes a field of PodSpec\n-\tif (len(toleration.Operator) == 0 || toleration.Operator == TolerationOpEqual) && toleration.Value == taint.Value {\n-\t\treturn true\n+\n+\t// check forgivenessSeconds time out\n+\tif t.ForgivenessSeconds != nil {\n+\t\t// taint with no added time indicated can only be tolerated\n+\t\t// by toleration with no forgivenessSeconds.\n+\t\tif taint.AddedTime.IsZero() {\n+\t\t\treturn false\n+\t\t}\n+\t\tif unversioned.Now().After(taint.AddedTime.Add(time.Second * time.Duration(*t.ForgivenessSeconds))) {\n+\t\t\treturn false\n+\t\t}\n \t}\n-\tif toleration.Operator == TolerationOpExists {\n+\n+\t// TODO: Use proper defaulting when Toleration becomes a field of PodSpec\n+\tswitch t.Operator {\n+\tcase \"\", TolerationOpEqual:\n+\t\treturn t.Value == taint.Value\n+\tcase TolerationOpExists:\n \t\treturn true\n+\tdefault:\n+\t\treturn false\n \t}\n-\treturn false\n-\n }\n \n-// TaintToleratedByTolerations checks if taint is tolerated by any of the tolerations.\n-func TaintToleratedByTolerations(taint *Taint, tolerations []Toleration) bool {\n+// TolerationsTolerateTaint checks if taint is tolerated by any of the tolerations.\n+func TolerationsTolerateTaint(tolerations []Toleration, taint *Taint) bool {\n \ttolerated := false\n \tfor i := range tolerations {\n-\t\tif TolerationToleratesTaint(&tolerations[i], taint) {\n+\t\tif tolerations[i].ToleratesTaint(taint) {\n \t\t\ttolerated = true\n \t\t\tbreak\n \t\t}\n \t}\n \treturn tolerated\n }\n \n+type taintsFilterFunc func(Taint) bool","path":"pkg/api/helpers.go","position":60,"original_position":60,"commit_id":"04fa9c8f35a4251129fbde4331c8024355483981","original_commit_id":"04fa9c8f35a4251129fbde4331c8024355483981","user":{"login":"gmarek","id":1703842,"avatar_url":"https://avatars.githubusercontent.com/u/1703842?v=3","gravatar_id":"","url":"https://api.github.com/users/gmarek","html_url":"https://github.com/gmarek","followers_url":"https://api.github.com/users/gmarek/followers","following_url":"https://api.github.com/users/gmarek/following{/other_user}","gists_url":"https://api.github.com/users/gmarek/gists{/gist_id}","starred_url":"https://api.github.com/users/gmarek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmarek/subscriptions","organizations_url":"https://api.github.com/users/gmarek/orgs","repos_url":"https://api.github.com/users/gmarek/repos","events_url":"https://api.github.com/users/gmarek/events{/privacy}","received_events_url":"https://api.github.com/users/gmarek/received_events","type":"User","site_admin":false},"body":"Other topic than above, but it's github... - you probably can go with *Taint and avoid unnecessary copies.","created_at":"2016-10-18T13:56:18Z","updated_at":"2016-10-18T13:56:18Z","html_url":"https://github.com/kubernetes/kubernetes/pull/34825#discussion_r83859074","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34825","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/83859074"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/34825#discussion_r83859074"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34825"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34825","id":89393956,"html_url":"https://github.com/kubernetes/kubernetes/pull/34825","diff_url":"https://github.com/kubernetes/kubernetes/pull/34825.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/34825.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34825","number":34825,"state":"open","locked":false,"title":"WIP: implement forgiveness phase 1","user":{"login":"kevin-wangzefeng","id":6914660,"avatar_url":"https://avatars.githubusercontent.com/u/6914660?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-wangzefeng","html_url":"https://github.com/kevin-wangzefeng","followers_url":"https://api.github.com/users/kevin-wangzefeng/followers","following_url":"https://api.github.com/users/kevin-wangzefeng/following{/other_user}","gists_url":"https://api.github.com/users/kevin-wangzefeng/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-wangzefeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-wangzefeng/subscriptions","organizations_url":"https://api.github.com/users/kevin-wangzefeng/orgs","repos_url":"https://api.github.com/users/kevin-wangzefeng/repos","events_url":"https://api.github.com/users/kevin-wangzefeng/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-wangzefeng/received_events","type":"User","site_admin":false},"body":"**Why**:  \r\nThis PR is to implement forgiveness phase 1 and features it depends. \r\nRelated issue: #1574\r\nRefreshes Implementation: #30191, also incorporates #32498\r\n\r\n**What changes made in this PR**:  \r\n\r\n1. [x] update toleration api types to support forgiveness, added a new field `forgivenessSeconds` to indicate the duration of time it tolerates a taint.\r\n2. [x] update taint api types, added a new field to indicate the time the taint is added.\r\n3. [x] automatically add taint `notready:NoExecute` with timestamp to a node when it goes not ready, and remove it when it turns ready.\r\n4. [x] automatically add taint `unreachable:NoExecute` with timestamp to a node when it becomes unknown, and remove it when it turns back ready.\r\n5. [x] periodically check taints of a node and pods running on it, evict those not tolerate NoExecute taints. \r\n6. [x] make taints-tolerations matching respect timestamps, useful in forgiveness cases.\r\n7. [ ] make tolerations respect wildcard key\r\n8. [ ] add a new admission-controller to set default forgiveness toleration for pods (that has no forgiveness tolerations) to tolerate taints `notready:NoExecute` and `unreachable:NoExecute` for 5 minutes.\r\n\r\n**Release note**:\r\n<!--  Steps to write your release note:\r\n1. Use the release-note-* labels to set the release note state (if you have access) \r\n2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`. \r\n-->\r\n```release-note\r\nimplement forgiveness alpha verion \r\nsupports taint based pod eviction at runtime\r\n```\r\n\r\n<!-- Reviewable:start -->\r\n---\r\nThis change is [<img src=\"https://reviewable.kubernetes.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.kubernetes.io/reviews/kubernetes/kubernetes/34825)\r\n<!-- Reviewable:end -->\r\n","created_at":"2016-10-14T14:25:46Z","updated_at":"2016-10-18T13:56:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8584f9b340a34c0e60d1f00b270b16b69dbce169","assignee":{"login":"davidopp","id":8264113,"avatar_url":"https://avatars.githubusercontent.com/u/8264113?v=3","gravatar_id":"","url":"https://api.github.com/users/davidopp","html_url":"https://github.com/davidopp","followers_url":"https://api.github.com/users/davidopp/followers","following_url":"https://api.github.com/users/davidopp/following{/other_user}","gists_url":"https://api.github.com/users/davidopp/gists{/gist_id}","starred_url":"https://api.github.com/users/davidopp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidopp/subscriptions","organizations_url":"https://api.github.com/users/davidopp/orgs","repos_url":"https://api.github.com/users/davidopp/repos","events_url":"https://api.github.com/users/davidopp/events{/privacy}","received_events_url":"https://api.github.com/users/davidopp/received_events","type":"User","site_admin":false},"assignees":[{"login":"davidopp","id":8264113,"avatar_url":"https://avatars.githubusercontent.com/u/8264113?v=3","gravatar_id":"","url":"https://api.github.com/users/davidopp","html_url":"https://github.com/davidopp","followers_url":"https://api.github.com/users/davidopp/followers","following_url":"https://api.github.com/users/davidopp/following{/other_user}","gists_url":"https://api.github.com/users/davidopp/gists{/gist_id}","starred_url":"https://api.github.com/users/davidopp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidopp/subscriptions","organizations_url":"https://api.github.com/users/davidopp/orgs","repos_url":"https://api.github.com/users/davidopp/repos","events_url":"https://api.github.com/users/davidopp/events{/privacy}","received_events_url":"https://api.github.com/users/davidopp/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34825/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34825/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34825/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/04fa9c8f35a4251129fbde4331c8024355483981","head":{"label":"kevin-wangzefeng:feature_forgiveness","ref":"feature_forgiveness","sha":"04fa9c8f35a4251129fbde4331c8024355483981","user":{"login":"kevin-wangzefeng","id":6914660,"avatar_url":"https://avatars.githubusercontent.com/u/6914660?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-wangzefeng","html_url":"https://github.com/kevin-wangzefeng","followers_url":"https://api.github.com/users/kevin-wangzefeng/followers","following_url":"https://api.github.com/users/kevin-wangzefeng/following{/other_user}","gists_url":"https://api.github.com/users/kevin-wangzefeng/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-wangzefeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-wangzefeng/subscriptions","organizations_url":"https://api.github.com/users/kevin-wangzefeng/orgs","repos_url":"https://api.github.com/users/kevin-wangzefeng/repos","events_url":"https://api.github.com/users/kevin-wangzefeng/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-wangzefeng/received_events","type":"User","site_admin":false},"repo":{"id":40229810,"name":"kubernetes","full_name":"kevin-wangzefeng/kubernetes","owner":{"login":"kevin-wangzefeng","id":6914660,"avatar_url":"https://avatars.githubusercontent.com/u/6914660?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-wangzefeng","html_url":"https://github.com/kevin-wangzefeng","followers_url":"https://api.github.com/users/kevin-wangzefeng/followers","following_url":"https://api.github.com/users/kevin-wangzefeng/following{/other_user}","gists_url":"https://api.github.com/users/kevin-wangzefeng/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-wangzefeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-wangzefeng/subscriptions","organizations_url":"https://api.github.com/users/kevin-wangzefeng/orgs","repos_url":"https://api.github.com/users/kevin-wangzefeng/repos","events_url":"https://api.github.com/users/kevin-wangzefeng/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-wangzefeng/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kevin-wangzefeng/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes","forks_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/forks","keys_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/teams","hooks_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/events","assignees_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/tags","blobs_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/languages","stargazers_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/subscription","commits_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/merges","archive_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/downloads","issues_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/kevin-wangzefeng/kubernetes/deployments","created_at":"2015-08-05T06:55:22Z","updated_at":"2016-02-05T08:27:33Z","pushed_at":"2016-10-18T08:10:03Z","git_url":"git://github.com/kevin-wangzefeng/kubernetes.git","ssh_url":"git@github.com:kevin-wangzefeng/kubernetes.git","clone_url":"https://github.com/kevin-wangzefeng/kubernetes.git","svn_url":"https://github.com/kevin-wangzefeng/kubernetes","homepage":"http://kubernetes.io","size":333081,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"928b8cbdb85e08da245ed608142b4ef061a9ea26","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":"Production-Grade Container Scheduling and Management","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-10-18T13:41:52Z","pushed_at":"2016-10-18T13:54:56Z","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":596894,"stargazers_count":17685,"watchers_count":17685,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5737,"mirror_url":null,"open_issues_count":4934,"forks":5737,"open_issues":4934,"watchers":17685,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34825"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/34825"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/34825"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/34825/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34825/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/34825/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/04fa9c8f35a4251129fbde4331c8024355483981"}}}}
{"actor":{"display_login":"gmarek"}}