{"action":"created","comment":{"url":"https://api.github.com/repos/Luzifer/gobuilder/pulls/comments/28768079","id":28768079,"diff_hunk":"@@ -130,6 +131,26 @@ func fetchBuildJob() {\n \t}\n \trepo := job.Repository\n \n+\t// Aquire lock to ensure one repo is not built twice\n+\tlockID := uuid.NewV4().String()\n+\tredisClient.Set(fmt.Sprintf(\"project::%s::build-lock\", repo), lockID, 1800, 0, false, true)\n+\n+\tlock, err := redisClient.Get(fmt.Sprintf(\"project::%s::build-lock\", repo))\n+\tif err != nil {\n+\t\tlog.WithFields(logrus.Fields{\n+\t\t\t\"error\": err,\n+\t\t}).Error(\"Unable to fetch lock state\")\n+\t\treturn\n+\t}\n+\n+\tif string(lock) != lockID {\n+\t\t// If build-job is currently locked but not by us, try again later\n+\t\tqueueEntry, err := job.ToByte()\n+\t\torFail(err)\n+\t\tredisClient.RPush(\"build-queue\", string(queueEntry))\n+\t\treturn\n+\t}","path":"cmd/starter/main.go","position":30,"original_position":30,"commit_id":"db340aab654b8cec9742e1fb04382d3290b390d4","original_commit_id":"db340aab654b8cec9742e1fb04382d3290b390d4","user":{"login":"Luzifer","id":20142,"avatar_url":"https://avatars.githubusercontent.com/u/20142?v=3","gravatar_id":"","url":"https://api.github.com/users/Luzifer","html_url":"https://github.com/Luzifer","followers_url":"https://api.github.com/users/Luzifer/followers","following_url":"https://api.github.com/users/Luzifer/following{/other_user}","gists_url":"https://api.github.com/users/Luzifer/gists{/gist_id}","starred_url":"https://api.github.com/users/Luzifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Luzifer/subscriptions","organizations_url":"https://api.github.com/users/Luzifer/orgs","repos_url":"https://api.github.com/users/Luzifer/repos","events_url":"https://api.github.com/users/Luzifer/events{/privacy}","received_events_url":"https://api.github.com/users/Luzifer/received_events","type":"User","site_admin":false},"body":"I don't really know. The code for the set command is quite intransparent… Thats why I wrote the get check to ensure the own ID is set to the lock. Any other sets should fail and the id does not match so the get returns from the function…","created_at":"2015-04-21T11:01:44Z","updated_at":"2015-04-21T11:01:44Z","html_url":"https://github.com/Luzifer/gobuilder/pull/21#discussion_r28768079","pull_request_url":"https://api.github.com/repos/Luzifer/gobuilder/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/Luzifer/gobuilder/pulls/comments/28768079"},"html":{"href":"https://github.com/Luzifer/gobuilder/pull/21#discussion_r28768079"},"pull_request":{"href":"https://api.github.com/repos/Luzifer/gobuilder/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/Luzifer/gobuilder/pulls/21","id":33626383,"html_url":"https://github.com/Luzifer/gobuilder/pull/21","diff_url":"https://github.com/Luzifer/gobuilder/pull/21.diff","patch_url":"https://github.com/Luzifer/gobuilder/pull/21.patch","issue_url":"https://api.github.com/repos/Luzifer/gobuilder/issues/21","number":21,"state":"open","locked":false,"title":"Added locking for build jobs","user":{"login":"Luzifer","id":20142,"avatar_url":"https://avatars.githubusercontent.com/u/20142?v=3","gravatar_id":"","url":"https://api.github.com/users/Luzifer","html_url":"https://github.com/Luzifer","followers_url":"https://api.github.com/users/Luzifer/followers","following_url":"https://api.github.com/users/Luzifer/following{/other_user}","gists_url":"https://api.github.com/users/Luzifer/gists{/gist_id}","starred_url":"https://api.github.com/users/Luzifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Luzifer/subscriptions","organizations_url":"https://api.github.com/users/Luzifer/orgs","repos_url":"https://api.github.com/users/Luzifer/repos","events_url":"https://api.github.com/users/Luzifer/events{/privacy}","received_events_url":"https://api.github.com/users/Luzifer/received_events","type":"User","site_admin":false},"body":null,"created_at":"2015-04-19T21:34:08Z","updated_at":"2015-04-21T11:01:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4319cc95d0a448d5bc24f6b44eb3b3739b7c1010","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Luzifer/gobuilder/pulls/21/commits","review_comments_url":"https://api.github.com/repos/Luzifer/gobuilder/pulls/21/comments","review_comment_url":"https://api.github.com/repos/Luzifer/gobuilder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Luzifer/gobuilder/issues/21/comments","statuses_url":"https://api.github.com/repos/Luzifer/gobuilder/statuses/db340aab654b8cec9742e1fb04382d3290b390d4","head":{"label":"Luzifer:feature/build-lock","ref":"feature/build-lock","sha":"db340aab654b8cec9742e1fb04382d3290b390d4","user":{"login":"Luzifer","id":20142,"avatar_url":"https://avatars.githubusercontent.com/u/20142?v=3","gravatar_id":"","url":"https://api.github.com/users/Luzifer","html_url":"https://github.com/Luzifer","followers_url":"https://api.github.com/users/Luzifer/followers","following_url":"https://api.github.com/users/Luzifer/following{/other_user}","gists_url":"https://api.github.com/users/Luzifer/gists{/gist_id}","starred_url":"https://api.github.com/users/Luzifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Luzifer/subscriptions","organizations_url":"https://api.github.com/users/Luzifer/orgs","repos_url":"https://api.github.com/users/Luzifer/repos","events_url":"https://api.github.com/users/Luzifer/events{/privacy}","received_events_url":"https://api.github.com/users/Luzifer/received_events","type":"User","site_admin":false},"repo":{"id":26295700,"name":"gobuilder","full_name":"Luzifer/gobuilder","owner":{"login":"Luzifer","id":20142,"avatar_url":"https://avatars.githubusercontent.com/u/20142?v=3","gravatar_id":"","url":"https://api.github.com/users/Luzifer","html_url":"https://github.com/Luzifer","followers_url":"https://api.github.com/users/Luzifer/followers","following_url":"https://api.github.com/users/Luzifer/following{/other_user}","gists_url":"https://api.github.com/users/Luzifer/gists{/gist_id}","starred_url":"https://api.github.com/users/Luzifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Luzifer/subscriptions","organizations_url":"https://api.github.com/users/Luzifer/orgs","repos_url":"https://api.github.com/users/Luzifer/repos","events_url":"https://api.github.com/users/Luzifer/events{/privacy}","received_events_url":"https://api.github.com/users/Luzifer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Luzifer/gobuilder","description":"Automatic Golang building project","fork":false,"url":"https://api.github.com/repos/Luzifer/gobuilder","forks_url":"https://api.github.com/repos/Luzifer/gobuilder/forks","keys_url":"https://api.github.com/repos/Luzifer/gobuilder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Luzifer/gobuilder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Luzifer/gobuilder/teams","hooks_url":"https://api.github.com/repos/Luzifer/gobuilder/hooks","issue_events_url":"https://api.github.com/repos/Luzifer/gobuilder/issues/events{/number}","events_url":"https://api.github.com/repos/Luzifer/gobuilder/events","assignees_url":"https://api.github.com/repos/Luzifer/gobuilder/assignees{/user}","branches_url":"https://api.github.com/repos/Luzifer/gobuilder/branches{/branch}","tags_url":"https://api.github.com/repos/Luzifer/gobuilder/tags","blobs_url":"https://api.github.com/repos/Luzifer/gobuilder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Luzifer/gobuilder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Luzifer/gobuilder/git/refs{/sha}","trees_url":"https://api.github.com/repos/Luzifer/gobuilder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Luzifer/gobuilder/statuses/{sha}","languages_url":"https://api.github.com/repos/Luzifer/gobuilder/languages","stargazers_url":"https://api.github.com/repos/Luzifer/gobuilder/stargazers","contributors_url":"https://api.github.com/repos/Luzifer/gobuilder/contributors","subscribers_url":"https://api.github.com/repos/Luzifer/gobuilder/subscribers","subscription_url":"https://api.github.com/repos/Luzifer/gobuilder/subscription","commits_url":"https://api.github.com/repos/Luzifer/gobuilder/commits{/sha}","git_commits_url":"https://api.github.com/repos/Luzifer/gobuilder/git/commits{/sha}","comments_url":"https://api.github.com/repos/Luzifer/gobuilder/comments{/number}","issue_comment_url":"https://api.github.com/repos/Luzifer/gobuilder/issues/comments{/number}","contents_url":"https://api.github.com/repos/Luzifer/gobuilder/contents/{+path}","compare_url":"https://api.github.com/repos/Luzifer/gobuilder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Luzifer/gobuilder/merges","archive_url":"https://api.github.com/repos/Luzifer/gobuilder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Luzifer/gobuilder/downloads","issues_url":"https://api.github.com/repos/Luzifer/gobuilder/issues{/number}","pulls_url":"https://api.github.com/repos/Luzifer/gobuilder/pulls{/number}","milestones_url":"https://api.github.com/repos/Luzifer/gobuilder/milestones{/number}","notifications_url":"https://api.github.com/repos/Luzifer/gobuilder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Luzifer/gobuilder/labels{/name}","releases_url":"https://api.github.com/repos/Luzifer/gobuilder/releases{/id}","created_at":"2014-11-06T23:55:07Z","updated_at":"2015-04-17T12:15:49Z","pushed_at":"2015-04-21T10:26:26Z","git_url":"git://github.com/Luzifer/gobuilder.git","ssh_url":"git@github.com:Luzifer/gobuilder.git","clone_url":"https://github.com/Luzifer/gobuilder.git","svn_url":"https://github.com/Luzifer/gobuilder","homepage":"https://gobuilder.me/","size":1652,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":9,"default_branch":"master"}},"base":{"label":"Luzifer:master","ref":"master","sha":"614966667df66d9b21b3e6deb7deff39c7a9f574","user":{"login":"Luzifer","id":20142,"avatar_url":"https://avatars.githubusercontent.com/u/20142?v=3","gravatar_id":"","url":"https://api.github.com/users/Luzifer","html_url":"https://github.com/Luzifer","followers_url":"https://api.github.com/users/Luzifer/followers","following_url":"https://api.github.com/users/Luzifer/following{/other_user}","gists_url":"https://api.github.com/users/Luzifer/gists{/gist_id}","starred_url":"https://api.github.com/users/Luzifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Luzifer/subscriptions","organizations_url":"https://api.github.com/users/Luzifer/orgs","repos_url":"https://api.github.com/users/Luzifer/repos","events_url":"https://api.github.com/users/Luzifer/events{/privacy}","received_events_url":"https://api.github.com/users/Luzifer/received_events","type":"User","site_admin":false},"repo":{"id":26295700,"name":"gobuilder","full_name":"Luzifer/gobuilder","owner":{"login":"Luzifer","id":20142,"avatar_url":"https://avatars.githubusercontent.com/u/20142?v=3","gravatar_id":"","url":"https://api.github.com/users/Luzifer","html_url":"https://github.com/Luzifer","followers_url":"https://api.github.com/users/Luzifer/followers","following_url":"https://api.github.com/users/Luzifer/following{/other_user}","gists_url":"https://api.github.com/users/Luzifer/gists{/gist_id}","starred_url":"https://api.github.com/users/Luzifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Luzifer/subscriptions","organizations_url":"https://api.github.com/users/Luzifer/orgs","repos_url":"https://api.github.com/users/Luzifer/repos","events_url":"https://api.github.com/users/Luzifer/events{/privacy}","received_events_url":"https://api.github.com/users/Luzifer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Luzifer/gobuilder","description":"Automatic Golang building project","fork":false,"url":"https://api.github.com/repos/Luzifer/gobuilder","forks_url":"https://api.github.com/repos/Luzifer/gobuilder/forks","keys_url":"https://api.github.com/repos/Luzifer/gobuilder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Luzifer/gobuilder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Luzifer/gobuilder/teams","hooks_url":"https://api.github.com/repos/Luzifer/gobuilder/hooks","issue_events_url":"https://api.github.com/repos/Luzifer/gobuilder/issues/events{/number}","events_url":"https://api.github.com/repos/Luzifer/gobuilder/events","assignees_url":"https://api.github.com/repos/Luzifer/gobuilder/assignees{/user}","branches_url":"https://api.github.com/repos/Luzifer/gobuilder/branches{/branch}","tags_url":"https://api.github.com/repos/Luzifer/gobuilder/tags","blobs_url":"https://api.github.com/repos/Luzifer/gobuilder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Luzifer/gobuilder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Luzifer/gobuilder/git/refs{/sha}","trees_url":"https://api.github.com/repos/Luzifer/gobuilder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Luzifer/gobuilder/statuses/{sha}","languages_url":"https://api.github.com/repos/Luzifer/gobuilder/languages","stargazers_url":"https://api.github.com/repos/Luzifer/gobuilder/stargazers","contributors_url":"https://api.github.com/repos/Luzifer/gobuilder/contributors","subscribers_url":"https://api.github.com/repos/Luzifer/gobuilder/subscribers","subscription_url":"https://api.github.com/repos/Luzifer/gobuilder/subscription","commits_url":"https://api.github.com/repos/Luzifer/gobuilder/commits{/sha}","git_commits_url":"https://api.github.com/repos/Luzifer/gobuilder/git/commits{/sha}","comments_url":"https://api.github.com/repos/Luzifer/gobuilder/comments{/number}","issue_comment_url":"https://api.github.com/repos/Luzifer/gobuilder/issues/comments{/number}","contents_url":"https://api.github.com/repos/Luzifer/gobuilder/contents/{+path}","compare_url":"https://api.github.com/repos/Luzifer/gobuilder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Luzifer/gobuilder/merges","archive_url":"https://api.github.com/repos/Luzifer/gobuilder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Luzifer/gobuilder/downloads","issues_url":"https://api.github.com/repos/Luzifer/gobuilder/issues{/number}","pulls_url":"https://api.github.com/repos/Luzifer/gobuilder/pulls{/number}","milestones_url":"https://api.github.com/repos/Luzifer/gobuilder/milestones{/number}","notifications_url":"https://api.github.com/repos/Luzifer/gobuilder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Luzifer/gobuilder/labels{/name}","releases_url":"https://api.github.com/repos/Luzifer/gobuilder/releases{/id}","created_at":"2014-11-06T23:55:07Z","updated_at":"2015-04-17T12:15:49Z","pushed_at":"2015-04-21T10:26:26Z","git_url":"git://github.com/Luzifer/gobuilder.git","ssh_url":"git@github.com:Luzifer/gobuilder.git","clone_url":"https://github.com/Luzifer/gobuilder.git","svn_url":"https://github.com/Luzifer/gobuilder","homepage":"https://gobuilder.me/","size":1652,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Luzifer/gobuilder/pulls/21"},"html":{"href":"https://github.com/Luzifer/gobuilder/pull/21"},"issue":{"href":"https://api.github.com/repos/Luzifer/gobuilder/issues/21"},"comments":{"href":"https://api.github.com/repos/Luzifer/gobuilder/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/Luzifer/gobuilder/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/Luzifer/gobuilder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Luzifer/gobuilder/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/Luzifer/gobuilder/statuses/db340aab654b8cec9742e1fb04382d3290b390d4"}}}}