{"action":"created","comment":{"url":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/comments/74304970","id":74304970,"diff_hunk":"@@ -139,10 +125,172 @@ class AwsManager {\n     this.reportAmiUsage = series.amiUsage.reporter(influx);\n   }\n \n+  async init(){\n+    try {\n+      let rawJson = await this.spotRequestContainer.read('internal-provisioner-data');\n+      let data = JSON.parse(rawJson);\n+      // This is mainly for debugging\n+      fs.writeFileSync('internal-data.json', data);\n+      this.__spotRequestIdCache = data.managedSpotRequests || []; \n+      this.__internalState = data.internallyTrackedSpotRequests || [];\n+    } catch (err) {\n+      if (err.code !== 'BlobNotFound') {\n+        throw err;\n+      }\n+      this.__spotRequestIdCache = [];\n+      this.__internalState = [];\n+    }\n+  }\n+\n+  async saveAwsManagerInternalState() {\n+    // We use this for both of the current internal caches... let's just use\n+    // the same code for both\n+    function expire(item) {\n+      let diff = Date.now() - item.created;\n+      // If we've known about this for more than 5 days, evict it, otherwise\n+      // keep it.  5 days is a good amount since we force kill things even if\n+      // they're running after 4 days.  This lets us have a full extra day\n+      if (diff > 1000 * 60 * 60 * 24 * 5) {\n+        return false;\n+      }\n+      return true;\n+    }\n+\n+    this.__spotRequestIdCache = this.__spotRequestIdCache.filter(expire);\n+\n+    let data = JSON.stringify({\n+      managedSpotRequests: this.__spotRequestIdCache || [],\n+      internallyTrackedSpotRequests: this.__internalState || [],\n+    }, null, 2);\n+\n+    fs.writeFileSync('internal-data.json', data);\n+    return this.spotRequestContainer.write('internal-provisioner-data', data);\n+  }\n+\n+  /**\n+   * Simplify how we access stored spot request ids","path":"src/aws-manager.js","position":117,"original_position":117,"commit_id":"52ec7d18ca81f407e781d8f46b167060fd811074","original_commit_id":"52ec7d18ca81f407e781d8f46b167060fd811074","user":{"login":"jonasfj","id":149732,"avatar_url":"https://avatars.githubusercontent.com/u/149732?v=3","gravatar_id":"","url":"https://api.github.com/users/jonasfj","html_url":"https://github.com/jonasfj","followers_url":"https://api.github.com/users/jonasfj/followers","following_url":"https://api.github.com/users/jonasfj/following{/other_user}","gists_url":"https://api.github.com/users/jonasfj/gists{/gist_id}","starred_url":"https://api.github.com/users/jonasfj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonasfj/subscriptions","organizations_url":"https://api.github.com/users/jonasfj/orgs","repos_url":"https://api.github.com/users/jonasfj/repos","events_url":"https://api.github.com/users/jonasfj/events{/privacy}","received_events_url":"https://api.github.com/users/jonasfj/received_events","type":"User","site_admin":false},"body":"Maybe a comment saying what the function takes and returns...","created_at":"2016-08-10T18:41:49Z","updated_at":"2016-08-10T18:41:49Z","html_url":"https://github.com/taskcluster/aws-provisioner/pull/98#discussion_r74304970","pull_request_url":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/98","_links":{"self":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/comments/74304970"},"html":{"href":"https://github.com/taskcluster/aws-provisioner/pull/98#discussion_r74304970"},"pull_request":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/98","id":79594438,"html_url":"https://github.com/taskcluster/aws-provisioner/pull/98","diff_url":"https://github.com/taskcluster/aws-provisioner/pull/98.diff","patch_url":"https://github.com/taskcluster/aws-provisioner/pull/98.patch","issue_url":"https://api.github.com/repos/taskcluster/aws-provisioner/issues/98","number":98,"state":"open","locked":false,"title":"bug 1290922 - stop using KeyPair.Name as a metadata store","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":"For security reasons, we'd like to use a different mechanism to store the provisioner id and worker type.  This approach builds up a database in memory, saving to Azure blob storage as needed.\n\nWhen this deploys, we'll stop considering worker types which are managed using KeyPairs.  This will result in over provisioning briefly, but the worker shutdown procedures should ensure that this overlap is not too much more than one hour.","created_at":"2016-08-01T16:10:57Z","updated_at":"2016-08-10T18:41:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79edff39968fbe50afb4591482be2067cea851e9","assignee":{"login":"jonasfj","id":149732,"avatar_url":"https://avatars.githubusercontent.com/u/149732?v=3","gravatar_id":"","url":"https://api.github.com/users/jonasfj","html_url":"https://github.com/jonasfj","followers_url":"https://api.github.com/users/jonasfj/followers","following_url":"https://api.github.com/users/jonasfj/following{/other_user}","gists_url":"https://api.github.com/users/jonasfj/gists{/gist_id}","starred_url":"https://api.github.com/users/jonasfj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonasfj/subscriptions","organizations_url":"https://api.github.com/users/jonasfj/orgs","repos_url":"https://api.github.com/users/jonasfj/repos","events_url":"https://api.github.com/users/jonasfj/events{/privacy}","received_events_url":"https://api.github.com/users/jonasfj/received_events","type":"User","site_admin":false},"assignees":[{"login":"jonasfj","id":149732,"avatar_url":"https://avatars.githubusercontent.com/u/149732?v=3","gravatar_id":"","url":"https://api.github.com/users/jonasfj","html_url":"https://github.com/jonasfj","followers_url":"https://api.github.com/users/jonasfj/followers","following_url":"https://api.github.com/users/jonasfj/following{/other_user}","gists_url":"https://api.github.com/users/jonasfj/gists{/gist_id}","starred_url":"https://api.github.com/users/jonasfj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonasfj/subscriptions","organizations_url":"https://api.github.com/users/jonasfj/orgs","repos_url":"https://api.github.com/users/jonasfj/repos","events_url":"https://api.github.com/users/jonasfj/events{/privacy}","received_events_url":"https://api.github.com/users/jonasfj/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/98/commits","review_comments_url":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/98/comments","review_comment_url":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/taskcluster/aws-provisioner/issues/98/comments","statuses_url":"https://api.github.com/repos/taskcluster/aws-provisioner/statuses/52ec7d18ca81f407e781d8f46b167060fd811074","head":{"label":"taskcluster:stop-using-keypairs","ref":"stop-using-keypairs","sha":"52ec7d18ca81f407e781d8f46b167060fd811074","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":16123958,"name":"aws-provisioner","full_name":"taskcluster/aws-provisioner","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/aws-provisioner","description":"AWS Provisioner for the TaskCluster","fork":false,"url":"https://api.github.com/repos/taskcluster/aws-provisioner","forks_url":"https://api.github.com/repos/taskcluster/aws-provisioner/forks","keys_url":"https://api.github.com/repos/taskcluster/aws-provisioner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/taskcluster/aws-provisioner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/taskcluster/aws-provisioner/teams","hooks_url":"https://api.github.com/repos/taskcluster/aws-provisioner/hooks","issue_events_url":"https://api.github.com/repos/taskcluster/aws-provisioner/issues/events{/number}","events_url":"https://api.github.com/repos/taskcluster/aws-provisioner/events","assignees_url":"https://api.github.com/repos/taskcluster/aws-provisioner/assignees{/user}","branches_url":"https://api.github.com/repos/taskcluster/aws-provisioner/branches{/branch}","tags_url":"https://api.github.com/repos/taskcluster/aws-provisioner/tags","blobs_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/refs{/sha}","trees_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/taskcluster/aws-provisioner/statuses/{sha}","languages_url":"https://api.github.com/repos/taskcluster/aws-provisioner/languages","stargazers_url":"https://api.github.com/repos/taskcluster/aws-provisioner/stargazers","contributors_url":"https://api.github.com/repos/taskcluster/aws-provisioner/contributors","subscribers_url":"https://api.github.com/repos/taskcluster/aws-provisioner/subscribers","subscription_url":"https://api.github.com/repos/taskcluster/aws-provisioner/subscription","commits_url":"https://api.github.com/repos/taskcluster/aws-provisioner/commits{/sha}","git_commits_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/commits{/sha}","comments_url":"https://api.github.com/repos/taskcluster/aws-provisioner/comments{/number}","issue_comment_url":"https://api.github.com/repos/taskcluster/aws-provisioner/issues/comments{/number}","contents_url":"https://api.github.com/repos/taskcluster/aws-provisioner/contents/{+path}","compare_url":"https://api.github.com/repos/taskcluster/aws-provisioner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/taskcluster/aws-provisioner/merges","archive_url":"https://api.github.com/repos/taskcluster/aws-provisioner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/taskcluster/aws-provisioner/downloads","issues_url":"https://api.github.com/repos/taskcluster/aws-provisioner/issues{/number}","pulls_url":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls{/number}","milestones_url":"https://api.github.com/repos/taskcluster/aws-provisioner/milestones{/number}","notifications_url":"https://api.github.com/repos/taskcluster/aws-provisioner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/taskcluster/aws-provisioner/labels{/name}","releases_url":"https://api.github.com/repos/taskcluster/aws-provisioner/releases{/id}","deployments_url":"https://api.github.com/repos/taskcluster/aws-provisioner/deployments","created_at":"2014-01-22T00:44:52Z","updated_at":"2016-05-30T20:56:35Z","pushed_at":"2016-08-10T14:16:35Z","git_url":"git://github.com/taskcluster/aws-provisioner.git","ssh_url":"git@github.com:taskcluster/aws-provisioner.git","clone_url":"https://github.com/taskcluster/aws-provisioner.git","svn_url":"https://github.com/taskcluster/aws-provisioner","homepage":null,"size":11747,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":9,"forks":8,"open_issues":9,"watchers":4,"default_branch":"master"}},"base":{"label":"taskcluster:master","ref":"master","sha":"f3c5d0a8681b9f72af108406faf7bc815f89b711","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":16123958,"name":"aws-provisioner","full_name":"taskcluster/aws-provisioner","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/aws-provisioner","description":"AWS Provisioner for the TaskCluster","fork":false,"url":"https://api.github.com/repos/taskcluster/aws-provisioner","forks_url":"https://api.github.com/repos/taskcluster/aws-provisioner/forks","keys_url":"https://api.github.com/repos/taskcluster/aws-provisioner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/taskcluster/aws-provisioner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/taskcluster/aws-provisioner/teams","hooks_url":"https://api.github.com/repos/taskcluster/aws-provisioner/hooks","issue_events_url":"https://api.github.com/repos/taskcluster/aws-provisioner/issues/events{/number}","events_url":"https://api.github.com/repos/taskcluster/aws-provisioner/events","assignees_url":"https://api.github.com/repos/taskcluster/aws-provisioner/assignees{/user}","branches_url":"https://api.github.com/repos/taskcluster/aws-provisioner/branches{/branch}","tags_url":"https://api.github.com/repos/taskcluster/aws-provisioner/tags","blobs_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/refs{/sha}","trees_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/taskcluster/aws-provisioner/statuses/{sha}","languages_url":"https://api.github.com/repos/taskcluster/aws-provisioner/languages","stargazers_url":"https://api.github.com/repos/taskcluster/aws-provisioner/stargazers","contributors_url":"https://api.github.com/repos/taskcluster/aws-provisioner/contributors","subscribers_url":"https://api.github.com/repos/taskcluster/aws-provisioner/subscribers","subscription_url":"https://api.github.com/repos/taskcluster/aws-provisioner/subscription","commits_url":"https://api.github.com/repos/taskcluster/aws-provisioner/commits{/sha}","git_commits_url":"https://api.github.com/repos/taskcluster/aws-provisioner/git/commits{/sha}","comments_url":"https://api.github.com/repos/taskcluster/aws-provisioner/comments{/number}","issue_comment_url":"https://api.github.com/repos/taskcluster/aws-provisioner/issues/comments{/number}","contents_url":"https://api.github.com/repos/taskcluster/aws-provisioner/contents/{+path}","compare_url":"https://api.github.com/repos/taskcluster/aws-provisioner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/taskcluster/aws-provisioner/merges","archive_url":"https://api.github.com/repos/taskcluster/aws-provisioner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/taskcluster/aws-provisioner/downloads","issues_url":"https://api.github.com/repos/taskcluster/aws-provisioner/issues{/number}","pulls_url":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls{/number}","milestones_url":"https://api.github.com/repos/taskcluster/aws-provisioner/milestones{/number}","notifications_url":"https://api.github.com/repos/taskcluster/aws-provisioner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/taskcluster/aws-provisioner/labels{/name}","releases_url":"https://api.github.com/repos/taskcluster/aws-provisioner/releases{/id}","deployments_url":"https://api.github.com/repos/taskcluster/aws-provisioner/deployments","created_at":"2014-01-22T00:44:52Z","updated_at":"2016-05-30T20:56:35Z","pushed_at":"2016-08-10T14:16:35Z","git_url":"git://github.com/taskcluster/aws-provisioner.git","ssh_url":"git@github.com:taskcluster/aws-provisioner.git","clone_url":"https://github.com/taskcluster/aws-provisioner.git","svn_url":"https://github.com/taskcluster/aws-provisioner","homepage":null,"size":11747,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":9,"forks":8,"open_issues":9,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/98"},"html":{"href":"https://github.com/taskcluster/aws-provisioner/pull/98"},"issue":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/issues/98"},"comments":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/taskcluster/aws-provisioner/statuses/52ec7d18ca81f407e781d8f46b167060fd811074"}}}}
{"actor":{"display_login":"jonasfj"}}