{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/39186377","id":39186377,"diff_hunk":"@@ -249,10 +249,15 @@ func limitRequestRatioConstraint(limitType api.LimitType, resourceName api.Resou\n \t\treturn fmt.Errorf(\"%s max limit to request ratio per %s is %s, but no limit is specified or limit is 0.\", resourceName, limitType, enforced.String())\n \t}\n \n-\tobservedValue := observedLimValue / observedReqValue\n+\tobservedRatio := float64(observedLimValue) / float64(observedReqValue)\n+\tmaxLimitRequestRatio := enforced.Value()\n+\tif enforced.Value() <= resource.MaxMilliValue {\n+\t\tobservedRatio = observedRatio * 1000\n+\t\tmaxLimitRequestRatio = enforced.MilliValue()\n+\t}\n \n-\tif observedValue > enforcedValue {\n-\t\treturn fmt.Errorf(\"%s max limit to request ratio per %s is %s, but provided ratio is %d.\", resourceName, limitType, enforced.String(), observedValue)\n+\tif observedRatio > float64(maxLimitRequestRatio) {\n+\t\treturn fmt.Errorf(\"%s max limit to request ratio per %s is %s, but provided ratio is %f.\", resourceName, limitType, enforced.String(), observedRatio)","path":"plugin/pkg/admission/limitranger/admission.go","position":24,"original_position":24,"commit_id":"f7096d4260adcdbcefbe2b076af9c22f5b38d123","original_commit_id":"f7096d4260adcdbcefbe2b076af9c22f5b38d123","user":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"body":"The error message will be wrong since it will be scaled by a factor of 1000.\r\n\r\nUpdate the error message to give the float64(observedLimValue) / float64(observedReqValue) result directly.\r\n\r\nso error would say 10.1 instead of 10100","created_at":"2015-09-10T17:15:53Z","updated_at":"2015-09-10T17:15:53Z","html_url":"https://github.com/kubernetes/kubernetes/pull/13800#discussion_r39186377","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13800","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/39186377"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/13800#discussion_r39186377"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13800"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13800","id":44668748,"html_url":"https://github.com/kubernetes/kubernetes/pull/13800","diff_url":"https://github.com/kubernetes/kubernetes/pull/13800.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/13800.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/13800","number":13800,"state":"open","locked":false,"title":"Fix ratio calculation error in admission controller for LimitRange","user":{"login":"hurf","id":4618015,"avatar_url":"https://avatars.githubusercontent.com/u/4618015?v=3","gravatar_id":"","url":"https://api.github.com/users/hurf","html_url":"https://github.com/hurf","followers_url":"https://api.github.com/users/hurf/followers","following_url":"https://api.github.com/users/hurf/following{/other_user}","gists_url":"https://api.github.com/users/hurf/gists{/gist_id}","starred_url":"https://api.github.com/users/hurf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hurf/subscriptions","organizations_url":"https://api.github.com/users/hurf/orgs","repos_url":"https://api.github.com/users/hurf/repos","events_url":"https://api.github.com/users/hurf/events{/privacy}","received_events_url":"https://api.github.com/users/hurf/received_events","type":"User","site_admin":false},"body":"Fixes: #13799 \r\n\r\nUse float number to calculate ratio, and use same unit to compare\r\nratios.","created_at":"2015-09-10T13:41:54Z","updated_at":"2015-09-10T17:15:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca6611c7f8bc5194324f588bea7c2611d73b5d49","assignee":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13800/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13800/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/13800/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/f7096d4260adcdbcefbe2b076af9c22f5b38d123","head":{"label":"hurf:lr_ratio_admission","ref":"lr_ratio_admission","sha":"f7096d4260adcdbcefbe2b076af9c22f5b38d123","user":{"login":"hurf","id":4618015,"avatar_url":"https://avatars.githubusercontent.com/u/4618015?v=3","gravatar_id":"","url":"https://api.github.com/users/hurf","html_url":"https://github.com/hurf","followers_url":"https://api.github.com/users/hurf/followers","following_url":"https://api.github.com/users/hurf/following{/other_user}","gists_url":"https://api.github.com/users/hurf/gists{/gist_id}","starred_url":"https://api.github.com/users/hurf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hurf/subscriptions","organizations_url":"https://api.github.com/users/hurf/orgs","repos_url":"https://api.github.com/users/hurf/repos","events_url":"https://api.github.com/users/hurf/events{/privacy}","received_events_url":"https://api.github.com/users/hurf/received_events","type":"User","site_admin":false},"repo":{"id":32061334,"name":"kubernetes","full_name":"hurf/kubernetes","owner":{"login":"hurf","id":4618015,"avatar_url":"https://avatars.githubusercontent.com/u/4618015?v=3","gravatar_id":"","url":"https://api.github.com/users/hurf","html_url":"https://github.com/hurf","followers_url":"https://api.github.com/users/hurf/followers","following_url":"https://api.github.com/users/hurf/following{/other_user}","gists_url":"https://api.github.com/users/hurf/gists{/gist_id}","starred_url":"https://api.github.com/users/hurf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hurf/subscriptions","organizations_url":"https://api.github.com/users/hurf/orgs","repos_url":"https://api.github.com/users/hurf/repos","events_url":"https://api.github.com/users/hurf/events{/privacy}","received_events_url":"https://api.github.com/users/hurf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hurf/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/hurf/kubernetes","forks_url":"https://api.github.com/repos/hurf/kubernetes/forks","keys_url":"https://api.github.com/repos/hurf/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hurf/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hurf/kubernetes/teams","hooks_url":"https://api.github.com/repos/hurf/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/hurf/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/hurf/kubernetes/events","assignees_url":"https://api.github.com/repos/hurf/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/hurf/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/hurf/kubernetes/tags","blobs_url":"https://api.github.com/repos/hurf/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hurf/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hurf/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/hurf/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hurf/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/hurf/kubernetes/languages","stargazers_url":"https://api.github.com/repos/hurf/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/hurf/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/hurf/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/hurf/kubernetes/subscription","commits_url":"https://api.github.com/repos/hurf/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/hurf/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/hurf/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/hurf/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/hurf/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/hurf/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hurf/kubernetes/merges","archive_url":"https://api.github.com/repos/hurf/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hurf/kubernetes/downloads","issues_url":"https://api.github.com/repos/hurf/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/hurf/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/hurf/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/hurf/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hurf/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/hurf/kubernetes/releases{/id}","created_at":"2015-03-12T06:40:47Z","updated_at":"2015-05-08T10:52:15Z","pushed_at":"2015-09-10T13:41:26Z","git_url":"git://github.com/hurf/kubernetes.git","ssh_url":"git@github.com:hurf/kubernetes.git","clone_url":"https://github.com/hurf/kubernetes.git","svn_url":"https://github.com/hurf/kubernetes","homepage":"http://kubernetes.io","size":103878,"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":"6a5049f09d8668d70d21b1fffd0d876caf2cd8ed","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}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-09-10T15:49:55Z","pushed_at":"2015-09-10T17:15:46Z","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":402099,"stargazers_count":10173,"watchers_count":10173,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2494,"mirror_url":null,"open_issues_count":1743,"forks":2494,"open_issues":1743,"watchers":10173,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13800"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/13800"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/13800"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/13800/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13800/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13800/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/f7096d4260adcdbcefbe2b076af9c22f5b38d123"}}}}