{"action":"created","comment":{"url":"https://api.github.com/repos/kontena/kontena/pulls/comments/132108949","pull_request_review_id":55153721,"id":132108949,"diff_hunk":"@@ -18,7 +23,63 @@ def execute\n \n       notify_grid(self.host_node.grid)\n \n-      self.host_node\n+      # Update availability if given and trigger appropriate actions\n+      if self.availability && self.host_node.availability != self.availability\n+\n+        self.host_node.set(:availability => self.availability)\n+\n+        case self.availability\n+        when HostNode::Availability::ACTIVE\n+          start_stateful_services(self.host_node)\n+          # TODO Should this also trigger full re-scheduling or just wait for the next loop to do it?\n+        when HostNode::Availability::DRAIN\n+          re_deploy_needed_services(self.host_node)\n+          stop_stateful_services(self.host_node)\n+        end\n+      end\n+\n+      self.host_node.reload\n+    end\n+\n+    # Re-deploy needed services, new deployments will filter out evacuated node\n+    def re_deploy_needed_services(host_node)\n+      services = find_services(host_node)\n+      services.each do |service|\n+        GridServiceDeploy.create!(grid_service: service)","path":"server/app/mutations/host_nodes/update.rb","position":43,"original_position":44,"commit_id":"5142eda9381c183214333ee995c5c664dd1e863f","original_commit_id":"a300c2256c8b12cba416f38cc6fda400eb172796","user":{"login":"jnummelin","id":3205505,"avatar_url":"https://avatars0.githubusercontent.com/u/3205505?v=4","gravatar_id":"","url":"https://api.github.com/users/jnummelin","html_url":"https://github.com/jnummelin","followers_url":"https://api.github.com/users/jnummelin/followers","following_url":"https://api.github.com/users/jnummelin/following{/other_user}","gists_url":"https://api.github.com/users/jnummelin/gists{/gist_id}","starred_url":"https://api.github.com/users/jnummelin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnummelin/subscriptions","organizations_url":"https://api.github.com/users/jnummelin/orgs","repos_url":"https://api.github.com/users/jnummelin/repos","events_url":"https://api.github.com/users/jnummelin/events{/privacy}","received_events_url":"https://api.github.com/users/jnummelin/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2017-08-09T07:32:56Z","updated_at":"2017-08-09T07:32:56Z","html_url":"https://github.com/kontena/kontena/pull/2306#discussion_r132108949","pull_request_url":"https://api.github.com/repos/kontena/kontena/pulls/2306","_links":{"self":{"href":"https://api.github.com/repos/kontena/kontena/pulls/comments/132108949"},"html":{"href":"https://github.com/kontena/kontena/pull/2306#discussion_r132108949"},"pull_request":{"href":"https://api.github.com/repos/kontena/kontena/pulls/2306"}}},"pull_request":{"url":"https://api.github.com/repos/kontena/kontena/pulls/2306","id":120252701,"html_url":"https://github.com/kontena/kontena/pull/2306","diff_url":"https://github.com/kontena/kontena/pull/2306.diff","patch_url":"https://github.com/kontena/kontena/pull/2306.patch","issue_url":"https://api.github.com/repos/kontena/kontena/issues/2306","number":2306,"state":"open","locked":false,"title":"Node scheduling availability","user":{"login":"jnummelin","id":3205505,"avatar_url":"https://avatars0.githubusercontent.com/u/3205505?v=4","gravatar_id":"","url":"https://api.github.com/users/jnummelin","html_url":"https://github.com/jnummelin","followers_url":"https://api.github.com/users/jnummelin/followers","following_url":"https://api.github.com/users/jnummelin/following{/other_user}","gists_url":"https://api.github.com/users/jnummelin/gists{/gist_id}","starred_url":"https://api.github.com/users/jnummelin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnummelin/subscriptions","organizations_url":"https://api.github.com/users/jnummelin/orgs","repos_url":"https://api.github.com/users/jnummelin/repos","events_url":"https://api.github.com/users/jnummelin/events{/privacy}","received_events_url":"https://api.github.com/users/jnummelin/received_events","type":"User","site_admin":false},"body":"This PR implements node evacuate functionality.\r\n\r\nWhen a node is evacuated, all stateless services on it will be re-scheduled for other nodes. Stateful services will be stopped if they are running.\r\n\r\nOnce a node is put in evacuate mode with `kontena node update --availability drain xyz`, no services will be deployed onto it. When a node is taken out of evacuate mode by `kontena node update --availability active xyz` it will again be available for service scheduling.\r\n\r\nfixes #1030 \r\n\r\n### Todo\r\n\r\n\r\n- [x] API docs\r\n- [x] Docs","created_at":"2017-05-12T05:49:05Z","updated_at":"2017-08-09T07:32:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05d6c92b5d0010478b8b2204968271ee936287fc","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":{"url":"https://api.github.com/repos/kontena/kontena/milestones/72","html_url":"https://github.com/kontena/kontena/milestone/72","labels_url":"https://api.github.com/repos/kontena/kontena/milestones/72/labels","id":2488399,"number":72,"title":"1.4.0","description":"","creator":{"login":"jakolehm","id":1446224,"avatar_url":"https://avatars0.githubusercontent.com/u/1446224?v=4","gravatar_id":"","url":"https://api.github.com/users/jakolehm","html_url":"https://github.com/jakolehm","followers_url":"https://api.github.com/users/jakolehm/followers","following_url":"https://api.github.com/users/jakolehm/following{/other_user}","gists_url":"https://api.github.com/users/jakolehm/gists{/gist_id}","starred_url":"https://api.github.com/users/jakolehm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakolehm/subscriptions","organizations_url":"https://api.github.com/users/jakolehm/orgs","repos_url":"https://api.github.com/users/jakolehm/repos","events_url":"https://api.github.com/users/jakolehm/events{/privacy}","received_events_url":"https://api.github.com/users/jakolehm/received_events","type":"User","site_admin":false},"open_issues":40,"closed_issues":54,"state":"open","created_at":"2017-04-28T14:51:26Z","updated_at":"2017-08-09T07:23:39Z","due_on":"2017-08-11T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/kontena/kontena/pulls/2306/commits","review_comments_url":"https://api.github.com/repos/kontena/kontena/pulls/2306/comments","review_comment_url":"https://api.github.com/repos/kontena/kontena/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kontena/kontena/issues/2306/comments","statuses_url":"https://api.github.com/repos/kontena/kontena/statuses/5142eda9381c183214333ee995c5c664dd1e863f","head":{"label":"kontena:feature/node-evacuate","ref":"feature/node-evacuate","sha":"5142eda9381c183214333ee995c5c664dd1e863f","user":{"login":"kontena","id":10419574,"avatar_url":"https://avatars2.githubusercontent.com/u/10419574?v=4","gravatar_id":"","url":"https://api.github.com/users/kontena","html_url":"https://github.com/kontena","followers_url":"https://api.github.com/users/kontena/followers","following_url":"https://api.github.com/users/kontena/following{/other_user}","gists_url":"https://api.github.com/users/kontena/gists{/gist_id}","starred_url":"https://api.github.com/users/kontena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kontena/subscriptions","organizations_url":"https://api.github.com/users/kontena/orgs","repos_url":"https://api.github.com/users/kontena/repos","events_url":"https://api.github.com/users/kontena/events{/privacy}","received_events_url":"https://api.github.com/users/kontena/received_events","type":"Organization","site_admin":false},"repo":{"id":32689932,"name":"kontena","full_name":"kontena/kontena","owner":{"login":"kontena","id":10419574,"avatar_url":"https://avatars2.githubusercontent.com/u/10419574?v=4","gravatar_id":"","url":"https://api.github.com/users/kontena","html_url":"https://github.com/kontena","followers_url":"https://api.github.com/users/kontena/followers","following_url":"https://api.github.com/users/kontena/following{/other_user}","gists_url":"https://api.github.com/users/kontena/gists{/gist_id}","starred_url":"https://api.github.com/users/kontena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kontena/subscriptions","organizations_url":"https://api.github.com/users/kontena/orgs","repos_url":"https://api.github.com/users/kontena/repos","events_url":"https://api.github.com/users/kontena/events{/privacy}","received_events_url":"https://api.github.com/users/kontena/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kontena/kontena","description":"The developer friendly container and micro services platform. Works on any cloud, easy to setup, simple to use.","fork":false,"url":"https://api.github.com/repos/kontena/kontena","forks_url":"https://api.github.com/repos/kontena/kontena/forks","keys_url":"https://api.github.com/repos/kontena/kontena/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kontena/kontena/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kontena/kontena/teams","hooks_url":"https://api.github.com/repos/kontena/kontena/hooks","issue_events_url":"https://api.github.com/repos/kontena/kontena/issues/events{/number}","events_url":"https://api.github.com/repos/kontena/kontena/events","assignees_url":"https://api.github.com/repos/kontena/kontena/assignees{/user}","branches_url":"https://api.github.com/repos/kontena/kontena/branches{/branch}","tags_url":"https://api.github.com/repos/kontena/kontena/tags","blobs_url":"https://api.github.com/repos/kontena/kontena/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kontena/kontena/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kontena/kontena/git/refs{/sha}","trees_url":"https://api.github.com/repos/kontena/kontena/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kontena/kontena/statuses/{sha}","languages_url":"https://api.github.com/repos/kontena/kontena/languages","stargazers_url":"https://api.github.com/repos/kontena/kontena/stargazers","contributors_url":"https://api.github.com/repos/kontena/kontena/contributors","subscribers_url":"https://api.github.com/repos/kontena/kontena/subscribers","subscription_url":"https://api.github.com/repos/kontena/kontena/subscription","commits_url":"https://api.github.com/repos/kontena/kontena/commits{/sha}","git_commits_url":"https://api.github.com/repos/kontena/kontena/git/commits{/sha}","comments_url":"https://api.github.com/repos/kontena/kontena/comments{/number}","issue_comment_url":"https://api.github.com/repos/kontena/kontena/issues/comments{/number}","contents_url":"https://api.github.com/repos/kontena/kontena/contents/{+path}","compare_url":"https://api.github.com/repos/kontena/kontena/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kontena/kontena/merges","archive_url":"https://api.github.com/repos/kontena/kontena/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kontena/kontena/downloads","issues_url":"https://api.github.com/repos/kontena/kontena/issues{/number}","pulls_url":"https://api.github.com/repos/kontena/kontena/pulls{/number}","milestones_url":"https://api.github.com/repos/kontena/kontena/milestones{/number}","notifications_url":"https://api.github.com/repos/kontena/kontena/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kontena/kontena/labels{/name}","releases_url":"https://api.github.com/repos/kontena/kontena/releases{/id}","deployments_url":"https://api.github.com/repos/kontena/kontena/deployments","created_at":"2015-03-22T18:52:32Z","updated_at":"2017-08-07T23:39:29Z","pushed_at":"2017-08-09T07:18:56Z","git_url":"git://github.com/kontena/kontena.git","ssh_url":"git@github.com:kontena/kontena.git","clone_url":"https://github.com/kontena/kontena.git","svn_url":"https://github.com/kontena/kontena","homepage":"http://www.kontena.io","size":7363,"stargazers_count":1174,"watchers_count":1174,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":375,"forks":104,"open_issues":375,"watchers":1174,"default_branch":"master"}},"base":{"label":"kontena:master","ref":"master","sha":"13b0b68089d7583c5872545bba5d051a5a783964","user":{"login":"kontena","id":10419574,"avatar_url":"https://avatars2.githubusercontent.com/u/10419574?v=4","gravatar_id":"","url":"https://api.github.com/users/kontena","html_url":"https://github.com/kontena","followers_url":"https://api.github.com/users/kontena/followers","following_url":"https://api.github.com/users/kontena/following{/other_user}","gists_url":"https://api.github.com/users/kontena/gists{/gist_id}","starred_url":"https://api.github.com/users/kontena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kontena/subscriptions","organizations_url":"https://api.github.com/users/kontena/orgs","repos_url":"https://api.github.com/users/kontena/repos","events_url":"https://api.github.com/users/kontena/events{/privacy}","received_events_url":"https://api.github.com/users/kontena/received_events","type":"Organization","site_admin":false},"repo":{"id":32689932,"name":"kontena","full_name":"kontena/kontena","owner":{"login":"kontena","id":10419574,"avatar_url":"https://avatars2.githubusercontent.com/u/10419574?v=4","gravatar_id":"","url":"https://api.github.com/users/kontena","html_url":"https://github.com/kontena","followers_url":"https://api.github.com/users/kontena/followers","following_url":"https://api.github.com/users/kontena/following{/other_user}","gists_url":"https://api.github.com/users/kontena/gists{/gist_id}","starred_url":"https://api.github.com/users/kontena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kontena/subscriptions","organizations_url":"https://api.github.com/users/kontena/orgs","repos_url":"https://api.github.com/users/kontena/repos","events_url":"https://api.github.com/users/kontena/events{/privacy}","received_events_url":"https://api.github.com/users/kontena/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kontena/kontena","description":"The developer friendly container and micro services platform. Works on any cloud, easy to setup, simple to use.","fork":false,"url":"https://api.github.com/repos/kontena/kontena","forks_url":"https://api.github.com/repos/kontena/kontena/forks","keys_url":"https://api.github.com/repos/kontena/kontena/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kontena/kontena/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kontena/kontena/teams","hooks_url":"https://api.github.com/repos/kontena/kontena/hooks","issue_events_url":"https://api.github.com/repos/kontena/kontena/issues/events{/number}","events_url":"https://api.github.com/repos/kontena/kontena/events","assignees_url":"https://api.github.com/repos/kontena/kontena/assignees{/user}","branches_url":"https://api.github.com/repos/kontena/kontena/branches{/branch}","tags_url":"https://api.github.com/repos/kontena/kontena/tags","blobs_url":"https://api.github.com/repos/kontena/kontena/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kontena/kontena/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kontena/kontena/git/refs{/sha}","trees_url":"https://api.github.com/repos/kontena/kontena/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kontena/kontena/statuses/{sha}","languages_url":"https://api.github.com/repos/kontena/kontena/languages","stargazers_url":"https://api.github.com/repos/kontena/kontena/stargazers","contributors_url":"https://api.github.com/repos/kontena/kontena/contributors","subscribers_url":"https://api.github.com/repos/kontena/kontena/subscribers","subscription_url":"https://api.github.com/repos/kontena/kontena/subscription","commits_url":"https://api.github.com/repos/kontena/kontena/commits{/sha}","git_commits_url":"https://api.github.com/repos/kontena/kontena/git/commits{/sha}","comments_url":"https://api.github.com/repos/kontena/kontena/comments{/number}","issue_comment_url":"https://api.github.com/repos/kontena/kontena/issues/comments{/number}","contents_url":"https://api.github.com/repos/kontena/kontena/contents/{+path}","compare_url":"https://api.github.com/repos/kontena/kontena/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kontena/kontena/merges","archive_url":"https://api.github.com/repos/kontena/kontena/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kontena/kontena/downloads","issues_url":"https://api.github.com/repos/kontena/kontena/issues{/number}","pulls_url":"https://api.github.com/repos/kontena/kontena/pulls{/number}","milestones_url":"https://api.github.com/repos/kontena/kontena/milestones{/number}","notifications_url":"https://api.github.com/repos/kontena/kontena/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kontena/kontena/labels{/name}","releases_url":"https://api.github.com/repos/kontena/kontena/releases{/id}","deployments_url":"https://api.github.com/repos/kontena/kontena/deployments","created_at":"2015-03-22T18:52:32Z","updated_at":"2017-08-07T23:39:29Z","pushed_at":"2017-08-09T07:18:56Z","git_url":"git://github.com/kontena/kontena.git","ssh_url":"git@github.com:kontena/kontena.git","clone_url":"https://github.com/kontena/kontena.git","svn_url":"https://github.com/kontena/kontena","homepage":"http://www.kontena.io","size":7363,"stargazers_count":1174,"watchers_count":1174,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":375,"forks":104,"open_issues":375,"watchers":1174,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kontena/kontena/pulls/2306"},"html":{"href":"https://github.com/kontena/kontena/pull/2306"},"issue":{"href":"https://api.github.com/repos/kontena/kontena/issues/2306"},"comments":{"href":"https://api.github.com/repos/kontena/kontena/issues/2306/comments"},"review_comments":{"href":"https://api.github.com/repos/kontena/kontena/pulls/2306/comments"},"review_comment":{"href":"https://api.github.com/repos/kontena/kontena/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kontena/kontena/pulls/2306/commits"},"statuses":{"href":"https://api.github.com/repos/kontena/kontena/statuses/5142eda9381c183214333ee995c5c664dd1e863f"}}}}
{"actor":{"display_login":"jnummelin"}}