{"action":"created","comment":{"url":"https://api.github.com/repos/mrunalp/ocid/pulls/comments/72129816","id":72129816,"diff_hunk":"@@ -24,3 +26,66 @@ func getGPRCVersion() (string, error) {\n \t}\n \treturn out, nil\n }\n+\n+func setResourcesCPU(limits, requests float64, g generate.Generator) error {\n+\tif requests > limits {\n+\t\treturn fmt.Errorf(\"CPU.Requests should not be greater than CPU.Limits\")\n+\t}\n+\n+\t// TODO(hmeng): this can be set as a global opt.\n+\t// by default, a pod sandbox is allowed to utilize one CPU core.\n+\tvar cores float64 = 1\n+\n+\tif limits != 0 || requests != 0 {\n+\t\tif limits > requests {\n+\t\t\tcores = limits\n+\t\t} else {\n+\t\t\tcores = requests\n+\t\t}\n+\t}\n+\t// by default, cpu.cfs_period_us is set to be 1000000 (i.e., 1s).\n+\tperiod := uint64(1000000)\n+\tquota := uint64(float64(period) * cores)\n+\n+\t// the lower limit of cpu.cfs_quota_us is 1000.\n+\tif quota < 1000 {\n+\t\tquota = 1000\n+\t}\n+\n+\t// the upper limit of cpu.cfs_quota_us is 1000000.\n+\t// adjust quota and period for the case where multiple CPUs are requested\n+\t// so that cpu.cfs_quota_us <= 1000000.\n+\tfor quota > 1000000 {","path":"server/utils.go","position":42,"original_position":42,"commit_id":"22729327931e6324885b6267a86978dda509cba5","original_commit_id":"22729327931e6324885b6267a86978dda509cba5","user":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"body":"those numbers can be better placed at the beginning of this file with `const` - this may be `CfsQuotaUsMax` for instance","created_at":"2016-07-25T19:38:06Z","updated_at":"2016-07-25T19:38:06Z","html_url":"https://github.com/mrunalp/ocid/pull/17#discussion_r72129816","pull_request_url":"https://api.github.com/repos/mrunalp/ocid/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/mrunalp/ocid/pulls/comments/72129816"},"html":{"href":"https://github.com/mrunalp/ocid/pull/17#discussion_r72129816"},"pull_request":{"href":"https://api.github.com/repos/mrunalp/ocid/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/mrunalp/ocid/pulls/17","id":78729938,"html_url":"https://github.com/mrunalp/ocid/pull/17","diff_url":"https://github.com/mrunalp/ocid/pull/17.diff","patch_url":"https://github.com/mrunalp/ocid/pull/17.patch","issue_url":"https://api.github.com/repos/mrunalp/ocid/issues/17","number":17,"state":"open","locked":false,"title":"set up CPU and Memory resources","user":{"login":"hmeng-19","id":5217421,"avatar_url":"https://avatars.githubusercontent.com/u/5217421?v=3","gravatar_id":"","url":"https://api.github.com/users/hmeng-19","html_url":"https://github.com/hmeng-19","followers_url":"https://api.github.com/users/hmeng-19/followers","following_url":"https://api.github.com/users/hmeng-19/following{/other_user}","gists_url":"https://api.github.com/users/hmeng-19/gists{/gist_id}","starred_url":"https://api.github.com/users/hmeng-19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmeng-19/subscriptions","organizations_url":"https://api.github.com/users/hmeng-19/orgs","repos_url":"https://api.github.com/users/hmeng-19/repos","events_url":"https://api.github.com/users/hmeng-19/events{/privacy}","received_events_url":"https://api.github.com/users/hmeng-19/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Haiyan Meng <hmeng@redhat.com>","created_at":"2016-07-25T18:36:07Z","updated_at":"2016-07-25T19:38:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fe74beb9bb3b9fe98813ccd53ef4723fa893248","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mrunalp/ocid/pulls/17/commits","review_comments_url":"https://api.github.com/repos/mrunalp/ocid/pulls/17/comments","review_comment_url":"https://api.github.com/repos/mrunalp/ocid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mrunalp/ocid/issues/17/comments","statuses_url":"https://api.github.com/repos/mrunalp/ocid/statuses/22729327931e6324885b6267a86978dda509cba5","head":{"label":"hmeng-19:parse_cpu_mem","ref":"parse_cpu_mem","sha":"22729327931e6324885b6267a86978dda509cba5","user":{"login":"hmeng-19","id":5217421,"avatar_url":"https://avatars.githubusercontent.com/u/5217421?v=3","gravatar_id":"","url":"https://api.github.com/users/hmeng-19","html_url":"https://github.com/hmeng-19","followers_url":"https://api.github.com/users/hmeng-19/followers","following_url":"https://api.github.com/users/hmeng-19/following{/other_user}","gists_url":"https://api.github.com/users/hmeng-19/gists{/gist_id}","starred_url":"https://api.github.com/users/hmeng-19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmeng-19/subscriptions","organizations_url":"https://api.github.com/users/hmeng-19/orgs","repos_url":"https://api.github.com/users/hmeng-19/repos","events_url":"https://api.github.com/users/hmeng-19/events{/privacy}","received_events_url":"https://api.github.com/users/hmeng-19/received_events","type":"User","site_admin":false},"repo":{"id":63077486,"name":"ocid","full_name":"hmeng-19/ocid","owner":{"login":"hmeng-19","id":5217421,"avatar_url":"https://avatars.githubusercontent.com/u/5217421?v=3","gravatar_id":"","url":"https://api.github.com/users/hmeng-19","html_url":"https://github.com/hmeng-19","followers_url":"https://api.github.com/users/hmeng-19/followers","following_url":"https://api.github.com/users/hmeng-19/following{/other_user}","gists_url":"https://api.github.com/users/hmeng-19/gists{/gist_id}","starred_url":"https://api.github.com/users/hmeng-19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmeng-19/subscriptions","organizations_url":"https://api.github.com/users/hmeng-19/orgs","repos_url":"https://api.github.com/users/hmeng-19/repos","events_url":"https://api.github.com/users/hmeng-19/events{/privacy}","received_events_url":"https://api.github.com/users/hmeng-19/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hmeng-19/ocid","description":null,"fork":true,"url":"https://api.github.com/repos/hmeng-19/ocid","forks_url":"https://api.github.com/repos/hmeng-19/ocid/forks","keys_url":"https://api.github.com/repos/hmeng-19/ocid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmeng-19/ocid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmeng-19/ocid/teams","hooks_url":"https://api.github.com/repos/hmeng-19/ocid/hooks","issue_events_url":"https://api.github.com/repos/hmeng-19/ocid/issues/events{/number}","events_url":"https://api.github.com/repos/hmeng-19/ocid/events","assignees_url":"https://api.github.com/repos/hmeng-19/ocid/assignees{/user}","branches_url":"https://api.github.com/repos/hmeng-19/ocid/branches{/branch}","tags_url":"https://api.github.com/repos/hmeng-19/ocid/tags","blobs_url":"https://api.github.com/repos/hmeng-19/ocid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmeng-19/ocid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmeng-19/ocid/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmeng-19/ocid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmeng-19/ocid/statuses/{sha}","languages_url":"https://api.github.com/repos/hmeng-19/ocid/languages","stargazers_url":"https://api.github.com/repos/hmeng-19/ocid/stargazers","contributors_url":"https://api.github.com/repos/hmeng-19/ocid/contributors","subscribers_url":"https://api.github.com/repos/hmeng-19/ocid/subscribers","subscription_url":"https://api.github.com/repos/hmeng-19/ocid/subscription","commits_url":"https://api.github.com/repos/hmeng-19/ocid/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmeng-19/ocid/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmeng-19/ocid/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmeng-19/ocid/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmeng-19/ocid/contents/{+path}","compare_url":"https://api.github.com/repos/hmeng-19/ocid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmeng-19/ocid/merges","archive_url":"https://api.github.com/repos/hmeng-19/ocid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmeng-19/ocid/downloads","issues_url":"https://api.github.com/repos/hmeng-19/ocid/issues{/number}","pulls_url":"https://api.github.com/repos/hmeng-19/ocid/pulls{/number}","milestones_url":"https://api.github.com/repos/hmeng-19/ocid/milestones{/number}","notifications_url":"https://api.github.com/repos/hmeng-19/ocid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmeng-19/ocid/labels{/name}","releases_url":"https://api.github.com/repos/hmeng-19/ocid/releases{/id}","deployments_url":"https://api.github.com/repos/hmeng-19/ocid/deployments","created_at":"2016-07-11T15:01:03Z","updated_at":"2016-07-11T15:01:05Z","pushed_at":"2016-07-25T19:19:56Z","git_url":"git://github.com/hmeng-19/ocid.git","ssh_url":"git@github.com:hmeng-19/ocid.git","clone_url":"https://github.com/hmeng-19/ocid.git","svn_url":"https://github.com/hmeng-19/ocid","homepage":null,"size":1374,"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":"mrunalp:master","ref":"master","sha":"8d6f790364437cf6635c17b9f747622d81d77f88","user":{"login":"mrunalp","id":53798,"avatar_url":"https://avatars.githubusercontent.com/u/53798?v=3","gravatar_id":"","url":"https://api.github.com/users/mrunalp","html_url":"https://github.com/mrunalp","followers_url":"https://api.github.com/users/mrunalp/followers","following_url":"https://api.github.com/users/mrunalp/following{/other_user}","gists_url":"https://api.github.com/users/mrunalp/gists{/gist_id}","starred_url":"https://api.github.com/users/mrunalp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrunalp/subscriptions","organizations_url":"https://api.github.com/users/mrunalp/orgs","repos_url":"https://api.github.com/users/mrunalp/repos","events_url":"https://api.github.com/users/mrunalp/events{/privacy}","received_events_url":"https://api.github.com/users/mrunalp/received_events","type":"User","site_admin":false},"repo":{"id":61824137,"name":"ocid","full_name":"mrunalp/ocid","owner":{"login":"mrunalp","id":53798,"avatar_url":"https://avatars.githubusercontent.com/u/53798?v=3","gravatar_id":"","url":"https://api.github.com/users/mrunalp","html_url":"https://github.com/mrunalp","followers_url":"https://api.github.com/users/mrunalp/followers","following_url":"https://api.github.com/users/mrunalp/following{/other_user}","gists_url":"https://api.github.com/users/mrunalp/gists{/gist_id}","starred_url":"https://api.github.com/users/mrunalp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrunalp/subscriptions","organizations_url":"https://api.github.com/users/mrunalp/orgs","repos_url":"https://api.github.com/users/mrunalp/repos","events_url":"https://api.github.com/users/mrunalp/events{/privacy}","received_events_url":"https://api.github.com/users/mrunalp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mrunalp/ocid","description":"ocid","fork":false,"url":"https://api.github.com/repos/mrunalp/ocid","forks_url":"https://api.github.com/repos/mrunalp/ocid/forks","keys_url":"https://api.github.com/repos/mrunalp/ocid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mrunalp/ocid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mrunalp/ocid/teams","hooks_url":"https://api.github.com/repos/mrunalp/ocid/hooks","issue_events_url":"https://api.github.com/repos/mrunalp/ocid/issues/events{/number}","events_url":"https://api.github.com/repos/mrunalp/ocid/events","assignees_url":"https://api.github.com/repos/mrunalp/ocid/assignees{/user}","branches_url":"https://api.github.com/repos/mrunalp/ocid/branches{/branch}","tags_url":"https://api.github.com/repos/mrunalp/ocid/tags","blobs_url":"https://api.github.com/repos/mrunalp/ocid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mrunalp/ocid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mrunalp/ocid/git/refs{/sha}","trees_url":"https://api.github.com/repos/mrunalp/ocid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mrunalp/ocid/statuses/{sha}","languages_url":"https://api.github.com/repos/mrunalp/ocid/languages","stargazers_url":"https://api.github.com/repos/mrunalp/ocid/stargazers","contributors_url":"https://api.github.com/repos/mrunalp/ocid/contributors","subscribers_url":"https://api.github.com/repos/mrunalp/ocid/subscribers","subscription_url":"https://api.github.com/repos/mrunalp/ocid/subscription","commits_url":"https://api.github.com/repos/mrunalp/ocid/commits{/sha}","git_commits_url":"https://api.github.com/repos/mrunalp/ocid/git/commits{/sha}","comments_url":"https://api.github.com/repos/mrunalp/ocid/comments{/number}","issue_comment_url":"https://api.github.com/repos/mrunalp/ocid/issues/comments{/number}","contents_url":"https://api.github.com/repos/mrunalp/ocid/contents/{+path}","compare_url":"https://api.github.com/repos/mrunalp/ocid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mrunalp/ocid/merges","archive_url":"https://api.github.com/repos/mrunalp/ocid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mrunalp/ocid/downloads","issues_url":"https://api.github.com/repos/mrunalp/ocid/issues{/number}","pulls_url":"https://api.github.com/repos/mrunalp/ocid/pulls{/number}","milestones_url":"https://api.github.com/repos/mrunalp/ocid/milestones{/number}","notifications_url":"https://api.github.com/repos/mrunalp/ocid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mrunalp/ocid/labels{/name}","releases_url":"https://api.github.com/repos/mrunalp/ocid/releases{/id}","deployments_url":"https://api.github.com/repos/mrunalp/ocid/deployments","created_at":"2016-06-23T17:31:46Z","updated_at":"2016-07-19T18:24:22Z","pushed_at":"2016-07-25T19:19:57Z","git_url":"git://github.com/mrunalp/ocid.git","ssh_url":"git@github.com:mrunalp/ocid.git","clone_url":"https://github.com/mrunalp/ocid.git","svn_url":"https://github.com/mrunalp/ocid","homepage":"","size":1369,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":4,"forks":4,"open_issues":4,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mrunalp/ocid/pulls/17"},"html":{"href":"https://github.com/mrunalp/ocid/pull/17"},"issue":{"href":"https://api.github.com/repos/mrunalp/ocid/issues/17"},"comments":{"href":"https://api.github.com/repos/mrunalp/ocid/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/mrunalp/ocid/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/mrunalp/ocid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mrunalp/ocid/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/mrunalp/ocid/statuses/22729327931e6324885b6267a86978dda509cba5"}}}}
{"actor":{"display_login":"runcom"}}