{"action":"created","comment":{"url":"https://api.github.com/repos/spotify/gordon-gcp/pulls/comments/202189473","pull_request_review_id":136841718,"id":202189473,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjE4OTQ3Mw==","diff_hunk":"@@ -219,14 +242,16 @@ def _get_internal_ip(self, instance_data):\n         msg_logger = _utils.GEventMessageLogger(\n             self._logger, {'msg_id': event_message.msg_id})\n \n-        instance_data = await self._poll_for_instance_data(\n-            event_message.data['resourceName'], msg_logger)\n-        records = await self._create_rrecords(\n-            event_message.data, instance_data, msg_logger)\n-\n+        if event_message.data['action'] == 'additions':\n+            instance_data = await self._poll_for_instance_data(\n+                event_message.data['resourceName'], msg_logger)\n+            records = await self._create_rrecords(\n+                event_message.data, instance_data, msg_logger)\n+        elif event_message.data['action'] == 'deletions':\n+            instance_resource_url = event_message.data['resourceName']\n+            records = await self._get_matching_records(instance_resource_url)\n         msg_logger.debug(f'Enriched with resource record(s): {records}')\n         event_message.data['resourceRecords'].extend(records)\n-\n-        added_records = event_message.data['resourceRecords']\n-        msg = f'Enriched msg with {len(added_records)} resource record(s).'\n+        msg = (f\"Enriched msg with {len(event_message.data['resourceRecords'])}\"\n+               \" resource record(s).\")\n         event_message.append_to_history(msg, self.phase)","path":"src/gordon_gcp/plugins/service/enricher.py","position":92,"original_position":61,"commit_id":"0071f87bd2d6203846018224c1a7c0103543def4","original_commit_id":"f007fdc1d37013ee43408d74b84b1efe12becea3","user":{"login":"RochesterinNYC","id":1504464,"node_id":"MDQ6VXNlcjE1MDQ0NjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1504464?v=4","gravatar_id":"","url":"https://api.github.com/users/RochesterinNYC","html_url":"https://github.com/RochesterinNYC","followers_url":"https://api.github.com/users/RochesterinNYC/followers","following_url":"https://api.github.com/users/RochesterinNYC/following{/other_user}","gists_url":"https://api.github.com/users/RochesterinNYC/gists{/gist_id}","starred_url":"https://api.github.com/users/RochesterinNYC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RochesterinNYC/subscriptions","organizations_url":"https://api.github.com/users/RochesterinNYC/orgs","repos_url":"https://api.github.com/users/RochesterinNYC/repos","events_url":"https://api.github.com/users/RochesterinNYC/events{/privacy}","received_events_url":"https://api.github.com/users/RochesterinNYC/received_events","type":"User","site_admin":false},"body":"I've been thinking about this case, and it feels like the best behavior might be to drop/ack the message and appropriately log/record this somewhere?\r\n\r\nWe might not want to fully treat it as an error as the actual state == the desired state (i.e. we want no A records for the GCE host and the state in Google Cloud DNS is that there are no A records). However, with the logging/recording, we can keep track of how many times this is happening (because this happening too many times indicates something is wrong with the system).\r\n\r\nAny examples of this kind of behavior elsewhere in the codebase I can draw inspiration from?","created_at":"2018-07-12T21:46:15Z","updated_at":"2018-07-12T21:46:15Z","html_url":"https://github.com/spotify/gordon-gcp/pull/56#discussion_r202189473","pull_request_url":"https://api.github.com/repos/spotify/gordon-gcp/pulls/56","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/spotify/gordon-gcp/pulls/comments/202189473"},"html":{"href":"https://github.com/spotify/gordon-gcp/pull/56#discussion_r202189473"},"pull_request":{"href":"https://api.github.com/repos/spotify/gordon-gcp/pulls/56"}},"in_reply_to_id":201832476},"pull_request":{"url":"https://api.github.com/repos/spotify/gordon-gcp/pulls/56","id":200536948,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwNTM2OTQ4","html_url":"https://github.com/spotify/gordon-gcp/pull/56","diff_url":"https://github.com/spotify/gordon-gcp/pull/56.diff","patch_url":"https://github.com/spotify/gordon-gcp/pull/56.patch","issue_url":"https://api.github.com/repos/spotify/gordon-gcp/issues/56","number":56,"state":"open","locked":false,"title":"Add populating of 'resourceRecords' for GEventMessages that have the 'deletions' action","user":{"login":"RochesterinNYC","id":1504464,"node_id":"MDQ6VXNlcjE1MDQ0NjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1504464?v=4","gravatar_id":"","url":"https://api.github.com/users/RochesterinNYC","html_url":"https://github.com/RochesterinNYC","followers_url":"https://api.github.com/users/RochesterinNYC/followers","following_url":"https://api.github.com/users/RochesterinNYC/following{/other_user}","gists_url":"https://api.github.com/users/RochesterinNYC/gists{/gist_id}","starred_url":"https://api.github.com/users/RochesterinNYC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RochesterinNYC/subscriptions","organizations_url":"https://api.github.com/users/RochesterinNYC/orgs","repos_url":"https://api.github.com/users/RochesterinNYC/repos","events_url":"https://api.github.com/users/RochesterinNYC/events{/privacy}","received_events_url":"https://api.github.com/users/RochesterinNYC/received_events","type":"User","site_admin":false},"body":"**What this PR does / why we need it**:\r\n\r\nRight now, when parsing audit log pub/sub messages, the consumer sets the `resourceRecords` of the GEventMessage to an empty list, and the enricher assumes any that this empty`resourceRecords` needs to be enriched. However, that doesn't necessarily work for `deletions` actions, as when the enricher tries to find the related instance information from the GCP Instances API, the instance is already gone/deleted and will hence 404. \r\n\r\nThis PR adds the ability to populate the `resourceRecords` for GEventMessages that have the 'deletions' action via querying the Google Cloud DNS API for the records that Gordon initially created for the GCE host. Currently, this would only be the A record.\r\n\r\n**Special notes for your reviewer**:\r\n\r\nThe `name` and `type` parameters for the Google DNS API List endpoint are used to and only get the results/records that Gordon initially created for the GCE host (currently only the A record).\r\n\r\n**Release note**:\r\n<!--  Write your release note:\r\n1. Enter your extended release note in the below block. If the PR requires additional action from users switching to the new release, start the release note with the string \"action required: \".\r\n2. If no release note is required, just write \"NONE\".\r\n-->\r\n```release-note\r\nAdd populating of 'resourceRecords' for GEventMessages that have the 'deletions' action\r\n```\r\n","created_at":"2018-07-10T22:07:15Z","updated_at":"2018-07-12T21:46:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15bde024f558b0b6ddd1edc1a64df207421a2154","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/spotify/gordon-gcp/pulls/56/commits","review_comments_url":"https://api.github.com/repos/spotify/gordon-gcp/pulls/56/comments","review_comment_url":"https://api.github.com/repos/spotify/gordon-gcp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spotify/gordon-gcp/issues/56/comments","statuses_url":"https://api.github.com/repos/spotify/gordon-gcp/statuses/0071f87bd2d6203846018224c1a7c0103543def4","head":{"label":"spotify:feature/handle-deletion-events","ref":"feature/handle-deletion-events","sha":"0071f87bd2d6203846018224c1a7c0103543def4","user":{"login":"spotify","id":251374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTM3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"repo":{"id":115427246,"node_id":"MDEwOlJlcG9zaXRvcnkxMTU0MjcyNDY=","name":"gordon-gcp","full_name":"spotify/gordon-gcp","owner":{"login":"spotify","id":251374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTM3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spotify/gordon-gcp","description":"GCP Plugin for Gordon: Event-driven Cloud DNS","fork":false,"url":"https://api.github.com/repos/spotify/gordon-gcp","forks_url":"https://api.github.com/repos/spotify/gordon-gcp/forks","keys_url":"https://api.github.com/repos/spotify/gordon-gcp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spotify/gordon-gcp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spotify/gordon-gcp/teams","hooks_url":"https://api.github.com/repos/spotify/gordon-gcp/hooks","issue_events_url":"https://api.github.com/repos/spotify/gordon-gcp/issues/events{/number}","events_url":"https://api.github.com/repos/spotify/gordon-gcp/events","assignees_url":"https://api.github.com/repos/spotify/gordon-gcp/assignees{/user}","branches_url":"https://api.github.com/repos/spotify/gordon-gcp/branches{/branch}","tags_url":"https://api.github.com/repos/spotify/gordon-gcp/tags","blobs_url":"https://api.github.com/repos/spotify/gordon-gcp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spotify/gordon-gcp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spotify/gordon-gcp/git/refs{/sha}","trees_url":"https://api.github.com/repos/spotify/gordon-gcp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spotify/gordon-gcp/statuses/{sha}","languages_url":"https://api.github.com/repos/spotify/gordon-gcp/languages","stargazers_url":"https://api.github.com/repos/spotify/gordon-gcp/stargazers","contributors_url":"https://api.github.com/repos/spotify/gordon-gcp/contributors","subscribers_url":"https://api.github.com/repos/spotify/gordon-gcp/subscribers","subscription_url":"https://api.github.com/repos/spotify/gordon-gcp/subscription","commits_url":"https://api.github.com/repos/spotify/gordon-gcp/commits{/sha}","git_commits_url":"https://api.github.com/repos/spotify/gordon-gcp/git/commits{/sha}","comments_url":"https://api.github.com/repos/spotify/gordon-gcp/comments{/number}","issue_comment_url":"https://api.github.com/repos/spotify/gordon-gcp/issues/comments{/number}","contents_url":"https://api.github.com/repos/spotify/gordon-gcp/contents/{+path}","compare_url":"https://api.github.com/repos/spotify/gordon-gcp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spotify/gordon-gcp/merges","archive_url":"https://api.github.com/repos/spotify/gordon-gcp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spotify/gordon-gcp/downloads","issues_url":"https://api.github.com/repos/spotify/gordon-gcp/issues{/number}","pulls_url":"https://api.github.com/repos/spotify/gordon-gcp/pulls{/number}","milestones_url":"https://api.github.com/repos/spotify/gordon-gcp/milestones{/number}","notifications_url":"https://api.github.com/repos/spotify/gordon-gcp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spotify/gordon-gcp/labels{/name}","releases_url":"https://api.github.com/repos/spotify/gordon-gcp/releases{/id}","deployments_url":"https://api.github.com/repos/spotify/gordon-gcp/deployments","created_at":"2017-12-26T14:04:47Z","updated_at":"2018-07-10T22:16:17Z","pushed_at":"2018-07-12T21:38:11Z","git_url":"git://github.com/spotify/gordon-gcp.git","ssh_url":"git@github.com:spotify/gordon-gcp.git","clone_url":"https://github.com/spotify/gordon-gcp.git","svn_url":"https://github.com/spotify/gordon-gcp","homepage":null,"size":379,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2,"open_issues":3,"watchers":5,"default_branch":"develop"}},"base":{"label":"spotify:develop","ref":"develop","sha":"07a39c411ba0fc79f7407a6372ed7f901f479fca","user":{"login":"spotify","id":251374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTM3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"repo":{"id":115427246,"node_id":"MDEwOlJlcG9zaXRvcnkxMTU0MjcyNDY=","name":"gordon-gcp","full_name":"spotify/gordon-gcp","owner":{"login":"spotify","id":251374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTM3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spotify/gordon-gcp","description":"GCP Plugin for Gordon: Event-driven Cloud DNS","fork":false,"url":"https://api.github.com/repos/spotify/gordon-gcp","forks_url":"https://api.github.com/repos/spotify/gordon-gcp/forks","keys_url":"https://api.github.com/repos/spotify/gordon-gcp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spotify/gordon-gcp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spotify/gordon-gcp/teams","hooks_url":"https://api.github.com/repos/spotify/gordon-gcp/hooks","issue_events_url":"https://api.github.com/repos/spotify/gordon-gcp/issues/events{/number}","events_url":"https://api.github.com/repos/spotify/gordon-gcp/events","assignees_url":"https://api.github.com/repos/spotify/gordon-gcp/assignees{/user}","branches_url":"https://api.github.com/repos/spotify/gordon-gcp/branches{/branch}","tags_url":"https://api.github.com/repos/spotify/gordon-gcp/tags","blobs_url":"https://api.github.com/repos/spotify/gordon-gcp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spotify/gordon-gcp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spotify/gordon-gcp/git/refs{/sha}","trees_url":"https://api.github.com/repos/spotify/gordon-gcp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spotify/gordon-gcp/statuses/{sha}","languages_url":"https://api.github.com/repos/spotify/gordon-gcp/languages","stargazers_url":"https://api.github.com/repos/spotify/gordon-gcp/stargazers","contributors_url":"https://api.github.com/repos/spotify/gordon-gcp/contributors","subscribers_url":"https://api.github.com/repos/spotify/gordon-gcp/subscribers","subscription_url":"https://api.github.com/repos/spotify/gordon-gcp/subscription","commits_url":"https://api.github.com/repos/spotify/gordon-gcp/commits{/sha}","git_commits_url":"https://api.github.com/repos/spotify/gordon-gcp/git/commits{/sha}","comments_url":"https://api.github.com/repos/spotify/gordon-gcp/comments{/number}","issue_comment_url":"https://api.github.com/repos/spotify/gordon-gcp/issues/comments{/number}","contents_url":"https://api.github.com/repos/spotify/gordon-gcp/contents/{+path}","compare_url":"https://api.github.com/repos/spotify/gordon-gcp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spotify/gordon-gcp/merges","archive_url":"https://api.github.com/repos/spotify/gordon-gcp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spotify/gordon-gcp/downloads","issues_url":"https://api.github.com/repos/spotify/gordon-gcp/issues{/number}","pulls_url":"https://api.github.com/repos/spotify/gordon-gcp/pulls{/number}","milestones_url":"https://api.github.com/repos/spotify/gordon-gcp/milestones{/number}","notifications_url":"https://api.github.com/repos/spotify/gordon-gcp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spotify/gordon-gcp/labels{/name}","releases_url":"https://api.github.com/repos/spotify/gordon-gcp/releases{/id}","deployments_url":"https://api.github.com/repos/spotify/gordon-gcp/deployments","created_at":"2017-12-26T14:04:47Z","updated_at":"2018-07-10T22:16:17Z","pushed_at":"2018-07-12T21:38:11Z","git_url":"git://github.com/spotify/gordon-gcp.git","ssh_url":"git@github.com:spotify/gordon-gcp.git","clone_url":"https://github.com/spotify/gordon-gcp.git","svn_url":"https://github.com/spotify/gordon-gcp","homepage":null,"size":379,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2,"open_issues":3,"watchers":5,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/spotify/gordon-gcp/pulls/56"},"html":{"href":"https://github.com/spotify/gordon-gcp/pull/56"},"issue":{"href":"https://api.github.com/repos/spotify/gordon-gcp/issues/56"},"comments":{"href":"https://api.github.com/repos/spotify/gordon-gcp/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/spotify/gordon-gcp/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/spotify/gordon-gcp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spotify/gordon-gcp/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/spotify/gordon-gcp/statuses/0071f87bd2d6203846018224c1a7c0103543def4"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"RochesterinNYC"}}