{"action":"created","comment":{"url":"https://api.github.com/repos/rancher/agent/pulls/comments/73933478","id":73933478,"diff_hunk":"@@ -1,45 +1,142 @@\n package handlers\n \n import (\n+\t\"encoding/json\"\n \t\"github.com/Sirupsen/logrus\"\n-\t\"github.com/rancher/agent/handlers/dockerClient\"\n+\t\"github.com/mitchellh/mapstructure\"\n+\t\"github.com/rancher/agent/handlers/docker\"\n \t\"github.com/rancher/agent/handlers/progress\"\n \t\"github.com/rancher/agent/handlers/utils\"\n \t\"github.com/rancher/agent/model\"\n \trevents \"github.com/rancher/go-machine-service/events\"\n \t\"github.com/rancher/go-rancher/client\"\n-\t\"sync\"\n )\n \n-type InstanceWithLock struct {\n-\tmu sync.Mutex\n-\tin *model.Instance\n-}\n-\n func InstanceActivate(event *revents.Event, cli *client.RancherClient) error {\n \tlogrus.Infof(\"Received event: Name: %s, Event Id: %s, Resource Id: %s\", event.Name, event.ID, event.ResourceID)\n \tinstance, host := utils.GetInstanceAndHost(event)\n \n-\tprogress := progress.Progress{}\n+\tprogress := progress.Progress{Request: event, Client: cli}\n \n-\tif instance != nil {\n-\t\tprocessData, ok := event.Data[\"processData\"]\n-\t\tif ok {\n-\t\t\tinstance.ProcessData = processData.(map[string]interface{})\n-\t\t}\n+\tif processData, ok := event.Data[\"processData\"]; ok && instance != nil {\n+\t\tinstance.ProcessData = processData.(map[string]interface{})\n+\t}\n+\tif utils.IsNoOp(event.Data) {\n+\t\tutils.RecordState(docker.GetClient(utils.DefaultVersion), instance, \"\")\n+\t\treturn reply(utils.GetResponseData(event), event, cli)\n \t}\n \n-\tinsWithLock := InstanceWithLock{mu: sync.Mutex{}, in: instance}\n-\tinsWithLock.mu.Lock()\n-\tdefer insWithLock.mu.Unlock()\n-\tif utils.IsInstanceActive(insWithLock.in, host) {\n+\tif utils.IsInstanceActive(instance, host) {\n \t\tlogrus.Info(\"instance is activated\")\n-\t\tutils.RecordState(dockerClient.GetClient(utils.DefaultVersion), instance, \"\")\n-\t\treturn reply(event.Data, utils.GetResponseData(event, event.Data), cli)\n+\t\tutils.RecordState(docker.GetClient(utils.DefaultVersion), instance, \"\")\n+\t\treturn reply(utils.GetResponseData(event), event, cli)\n \t}\n \n \tutils.DoInstanceActivate(instance, host, &progress)","path":"handlers/compute.go","position":54,"original_position":54,"commit_id":"dbc6f53711a8bc9fea4ad0f2aec0776a0122a8e5","original_commit_id":"dbc6f53711a8bc9fea4ad0f2aec0776a0122a8e5","user":{"login":"cjellick","id":2473240,"avatar_url":"https://avatars.githubusercontent.com/u/2473240?v=3","gravatar_id":"","url":"https://api.github.com/users/cjellick","html_url":"https://github.com/cjellick","followers_url":"https://api.github.com/users/cjellick/followers","following_url":"https://api.github.com/users/cjellick/following{/other_user}","gists_url":"https://api.github.com/users/cjellick/gists{/gist_id}","starred_url":"https://api.github.com/users/cjellick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjellick/subscriptions","organizations_url":"https://api.github.com/users/cjellick/orgs","repos_url":"https://api.github.com/users/cjellick/repos","events_url":"https://api.github.com/users/cjellick/events{/privacy}","received_events_url":"https://api.github.com/users/cjellick/received_events","type":"User","site_admin":false},"body":"It doesn't make much sense to me that DoInstanceActivate is in a utils package. It isn't a re-used utility function. It is only used in this specific context. What was your motivation for putting it in the utils package?","created_at":"2016-08-08T18:58:57Z","updated_at":"2016-08-08T18:58:57Z","html_url":"https://github.com/rancher/agent/pull/11#discussion_r73933478","pull_request_url":"https://api.github.com/repos/rancher/agent/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/rancher/agent/pulls/comments/73933478"},"html":{"href":"https://github.com/rancher/agent/pull/11#discussion_r73933478"},"pull_request":{"href":"https://api.github.com/repos/rancher/agent/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/rancher/agent/pulls/11","id":78941121,"html_url":"https://github.com/rancher/agent/pull/11","diff_url":"https://github.com/rancher/agent/pull/11.diff","patch_url":"https://github.com/rancher/agent/pull/11.patch","issue_url":"https://api.github.com/repos/rancher/agent/issues/11","number":11,"state":"open","locked":false,"title":"Go agent","user":{"login":"StrongMonkey","id":9203378,"avatar_url":"https://avatars.githubusercontent.com/u/9203378?v=3","gravatar_id":"","url":"https://api.github.com/users/StrongMonkey","html_url":"https://github.com/StrongMonkey","followers_url":"https://api.github.com/users/StrongMonkey/followers","following_url":"https://api.github.com/users/StrongMonkey/following{/other_user}","gists_url":"https://api.github.com/users/StrongMonkey/gists{/gist_id}","starred_url":"https://api.github.com/users/StrongMonkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StrongMonkey/subscriptions","organizations_url":"https://api.github.com/users/StrongMonkey/orgs","repos_url":"https://api.github.com/users/StrongMonkey/repos","events_url":"https://api.github.com/users/StrongMonkey/events{/privacy}","received_events_url":"https://api.github.com/users/StrongMonkey/received_events","type":"User","site_admin":false},"body":"Go agent with all event handlers implemented and 83 test cases","created_at":"2016-07-26T23:07:48Z","updated_at":"2016-08-08T18:58:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"937b063309320bfd9325730c0749a98f6b0d783a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rancher/agent/pulls/11/commits","review_comments_url":"https://api.github.com/repos/rancher/agent/pulls/11/comments","review_comment_url":"https://api.github.com/repos/rancher/agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rancher/agent/issues/11/comments","statuses_url":"https://api.github.com/repos/rancher/agent/statuses/dbc6f53711a8bc9fea4ad0f2aec0776a0122a8e5","head":{"label":"StrongMonkey:dev","ref":"dev","sha":"dbc6f53711a8bc9fea4ad0f2aec0776a0122a8e5","user":{"login":"StrongMonkey","id":9203378,"avatar_url":"https://avatars.githubusercontent.com/u/9203378?v=3","gravatar_id":"","url":"https://api.github.com/users/StrongMonkey","html_url":"https://github.com/StrongMonkey","followers_url":"https://api.github.com/users/StrongMonkey/followers","following_url":"https://api.github.com/users/StrongMonkey/following{/other_user}","gists_url":"https://api.github.com/users/StrongMonkey/gists{/gist_id}","starred_url":"https://api.github.com/users/StrongMonkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StrongMonkey/subscriptions","organizations_url":"https://api.github.com/users/StrongMonkey/orgs","repos_url":"https://api.github.com/users/StrongMonkey/repos","events_url":"https://api.github.com/users/StrongMonkey/events{/privacy}","received_events_url":"https://api.github.com/users/StrongMonkey/received_events","type":"User","site_admin":false},"repo":{"id":63087151,"name":"agent-1","full_name":"StrongMonkey/agent-1","owner":{"login":"StrongMonkey","id":9203378,"avatar_url":"https://avatars.githubusercontent.com/u/9203378?v=3","gravatar_id":"","url":"https://api.github.com/users/StrongMonkey","html_url":"https://github.com/StrongMonkey","followers_url":"https://api.github.com/users/StrongMonkey/followers","following_url":"https://api.github.com/users/StrongMonkey/following{/other_user}","gists_url":"https://api.github.com/users/StrongMonkey/gists{/gist_id}","starred_url":"https://api.github.com/users/StrongMonkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StrongMonkey/subscriptions","organizations_url":"https://api.github.com/users/StrongMonkey/orgs","repos_url":"https://api.github.com/users/StrongMonkey/repos","events_url":"https://api.github.com/users/StrongMonkey/events{/privacy}","received_events_url":"https://api.github.com/users/StrongMonkey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/StrongMonkey/agent-1","description":null,"fork":true,"url":"https://api.github.com/repos/StrongMonkey/agent-1","forks_url":"https://api.github.com/repos/StrongMonkey/agent-1/forks","keys_url":"https://api.github.com/repos/StrongMonkey/agent-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StrongMonkey/agent-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StrongMonkey/agent-1/teams","hooks_url":"https://api.github.com/repos/StrongMonkey/agent-1/hooks","issue_events_url":"https://api.github.com/repos/StrongMonkey/agent-1/issues/events{/number}","events_url":"https://api.github.com/repos/StrongMonkey/agent-1/events","assignees_url":"https://api.github.com/repos/StrongMonkey/agent-1/assignees{/user}","branches_url":"https://api.github.com/repos/StrongMonkey/agent-1/branches{/branch}","tags_url":"https://api.github.com/repos/StrongMonkey/agent-1/tags","blobs_url":"https://api.github.com/repos/StrongMonkey/agent-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StrongMonkey/agent-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StrongMonkey/agent-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/StrongMonkey/agent-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StrongMonkey/agent-1/statuses/{sha}","languages_url":"https://api.github.com/repos/StrongMonkey/agent-1/languages","stargazers_url":"https://api.github.com/repos/StrongMonkey/agent-1/stargazers","contributors_url":"https://api.github.com/repos/StrongMonkey/agent-1/contributors","subscribers_url":"https://api.github.com/repos/StrongMonkey/agent-1/subscribers","subscription_url":"https://api.github.com/repos/StrongMonkey/agent-1/subscription","commits_url":"https://api.github.com/repos/StrongMonkey/agent-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/StrongMonkey/agent-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/StrongMonkey/agent-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/StrongMonkey/agent-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/StrongMonkey/agent-1/contents/{+path}","compare_url":"https://api.github.com/repos/StrongMonkey/agent-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StrongMonkey/agent-1/merges","archive_url":"https://api.github.com/repos/StrongMonkey/agent-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StrongMonkey/agent-1/downloads","issues_url":"https://api.github.com/repos/StrongMonkey/agent-1/issues{/number}","pulls_url":"https://api.github.com/repos/StrongMonkey/agent-1/pulls{/number}","milestones_url":"https://api.github.com/repos/StrongMonkey/agent-1/milestones{/number}","notifications_url":"https://api.github.com/repos/StrongMonkey/agent-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StrongMonkey/agent-1/labels{/name}","releases_url":"https://api.github.com/repos/StrongMonkey/agent-1/releases{/id}","deployments_url":"https://api.github.com/repos/StrongMonkey/agent-1/deployments","created_at":"2016-07-11T17:14:39Z","updated_at":"2016-07-11T17:14:40Z","pushed_at":"2016-08-08T16:36:36Z","git_url":"git://github.com/StrongMonkey/agent-1.git","ssh_url":"git@github.com:StrongMonkey/agent-1.git","clone_url":"https://github.com/StrongMonkey/agent-1.git","svn_url":"https://github.com/StrongMonkey/agent-1","homepage":null,"size":649,"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":"rancher:dev","ref":"dev","sha":"008d390f06addee498a912b18f1be57e6d2d2a00","user":{"login":"rancher","id":9343010,"avatar_url":"https://avatars.githubusercontent.com/u/9343010?v=3","gravatar_id":"","url":"https://api.github.com/users/rancher","html_url":"https://github.com/rancher","followers_url":"https://api.github.com/users/rancher/followers","following_url":"https://api.github.com/users/rancher/following{/other_user}","gists_url":"https://api.github.com/users/rancher/gists{/gist_id}","starred_url":"https://api.github.com/users/rancher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rancher/subscriptions","organizations_url":"https://api.github.com/users/rancher/orgs","repos_url":"https://api.github.com/users/rancher/repos","events_url":"https://api.github.com/users/rancher/events{/privacy}","received_events_url":"https://api.github.com/users/rancher/received_events","type":"Organization","site_admin":false},"repo":{"id":62338628,"name":"agent","full_name":"rancher/agent","owner":{"login":"rancher","id":9343010,"avatar_url":"https://avatars.githubusercontent.com/u/9343010?v=3","gravatar_id":"","url":"https://api.github.com/users/rancher","html_url":"https://github.com/rancher","followers_url":"https://api.github.com/users/rancher/followers","following_url":"https://api.github.com/users/rancher/following{/other_user}","gists_url":"https://api.github.com/users/rancher/gists{/gist_id}","starred_url":"https://api.github.com/users/rancher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rancher/subscriptions","organizations_url":"https://api.github.com/users/rancher/orgs","repos_url":"https://api.github.com/users/rancher/repos","events_url":"https://api.github.com/users/rancher/events{/privacy}","received_events_url":"https://api.github.com/users/rancher/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rancher/agent","description":null,"fork":false,"url":"https://api.github.com/repos/rancher/agent","forks_url":"https://api.github.com/repos/rancher/agent/forks","keys_url":"https://api.github.com/repos/rancher/agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rancher/agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rancher/agent/teams","hooks_url":"https://api.github.com/repos/rancher/agent/hooks","issue_events_url":"https://api.github.com/repos/rancher/agent/issues/events{/number}","events_url":"https://api.github.com/repos/rancher/agent/events","assignees_url":"https://api.github.com/repos/rancher/agent/assignees{/user}","branches_url":"https://api.github.com/repos/rancher/agent/branches{/branch}","tags_url":"https://api.github.com/repos/rancher/agent/tags","blobs_url":"https://api.github.com/repos/rancher/agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rancher/agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rancher/agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/rancher/agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rancher/agent/statuses/{sha}","languages_url":"https://api.github.com/repos/rancher/agent/languages","stargazers_url":"https://api.github.com/repos/rancher/agent/stargazers","contributors_url":"https://api.github.com/repos/rancher/agent/contributors","subscribers_url":"https://api.github.com/repos/rancher/agent/subscribers","subscription_url":"https://api.github.com/repos/rancher/agent/subscription","commits_url":"https://api.github.com/repos/rancher/agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/rancher/agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/rancher/agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/rancher/agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/rancher/agent/contents/{+path}","compare_url":"https://api.github.com/repos/rancher/agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rancher/agent/merges","archive_url":"https://api.github.com/repos/rancher/agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rancher/agent/downloads","issues_url":"https://api.github.com/repos/rancher/agent/issues{/number}","pulls_url":"https://api.github.com/repos/rancher/agent/pulls{/number}","milestones_url":"https://api.github.com/repos/rancher/agent/milestones{/number}","notifications_url":"https://api.github.com/repos/rancher/agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rancher/agent/labels{/name}","releases_url":"https://api.github.com/repos/rancher/agent/releases{/id}","deployments_url":"https://api.github.com/repos/rancher/agent/deployments","created_at":"2016-06-30T19:57:16Z","updated_at":"2016-07-27T07:19:52Z","pushed_at":"2016-08-08T16:36:37Z","git_url":"git://github.com/rancher/agent.git","ssh_url":"git@github.com:rancher/agent.git","clone_url":"https://github.com/rancher/agent.git","svn_url":"https://github.com/rancher/agent","homepage":null,"size":701,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rancher/agent/pulls/11"},"html":{"href":"https://github.com/rancher/agent/pull/11"},"issue":{"href":"https://api.github.com/repos/rancher/agent/issues/11"},"comments":{"href":"https://api.github.com/repos/rancher/agent/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/rancher/agent/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/rancher/agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rancher/agent/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/rancher/agent/statuses/dbc6f53711a8bc9fea4ad0f2aec0776a0122a8e5"}}}}
{"actor":{"display_login":"cjellick"}}