{"action":"created","issue":{"url":"https://api.github.com/repos/docker/swarmkit/issues/903","repository_url":"https://api.github.com/repos/docker/swarmkit","labels_url":"https://api.github.com/repos/docker/swarmkit/issues/903/labels{/name}","comments_url":"https://api.github.com/repos/docker/swarmkit/issues/903/comments","events_url":"https://api.github.com/repos/docker/swarmkit/issues/903/events","html_url":"https://github.com/docker/swarmkit/pull/903","id":159557000,"number":903,"title":"reconcile resource in scheduler","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},"labels":[{"url":"https://api.github.com/repos/docker/swarmkit/labels/status/0-triage","name":"status/0-triage","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2016-06-10T04:32:11Z","updated_at":"2016-06-15T17:55:30Z","closed_at":"2016-06-14T20:26:05Z","pull_request":{"url":"https://api.github.com/repos/docker/swarmkit/pulls/903","html_url":"https://github.com/docker/swarmkit/pull/903","diff_url":"https://github.com/docker/swarmkit/pull/903.diff","patch_url":"https://github.com/docker/swarmkit/pull/903.patch"},"body":"in `createOrUpdateNode`, node's resources are reset to the initial value, without checking whether there are some tasks running in the node and reserving resources. This commit fixes the bug.\r\n\r\nHere is an example demonstrating this bug:\r\n\r\n* boot 2 nodes, suppose both's nanocpu resource is 2e9\r\n```\r\n$ swarmd -d /tmp/node-1 --listen-control-api /tmp/manager1/swarm.sock --hostname node-1\r\n$ swarmd -d /tmp/node-2 --hostname node-2 --join-addr 127.0.0.1:4242\r\n```\r\n* run a service, redis, and reserve 0.5 cpu resources\r\n```\r\n$ swarmctl service create --name redis --image redis:3.0.5 --cpu-reservation 0.5\r\n```\r\nredis will be assigned to node-1. node-1 cpu resource will be 1.5 e9\r\n* drain node-1\r\n```\r\n$ swarmctl node drain node-1\r\n```\r\n\r\nwhile there is still a task of redis in node-1 and about to shut down, cpu resource in this node is reset to 2e9. After node-1's task is shut down, it returns reserved resources to node-1, which makes node-1's cpu resource become 2.5 e9\r\n\r\nHowever, I don't think this bug is harmful. Because when we activate node-1 from draining, its cpu resources will be reset to correct value, 2e9, again.\r\n\r\nSigned-off-by: runshenzhu <runshen.zhu@gmail.com>"},"comment":{"url":"https://api.github.com/repos/docker/swarmkit/issues/comments/226267519","html_url":"https://github.com/docker/swarmkit/pull/903#issuecomment-226267519","issue_url":"https://api.github.com/repos/docker/swarmkit/issues/903","id":226267519,"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},"created_at":"2016-06-15T17:55:30Z","updated_at":"2016-06-15T17:55:30Z","body":"@stevvooe yes, I do agree that recalculation is much safer than using pointer. I will send a PR to revert it."}}
{"actor":{"display_login":"runshenzhu"}}