{"action":"created","comment":{"url":"https://api.github.com/repos/docker/swarmkit/pulls/comments/66534679","id":66534679,"diff_hunk":"@@ -235,14 +235,14 @@ func (c *containerConfig) resources() enginecontainer.Resources {\n \t\treturn resources\n \t}\n \n-\tif r.Limits.MemoryBytes > 0 {\n-\t\tresources.Memory = r.Limits.MemoryBytes\n+\tif v, ok := r.Limits.ScalarResources[api.MemoryBytes.String()]; ok {\n+\t\tresources.Memory = int64(v)\n \t}\n \n-\tif r.Limits.NanoCPUs > 0 {\n-\t\t// CPU Period must be set in microseconds.\n+\tif v, ok := r.Limits.ScalarResources[api.NanoCPUs.String()]; ok {\n+\t\tresources.Memory = int64(v)","path":"agent/exec/container/container.go","position":13,"original_position":13,"commit_id":"430baf3b6ce0a7752a2c384608394354d9df5b87","original_commit_id":"430baf3b6ce0a7752a2c384608394354d9df5b87","user":{"login":"dongluochen","id":14985073,"avatar_url":"https://avatars.githubusercontent.com/u/14985073?v=3","gravatar_id":"","url":"https://api.github.com/users/dongluochen","html_url":"https://github.com/dongluochen","followers_url":"https://api.github.com/users/dongluochen/followers","following_url":"https://api.github.com/users/dongluochen/following{/other_user}","gists_url":"https://api.github.com/users/dongluochen/gists{/gist_id}","starred_url":"https://api.github.com/users/dongluochen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongluochen/subscriptions","organizations_url":"https://api.github.com/users/dongluochen/orgs","repos_url":"https://api.github.com/users/dongluochen/repos","events_url":"https://api.github.com/users/dongluochen/events{/privacy}","received_events_url":"https://api.github.com/users/dongluochen/received_events","type":"User","site_admin":false},"body":"Memory?","created_at":"2016-06-09T22:39:24Z","updated_at":"2016-06-09T22:39:24Z","html_url":"https://github.com/docker/swarmkit/pull/894#discussion_r66534679","pull_request_url":"https://api.github.com/repos/docker/swarmkit/pulls/894","_links":{"self":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/comments/66534679"},"html":{"href":"https://github.com/docker/swarmkit/pull/894#discussion_r66534679"},"pull_request":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/894"}}},"pull_request":{"url":"https://api.github.com/repos/docker/swarmkit/pulls/894","id":73277227,"html_url":"https://github.com/docker/swarmkit/pull/894","diff_url":"https://github.com/docker/swarmkit/pull/894.diff","patch_url":"https://github.com/docker/swarmkit/pull/894.patch","issue_url":"https://api.github.com/repos/docker/swarmkit/issues/894","number":894,"state":"open","locked":false,"title":"[WIP] abstract resources","user":{"login":"runshenzhu","id":7114218,"avatar_url":"https://avatars.githubusercontent.com/u/7114218?v=3","gravatar_id":"","url":"https://api.github.com/users/runshenzhu","html_url":"https://github.com/runshenzhu","followers_url":"https://api.github.com/users/runshenzhu/followers","following_url":"https://api.github.com/users/runshenzhu/following{/other_user}","gists_url":"https://api.github.com/users/runshenzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/runshenzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runshenzhu/subscriptions","organizations_url":"https://api.github.com/users/runshenzhu/orgs","repos_url":"https://api.github.com/users/runshenzhu/repos","events_url":"https://api.github.com/users/runshenzhu/events{/privacy}","received_events_url":"https://api.github.com/users/runshenzhu/received_events","type":"User","site_admin":false},"body":"In Swarm-v1 users have been asking to support arbitrary resources, see [docker/swarm#2223](https://github.com/docker/swarm/issues/2223)\r\n\r\n[#594](https://github.com/docker/swarmkit/issues/594) talks about how to implement abstracted resources in swarmkit. This PR is the implementation.\r\n\r\nexample:\r\n\r\n* boot a node, which offers 2 user-defined resources: disk and gpu\r\n\r\n```\r\n# pre-defined resources, such as cpu and memory, will be auto-detected\r\n$ swarmd node .... --hostname node-1 --resources disk=512 --resources gpu=10\r\n```\r\n\r\n* create service and specify resources\r\n\r\n```\r\nswarmctl service create --name redis --image redis:3.0.5 --reservation cpu=0.5 --reservation gpu=1 --limit memory=512m\r\n```\r\n\r\n* inspect node-1\r\n\r\n```\r\n$ swarmctl node inspect node-1\r\n# Resources section would be as follows\r\n....\r\nResources:\r\n  Memory                  : 2.0 GiB\r\n  disk                    : 512\r\n  gpu                     : 10\r\n  CPUs                    : 2\r\n....\r\n```\r\n* inspect service redis\r\n\r\n```\r\n$ swarmctl svc inspect redis\r\n# Resources section would be as follows\r\n....\r\nResources\r\n    Reservations:\r\n      gpu                : 1\r\n      CPU                : 0.5\r\n    Limits:\r\n      Memory             : 512 MiB\r\n....\r\n```\r\n\r\n\r\n\r\nSigned-off-by: runshenzhu <runshen.zhu@gmail.com>","created_at":"2016-06-09T20:08:13Z","updated_at":"2016-06-09T22:39:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f37f25fcf805fca62d7a0457152b3c2920bd284","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/swarmkit/pulls/894/commits","review_comments_url":"https://api.github.com/repos/docker/swarmkit/pulls/894/comments","review_comment_url":"https://api.github.com/repos/docker/swarmkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/swarmkit/issues/894/comments","statuses_url":"https://api.github.com/repos/docker/swarmkit/statuses/430baf3b6ce0a7752a2c384608394354d9df5b87","head":{"label":"runshenzhu:abstract_resources","ref":"abstract_resources","sha":"430baf3b6ce0a7752a2c384608394354d9df5b87","user":{"login":"runshenzhu","id":7114218,"avatar_url":"https://avatars.githubusercontent.com/u/7114218?v=3","gravatar_id":"","url":"https://api.github.com/users/runshenzhu","html_url":"https://github.com/runshenzhu","followers_url":"https://api.github.com/users/runshenzhu/followers","following_url":"https://api.github.com/users/runshenzhu/following{/other_user}","gists_url":"https://api.github.com/users/runshenzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/runshenzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runshenzhu/subscriptions","organizations_url":"https://api.github.com/users/runshenzhu/orgs","repos_url":"https://api.github.com/users/runshenzhu/repos","events_url":"https://api.github.com/users/runshenzhu/events{/privacy}","received_events_url":"https://api.github.com/users/runshenzhu/received_events","type":"User","site_admin":false},"repo":{"id":60800342,"name":"swarmkit","full_name":"runshenzhu/swarmkit","owner":{"login":"runshenzhu","id":7114218,"avatar_url":"https://avatars.githubusercontent.com/u/7114218?v=3","gravatar_id":"","url":"https://api.github.com/users/runshenzhu","html_url":"https://github.com/runshenzhu","followers_url":"https://api.github.com/users/runshenzhu/followers","following_url":"https://api.github.com/users/runshenzhu/following{/other_user}","gists_url":"https://api.github.com/users/runshenzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/runshenzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runshenzhu/subscriptions","organizations_url":"https://api.github.com/users/runshenzhu/orgs","repos_url":"https://api.github.com/users/runshenzhu/repos","events_url":"https://api.github.com/users/runshenzhu/events{/privacy}","received_events_url":"https://api.github.com/users/runshenzhu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/runshenzhu/swarmkit","description":"A toolkit for orchestrating distributed systems at any scale. It includes primitives for node discovery, raft-based consensus, task scheduling and more.","fork":true,"url":"https://api.github.com/repos/runshenzhu/swarmkit","forks_url":"https://api.github.com/repos/runshenzhu/swarmkit/forks","keys_url":"https://api.github.com/repos/runshenzhu/swarmkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runshenzhu/swarmkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runshenzhu/swarmkit/teams","hooks_url":"https://api.github.com/repos/runshenzhu/swarmkit/hooks","issue_events_url":"https://api.github.com/repos/runshenzhu/swarmkit/issues/events{/number}","events_url":"https://api.github.com/repos/runshenzhu/swarmkit/events","assignees_url":"https://api.github.com/repos/runshenzhu/swarmkit/assignees{/user}","branches_url":"https://api.github.com/repos/runshenzhu/swarmkit/branches{/branch}","tags_url":"https://api.github.com/repos/runshenzhu/swarmkit/tags","blobs_url":"https://api.github.com/repos/runshenzhu/swarmkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runshenzhu/swarmkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runshenzhu/swarmkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/runshenzhu/swarmkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runshenzhu/swarmkit/statuses/{sha}","languages_url":"https://api.github.com/repos/runshenzhu/swarmkit/languages","stargazers_url":"https://api.github.com/repos/runshenzhu/swarmkit/stargazers","contributors_url":"https://api.github.com/repos/runshenzhu/swarmkit/contributors","subscribers_url":"https://api.github.com/repos/runshenzhu/swarmkit/subscribers","subscription_url":"https://api.github.com/repos/runshenzhu/swarmkit/subscription","commits_url":"https://api.github.com/repos/runshenzhu/swarmkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/runshenzhu/swarmkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/runshenzhu/swarmkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/runshenzhu/swarmkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/runshenzhu/swarmkit/contents/{+path}","compare_url":"https://api.github.com/repos/runshenzhu/swarmkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runshenzhu/swarmkit/merges","archive_url":"https://api.github.com/repos/runshenzhu/swarmkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runshenzhu/swarmkit/downloads","issues_url":"https://api.github.com/repos/runshenzhu/swarmkit/issues{/number}","pulls_url":"https://api.github.com/repos/runshenzhu/swarmkit/pulls{/number}","milestones_url":"https://api.github.com/repos/runshenzhu/swarmkit/milestones{/number}","notifications_url":"https://api.github.com/repos/runshenzhu/swarmkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runshenzhu/swarmkit/labels{/name}","releases_url":"https://api.github.com/repos/runshenzhu/swarmkit/releases{/id}","deployments_url":"https://api.github.com/repos/runshenzhu/swarmkit/deployments","created_at":"2016-06-09T19:14:11Z","updated_at":"2016-06-09T19:14:13Z","pushed_at":"2016-06-09T20:29:50Z","git_url":"git://github.com/runshenzhu/swarmkit.git","ssh_url":"git@github.com:runshenzhu/swarmkit.git","clone_url":"https://github.com/runshenzhu/swarmkit.git","svn_url":"https://github.com/runshenzhu/swarmkit","homepage":"","size":7149,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"docker:master","ref":"master","sha":"323a67340346d21301c73223ca7cd4e829c14519","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":51556828,"name":"swarmkit","full_name":"docker/swarmkit","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/swarmkit","description":"A toolkit for orchestrating distributed systems at any scale. It includes primitives for node discovery, raft-based consensus, task scheduling and more.","fork":false,"url":"https://api.github.com/repos/docker/swarmkit","forks_url":"https://api.github.com/repos/docker/swarmkit/forks","keys_url":"https://api.github.com/repos/docker/swarmkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/swarmkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/swarmkit/teams","hooks_url":"https://api.github.com/repos/docker/swarmkit/hooks","issue_events_url":"https://api.github.com/repos/docker/swarmkit/issues/events{/number}","events_url":"https://api.github.com/repos/docker/swarmkit/events","assignees_url":"https://api.github.com/repos/docker/swarmkit/assignees{/user}","branches_url":"https://api.github.com/repos/docker/swarmkit/branches{/branch}","tags_url":"https://api.github.com/repos/docker/swarmkit/tags","blobs_url":"https://api.github.com/repos/docker/swarmkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/swarmkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/swarmkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/swarmkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/swarmkit/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/swarmkit/languages","stargazers_url":"https://api.github.com/repos/docker/swarmkit/stargazers","contributors_url":"https://api.github.com/repos/docker/swarmkit/contributors","subscribers_url":"https://api.github.com/repos/docker/swarmkit/subscribers","subscription_url":"https://api.github.com/repos/docker/swarmkit/subscription","commits_url":"https://api.github.com/repos/docker/swarmkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/swarmkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/swarmkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/swarmkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/swarmkit/contents/{+path}","compare_url":"https://api.github.com/repos/docker/swarmkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/swarmkit/merges","archive_url":"https://api.github.com/repos/docker/swarmkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/swarmkit/downloads","issues_url":"https://api.github.com/repos/docker/swarmkit/issues{/number}","pulls_url":"https://api.github.com/repos/docker/swarmkit/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/swarmkit/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/swarmkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/swarmkit/labels{/name}","releases_url":"https://api.github.com/repos/docker/swarmkit/releases{/id}","deployments_url":"https://api.github.com/repos/docker/swarmkit/deployments","created_at":"2016-02-12T00:02:15Z","updated_at":"2016-06-09T21:50:49Z","pushed_at":"2016-06-09T20:08:14Z","git_url":"git://github.com/docker/swarmkit.git","ssh_url":"git@github.com:docker/swarmkit.git","clone_url":"https://github.com/docker/swarmkit.git","svn_url":"https://github.com/docker/swarmkit","homepage":"","size":16947,"stargazers_count":380,"watchers_count":380,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":127,"forks":55,"open_issues":127,"watchers":380,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/894"},"html":{"href":"https://github.com/docker/swarmkit/pull/894"},"issue":{"href":"https://api.github.com/repos/docker/swarmkit/issues/894"},"comments":{"href":"https://api.github.com/repos/docker/swarmkit/issues/894/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/894/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/swarmkit/pulls/894/commits"},"statuses":{"href":"https://api.github.com/repos/docker/swarmkit/statuses/430baf3b6ce0a7752a2c384608394354d9df5b87"}}}}
{"actor":{"display_login":"dongluochen"}}