{"action":"created","comment":{"url":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/comments/61877687","id":61877687,"diff_hunk":"@@ -70,100 +70,106 @@ api.declare({\n     // Intentionally vague because we don't want to reveafollowRedirects\n     // our configuration too much\n     let msg;\n+    let code = 503; // default is that something is temporarily wrong\n     switch (err.code) {\n-      case 'HTTPError':\n-        msg = 'HTTP Error while trying to resolve redirects';\n-        break;\n       case 'DoesNotMatchPatterns':\n         msg = 'Input URL does not match whitelist';\n+        code = 403; // forbidden\n         break;\n       case 'InsecureURL':\n         msg = 'Refusing to follow a non-SSL redirect';\n+        code = 403; // forbidden\n+        break;\n+      case 'HTTPError':\n+        msg = 'HTTP Error while trying to resolve redirects';\n         break;\n       default:\n         msg = 'Input URL failed validation for unknown reason';\n         break;\n     }\n-    return res.status(400).json({\n+    return res.status(code).json({\n       msg: msg,\n+      code: code,\n     });\n   }\n \n-  if (service.toLowerCase() === 's3') {\n-    if (this.s3backends[region]) {\n-      let backend = this.s3backends[region];\n-\n-      let maxWaitForCachedCopy = this.maxWaitForCachedCopy;\n-\n-      let startTime = new Date();\n-      let x = 0;\n-      while (new Date() - startTime < maxWaitForCachedCopy) {\n-        debug(`Check ${x++} of ${url}`);\n+  // This is the ID that we need to find a backend for\n+  let incomingId = `${service}_${region}`;\n+  \n+  // Let's pick which backend to use.  In this case, we're looking to find the\n+  // only backend known that matches the potential id\n+  let backends = this.cacheManagers.filter(x => x.id === incomingId);","path":"src/api-v1.js","position":46,"original_position":46,"commit_id":"173e8ce2a655bc4d998f068c992f4397881dbe76","original_commit_id":"173e8ce2a655bc4d998f068c992f4397881dbe76","user":{"login":"jhford","id":607353,"avatar_url":"https://avatars.githubusercontent.com/u/607353?v=3","gravatar_id":"","url":"https://api.github.com/users/jhford","html_url":"https://github.com/jhford","followers_url":"https://api.github.com/users/jhford/followers","following_url":"https://api.github.com/users/jhford/following{/other_user}","gists_url":"https://api.github.com/users/jhford/gists{/gist_id}","starred_url":"https://api.github.com/users/jhford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhford/subscriptions","organizations_url":"https://api.github.com/users/jhford/orgs","repos_url":"https://api.github.com/users/jhford/repos","events_url":"https://api.github.com/users/jhford/events{/privacy}","received_events_url":"https://api.github.com/users/jhford/received_events","type":"User","site_admin":false},"body":"but that will throw a 500 (and useless error message) if no backend is found, unless I have a try catch, which is uglier than an extra check imo.","created_at":"2016-05-03T13:11:37Z","updated_at":"2016-05-03T13:11:37Z","html_url":"https://github.com/taskcluster/cloud-mirror/pull/13#discussion_r61877687","pull_request_url":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/comments/61877687"},"html":{"href":"https://github.com/taskcluster/cloud-mirror/pull/13#discussion_r61877687"},"pull_request":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/13","id":68395192,"html_url":"https://github.com/taskcluster/cloud-mirror/pull/13","diff_url":"https://github.com/taskcluster/cloud-mirror/pull/13.diff","patch_url":"https://github.com/taskcluster/cloud-mirror/pull/13.patch","issue_url":"https://api.github.com/repos/taskcluster/cloud-mirror/issues/13","number":13,"state":"open","locked":false,"title":"Single queue","user":{"login":"jhford","id":607353,"avatar_url":"https://avatars.githubusercontent.com/u/607353?v=3","gravatar_id":"","url":"https://api.github.com/users/jhford","html_url":"https://github.com/jhford","followers_url":"https://api.github.com/users/jhford/followers","following_url":"https://api.github.com/users/jhford/following{/other_user}","gists_url":"https://api.github.com/users/jhford/gists{/gist_id}","starred_url":"https://api.github.com/users/jhford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhford/subscriptions","organizations_url":"https://api.github.com/users/jhford/orgs","repos_url":"https://api.github.com/users/jhford/repos","events_url":"https://api.github.com/users/jhford/events{/privacy}","received_events_url":"https://api.github.com/users/jhford/received_events","type":"User","site_admin":false},"body":"@jonasfj i reworked the queue to make it so we have a single queue per environment.  There's also a couple of things related to putting the frontend on heroku.  This isn't ready to deploy into production, but I just wanted to see what your thoughts are.\r\n\r\nI'm also going to split out the QueueManager class into its own library at some point because\r\n\r\n1. it's generally useful\r\n2. there's no 'simple' sqs system\r\n3. the unit tests are really delicate because of queue purging\r\n4. it shouldn't change as frequently as the rest of cloud-mirror\r\n\r\nThe whole registerQueue() function thing is because there's a bidirectional dependency between cache and queue managers.  I correctly handle the case where we have more than one queue registered as well as the case where I have multiple backends that share an id.","created_at":"2016-04-29T16:06:14Z","updated_at":"2016-05-03T13:11:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c9db8b06d75c1db5fbd0759ad45efbc28be07bac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/13/commits","review_comments_url":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/13/comments","review_comment_url":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/comments{/number}","comments_url":"https://api.github.com/repos/taskcluster/cloud-mirror/issues/13/comments","statuses_url":"https://api.github.com/repos/taskcluster/cloud-mirror/statuses/173e8ce2a655bc4d998f068c992f4397881dbe76","head":{"label":"taskcluster:single-queue","ref":"single-queue","sha":"173e8ce2a655bc4d998f068c992f4397881dbe76","user":{"login":"taskcluster","id":6257436,"avatar_url":"https://avatars.githubusercontent.com/u/6257436?v=3","gravatar_id":"","url":"https://api.github.com/users/taskcluster","html_url":"https://github.com/taskcluster","followers_url":"https://api.github.com/users/taskcluster/followers","following_url":"https://api.github.com/users/taskcluster/following{/other_user}","gists_url":"https://api.github.com/users/taskcluster/gists{/gist_id}","starred_url":"https://api.github.com/users/taskcluster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taskcluster/subscriptions","organizations_url":"https://api.github.com/users/taskcluster/orgs","repos_url":"https://api.github.com/users/taskcluster/repos","events_url":"https://api.github.com/users/taskcluster/events{/privacy}","received_events_url":"https://api.github.com/users/taskcluster/received_events","type":"Organization","site_admin":false},"repo":{"id":47338707,"name":"cloud-mirror","full_name":"taskcluster/cloud-mirror","owner":{"login":"taskcluster","id":6257436,"avatar_url":"https://avatars.githubusercontent.com/u/6257436?v=3","gravatar_id":"","url":"https://api.github.com/users/taskcluster","html_url":"https://github.com/taskcluster","followers_url":"https://api.github.com/users/taskcluster/followers","following_url":"https://api.github.com/users/taskcluster/following{/other_user}","gists_url":"https://api.github.com/users/taskcluster/gists{/gist_id}","starred_url":"https://api.github.com/users/taskcluster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taskcluster/subscriptions","organizations_url":"https://api.github.com/users/taskcluster/orgs","repos_url":"https://api.github.com/users/taskcluster/repos","events_url":"https://api.github.com/users/taskcluster/events{/privacy}","received_events_url":"https://api.github.com/users/taskcluster/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/taskcluster/cloud-mirror","description":"cloud mirror","fork":false,"url":"https://api.github.com/repos/taskcluster/cloud-mirror","forks_url":"https://api.github.com/repos/taskcluster/cloud-mirror/forks","keys_url":"https://api.github.com/repos/taskcluster/cloud-mirror/keys{/key_id}","collaborators_url":"https://api.github.com/repos/taskcluster/cloud-mirror/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/taskcluster/cloud-mirror/teams","hooks_url":"https://api.github.com/repos/taskcluster/cloud-mirror/hooks","issue_events_url":"https://api.github.com/repos/taskcluster/cloud-mirror/issues/events{/number}","events_url":"https://api.github.com/repos/taskcluster/cloud-mirror/events","assignees_url":"https://api.github.com/repos/taskcluster/cloud-mirror/assignees{/user}","branches_url":"https://api.github.com/repos/taskcluster/cloud-mirror/branches{/branch}","tags_url":"https://api.github.com/repos/taskcluster/cloud-mirror/tags","blobs_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/refs{/sha}","trees_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/trees{/sha}","statuses_url":"https://api.github.com/repos/taskcluster/cloud-mirror/statuses/{sha}","languages_url":"https://api.github.com/repos/taskcluster/cloud-mirror/languages","stargazers_url":"https://api.github.com/repos/taskcluster/cloud-mirror/stargazers","contributors_url":"https://api.github.com/repos/taskcluster/cloud-mirror/contributors","subscribers_url":"https://api.github.com/repos/taskcluster/cloud-mirror/subscribers","subscription_url":"https://api.github.com/repos/taskcluster/cloud-mirror/subscription","commits_url":"https://api.github.com/repos/taskcluster/cloud-mirror/commits{/sha}","git_commits_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/commits{/sha}","comments_url":"https://api.github.com/repos/taskcluster/cloud-mirror/comments{/number}","issue_comment_url":"https://api.github.com/repos/taskcluster/cloud-mirror/issues/comments{/number}","contents_url":"https://api.github.com/repos/taskcluster/cloud-mirror/contents/{+path}","compare_url":"https://api.github.com/repos/taskcluster/cloud-mirror/compare/{base}...{head}","merges_url":"https://api.github.com/repos/taskcluster/cloud-mirror/merges","archive_url":"https://api.github.com/repos/taskcluster/cloud-mirror/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/taskcluster/cloud-mirror/downloads","issues_url":"https://api.github.com/repos/taskcluster/cloud-mirror/issues{/number}","pulls_url":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls{/number}","milestones_url":"https://api.github.com/repos/taskcluster/cloud-mirror/milestones{/number}","notifications_url":"https://api.github.com/repos/taskcluster/cloud-mirror/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/taskcluster/cloud-mirror/labels{/name}","releases_url":"https://api.github.com/repos/taskcluster/cloud-mirror/releases{/id}","deployments_url":"https://api.github.com/repos/taskcluster/cloud-mirror/deployments","created_at":"2015-12-03T14:55:11Z","updated_at":"2016-02-19T14:27:22Z","pushed_at":"2016-04-29T16:08:50Z","git_url":"git://github.com/taskcluster/cloud-mirror.git","ssh_url":"git@github.com:taskcluster/cloud-mirror.git","clone_url":"https://github.com/taskcluster/cloud-mirror.git","svn_url":"https://github.com/taskcluster/cloud-mirror","homepage":"","size":133,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":10,"forks":1,"open_issues":10,"watchers":0,"default_branch":"master"}},"base":{"label":"taskcluster:master","ref":"master","sha":"3b34bccdbcadccc29c87fcf9e947047188d089fc","user":{"login":"taskcluster","id":6257436,"avatar_url":"https://avatars.githubusercontent.com/u/6257436?v=3","gravatar_id":"","url":"https://api.github.com/users/taskcluster","html_url":"https://github.com/taskcluster","followers_url":"https://api.github.com/users/taskcluster/followers","following_url":"https://api.github.com/users/taskcluster/following{/other_user}","gists_url":"https://api.github.com/users/taskcluster/gists{/gist_id}","starred_url":"https://api.github.com/users/taskcluster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taskcluster/subscriptions","organizations_url":"https://api.github.com/users/taskcluster/orgs","repos_url":"https://api.github.com/users/taskcluster/repos","events_url":"https://api.github.com/users/taskcluster/events{/privacy}","received_events_url":"https://api.github.com/users/taskcluster/received_events","type":"Organization","site_admin":false},"repo":{"id":47338707,"name":"cloud-mirror","full_name":"taskcluster/cloud-mirror","owner":{"login":"taskcluster","id":6257436,"avatar_url":"https://avatars.githubusercontent.com/u/6257436?v=3","gravatar_id":"","url":"https://api.github.com/users/taskcluster","html_url":"https://github.com/taskcluster","followers_url":"https://api.github.com/users/taskcluster/followers","following_url":"https://api.github.com/users/taskcluster/following{/other_user}","gists_url":"https://api.github.com/users/taskcluster/gists{/gist_id}","starred_url":"https://api.github.com/users/taskcluster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taskcluster/subscriptions","organizations_url":"https://api.github.com/users/taskcluster/orgs","repos_url":"https://api.github.com/users/taskcluster/repos","events_url":"https://api.github.com/users/taskcluster/events{/privacy}","received_events_url":"https://api.github.com/users/taskcluster/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/taskcluster/cloud-mirror","description":"cloud mirror","fork":false,"url":"https://api.github.com/repos/taskcluster/cloud-mirror","forks_url":"https://api.github.com/repos/taskcluster/cloud-mirror/forks","keys_url":"https://api.github.com/repos/taskcluster/cloud-mirror/keys{/key_id}","collaborators_url":"https://api.github.com/repos/taskcluster/cloud-mirror/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/taskcluster/cloud-mirror/teams","hooks_url":"https://api.github.com/repos/taskcluster/cloud-mirror/hooks","issue_events_url":"https://api.github.com/repos/taskcluster/cloud-mirror/issues/events{/number}","events_url":"https://api.github.com/repos/taskcluster/cloud-mirror/events","assignees_url":"https://api.github.com/repos/taskcluster/cloud-mirror/assignees{/user}","branches_url":"https://api.github.com/repos/taskcluster/cloud-mirror/branches{/branch}","tags_url":"https://api.github.com/repos/taskcluster/cloud-mirror/tags","blobs_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/refs{/sha}","trees_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/trees{/sha}","statuses_url":"https://api.github.com/repos/taskcluster/cloud-mirror/statuses/{sha}","languages_url":"https://api.github.com/repos/taskcluster/cloud-mirror/languages","stargazers_url":"https://api.github.com/repos/taskcluster/cloud-mirror/stargazers","contributors_url":"https://api.github.com/repos/taskcluster/cloud-mirror/contributors","subscribers_url":"https://api.github.com/repos/taskcluster/cloud-mirror/subscribers","subscription_url":"https://api.github.com/repos/taskcluster/cloud-mirror/subscription","commits_url":"https://api.github.com/repos/taskcluster/cloud-mirror/commits{/sha}","git_commits_url":"https://api.github.com/repos/taskcluster/cloud-mirror/git/commits{/sha}","comments_url":"https://api.github.com/repos/taskcluster/cloud-mirror/comments{/number}","issue_comment_url":"https://api.github.com/repos/taskcluster/cloud-mirror/issues/comments{/number}","contents_url":"https://api.github.com/repos/taskcluster/cloud-mirror/contents/{+path}","compare_url":"https://api.github.com/repos/taskcluster/cloud-mirror/compare/{base}...{head}","merges_url":"https://api.github.com/repos/taskcluster/cloud-mirror/merges","archive_url":"https://api.github.com/repos/taskcluster/cloud-mirror/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/taskcluster/cloud-mirror/downloads","issues_url":"https://api.github.com/repos/taskcluster/cloud-mirror/issues{/number}","pulls_url":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls{/number}","milestones_url":"https://api.github.com/repos/taskcluster/cloud-mirror/milestones{/number}","notifications_url":"https://api.github.com/repos/taskcluster/cloud-mirror/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/taskcluster/cloud-mirror/labels{/name}","releases_url":"https://api.github.com/repos/taskcluster/cloud-mirror/releases{/id}","deployments_url":"https://api.github.com/repos/taskcluster/cloud-mirror/deployments","created_at":"2015-12-03T14:55:11Z","updated_at":"2016-02-19T14:27:22Z","pushed_at":"2016-04-29T16:08:50Z","git_url":"git://github.com/taskcluster/cloud-mirror.git","ssh_url":"git@github.com:taskcluster/cloud-mirror.git","clone_url":"https://github.com/taskcluster/cloud-mirror.git","svn_url":"https://github.com/taskcluster/cloud-mirror","homepage":"","size":133,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":10,"forks":1,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/13"},"html":{"href":"https://github.com/taskcluster/cloud-mirror/pull/13"},"issue":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/issues/13"},"comments":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/taskcluster/cloud-mirror/statuses/173e8ce2a655bc4d998f068c992f4397881dbe76"}}}}