{"action":"created","comment":{"url":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/comments/187858898","pull_request_review_id":119720965,"id":187858898,"diff_hunk":"@@ -51,6 +51,9 @@ const IOSCert = \"cert\"\n const IOSPassPhrase = \"passphrase\"\n const IOSIsProduction = \"isProduction\"\n \n+// time in seconds\n+const UPSPollingInterval = 10","path":"cmd/server/main.go","position":18,"original_position":18,"commit_id":"f44c59339501b81c03cb9dc16ce0b13139cbbffc","original_commit_id":"f44c59339501b81c03cb9dc16ce0b13139cbbffc","user":{"login":"pb82","id":1851198,"avatar_url":"https://avatars3.githubusercontent.com/u/1851198?v=4","gravatar_id":"","url":"https://api.github.com/users/pb82","html_url":"https://github.com/pb82","followers_url":"https://api.github.com/users/pb82/followers","following_url":"https://api.github.com/users/pb82/following{/other_user}","gists_url":"https://api.github.com/users/pb82/gists{/gist_id}","starred_url":"https://api.github.com/users/pb82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pb82/subscriptions","organizations_url":"https://api.github.com/users/pb82/orgs","repos_url":"https://api.github.com/users/pb82/repos","events_url":"https://api.github.com/users/pb82/events{/privacy}","received_events_url":"https://api.github.com/users/pb82/received_events","type":"User","site_admin":false},"body":"The loop isn't that costly (http request on the same pod, number of variants usually small). With this in mind i would rather leave it at 10 seconds for better response times.","created_at":"2018-05-14T07:39:35Z","updated_at":"2018-05-14T07:39:35Z","html_url":"https://github.com/aerogear/ups-config-operator/pull/34#discussion_r187858898","pull_request_url":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/34","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/comments/187858898"},"html":{"href":"https://github.com/aerogear/ups-config-operator/pull/34#discussion_r187858898"},"pull_request":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/34"}},"in_reply_to_id":187358479},"pull_request":{"url":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/34","id":186978055,"html_url":"https://github.com/aerogear/ups-config-operator/pull/34","diff_url":"https://github.com/aerogear/ups-config-operator/pull/34.diff","patch_url":"https://github.com/aerogear/ups-config-operator/pull/34.patch","issue_url":"https://api.github.com/repos/aerogear/ups-config-operator/issues/34","number":34,"state":"open","locked":false,"title":"Poll UPS to check for deleted variants","user":{"login":"darahayes","id":8656188,"avatar_url":"https://avatars1.githubusercontent.com/u/8656188?v=4","gravatar_id":"","url":"https://api.github.com/users/darahayes","html_url":"https://github.com/darahayes","followers_url":"https://api.github.com/users/darahayes/followers","following_url":"https://api.github.com/users/darahayes/following{/other_user}","gists_url":"https://api.github.com/users/darahayes/gists{/gist_id}","starred_url":"https://api.github.com/users/darahayes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darahayes/subscriptions","organizations_url":"https://api.github.com/users/darahayes/orgs","repos_url":"https://api.github.com/users/darahayes/repos","events_url":"https://api.github.com/users/darahayes/events{/privacy}","received_events_url":"https://api.github.com/users/darahayes/received_events","type":"User","site_admin":false},"body":"Related Ticket: https://issues.jboss.org/browse/AEROGEAR-2647\r\n\r\n## Description\r\n\r\nThis PR implements a mechanism where every 10 seconds, the service polls UPS to build a list of all variants. It then compares those variants against the UPS secrets created in K8s to see if there are any client configs that reference a variant that no longer exists in UPS. If we find a client UPS config that references a variant that does not exist, we assume the variant has been deleted and we trigger an unbind by deleting the servicebinding relating to that particular variant.\r\n\r\nOne issue I have found is that when we notice a variant has been deleted in UPS, we delete the servicebinding, this results in the bind secret being deleted which results in the `handleDelete` function being triggered which makes a call to UPS to delete the variant but the variant has already been deleted. Not sure what we should do here...\r\n\r\n### Some additional notes\r\n\r\n* I've also done some minor refactoring in the pushClient.go\r\n* My editor has some automatic `gofmt` thing so you may see some stylistic changes in places.\r\n* `main.go` is getting really bloated and readability is suffering big time. This should definitely be resolved in another PR but for now, I've tried to make some minor improvements by bringing the `main()`, `startWatchLoop()` and `startPollingUPS()` functions to the top.\r\n\r\n### To Do\r\n\r\n- [x] some of the function and variable names are probably not the best and could be renamed\r\n- [x] I'm trying to figure out how to make the code simpler to understand\r\n- [x] need to refactor the `pushClientOrDie` function to not die if an error occurs. \r\n- [x]  We can then implement the appropriate nil checks and error checks in places we use the pushClient.\r\n\r\n@pb82 would love to get your thoughts on this.\r\n\r\n## How to Verify\r\n\r\n### Setup\r\n\r\nTo make it easier to verify, I've pushed an image based off this PR to `docker.io/darahayes/ups-config-operator:master`. This means you don't need to clone the code and build locally. You can trust that the code builds based off the build in CircleCI.\r\n\r\n* Ensure you have the latest unifiedpush-apb image with `docker pull aerogear/catalog/unifiedpush-apb`\r\n* Provision UPS from the service catalog as normal. Do not create any bindings at this time\r\n* In OpenShift, go into deployments/ups and replace `docker.io/aerogear/ups-config-operator:master` with `docker.io/darahayes/ups-config-operator:master`. Hit save. This should kick off a new deployment.\r\n* Create some bindings on the UPS service for iOS/Android clients.\r\n* You should see the associated variants in UPS and also under resoruces/secrets in OpenShift you should find a secret with a name like `ups-secret-<my-client-id>-abcjd` inside the `config` property of this secret(s) you will find the config that should be consumed by the client. There will be fields for `android` and `ios` depending on the bindings you created.\r\n\r\n### Actions\r\n\r\n* In the UPS console, delete a variant.\r\n* After a few seconds, verify that the servicebinding associated with this variant has been removed.\r\n* verify that the corresponding `ios` or `android` config has been removed from the secret in OpenShift","created_at":"2018-05-09T16:42:55Z","updated_at":"2018-05-14T07:39:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e06fadda6d572b85a10f13cec9c37ba1c7b758f3","assignee":null,"assignees":[],"requested_reviewers":[{"login":"pb82","id":1851198,"avatar_url":"https://avatars3.githubusercontent.com/u/1851198?v=4","gravatar_id":"","url":"https://api.github.com/users/pb82","html_url":"https://github.com/pb82","followers_url":"https://api.github.com/users/pb82/followers","following_url":"https://api.github.com/users/pb82/following{/other_user}","gists_url":"https://api.github.com/users/pb82/gists{/gist_id}","starred_url":"https://api.github.com/users/pb82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pb82/subscriptions","organizations_url":"https://api.github.com/users/pb82/orgs","repos_url":"https://api.github.com/users/pb82/repos","events_url":"https://api.github.com/users/pb82/events{/privacy}","received_events_url":"https://api.github.com/users/pb82/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/34/commits","review_comments_url":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/34/comments","review_comment_url":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aerogear/ups-config-operator/issues/34/comments","statuses_url":"https://api.github.com/repos/aerogear/ups-config-operator/statuses/f44c59339501b81c03cb9dc16ce0b13139cbbffc","head":{"label":"aerogear:poll-ups-deleted-variants","ref":"poll-ups-deleted-variants","sha":"f44c59339501b81c03cb9dc16ce0b13139cbbffc","user":{"login":"aerogear","id":954205,"avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"repo":{"id":125085066,"name":"ups-config-operator","full_name":"aerogear/ups-config-operator","owner":{"login":"aerogear","id":954205,"avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aerogear/ups-config-operator","description":null,"fork":false,"url":"https://api.github.com/repos/aerogear/ups-config-operator","forks_url":"https://api.github.com/repos/aerogear/ups-config-operator/forks","keys_url":"https://api.github.com/repos/aerogear/ups-config-operator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aerogear/ups-config-operator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aerogear/ups-config-operator/teams","hooks_url":"https://api.github.com/repos/aerogear/ups-config-operator/hooks","issue_events_url":"https://api.github.com/repos/aerogear/ups-config-operator/issues/events{/number}","events_url":"https://api.github.com/repos/aerogear/ups-config-operator/events","assignees_url":"https://api.github.com/repos/aerogear/ups-config-operator/assignees{/user}","branches_url":"https://api.github.com/repos/aerogear/ups-config-operator/branches{/branch}","tags_url":"https://api.github.com/repos/aerogear/ups-config-operator/tags","blobs_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/refs{/sha}","trees_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aerogear/ups-config-operator/statuses/{sha}","languages_url":"https://api.github.com/repos/aerogear/ups-config-operator/languages","stargazers_url":"https://api.github.com/repos/aerogear/ups-config-operator/stargazers","contributors_url":"https://api.github.com/repos/aerogear/ups-config-operator/contributors","subscribers_url":"https://api.github.com/repos/aerogear/ups-config-operator/subscribers","subscription_url":"https://api.github.com/repos/aerogear/ups-config-operator/subscription","commits_url":"https://api.github.com/repos/aerogear/ups-config-operator/commits{/sha}","git_commits_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/commits{/sha}","comments_url":"https://api.github.com/repos/aerogear/ups-config-operator/comments{/number}","issue_comment_url":"https://api.github.com/repos/aerogear/ups-config-operator/issues/comments{/number}","contents_url":"https://api.github.com/repos/aerogear/ups-config-operator/contents/{+path}","compare_url":"https://api.github.com/repos/aerogear/ups-config-operator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aerogear/ups-config-operator/merges","archive_url":"https://api.github.com/repos/aerogear/ups-config-operator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aerogear/ups-config-operator/downloads","issues_url":"https://api.github.com/repos/aerogear/ups-config-operator/issues{/number}","pulls_url":"https://api.github.com/repos/aerogear/ups-config-operator/pulls{/number}","milestones_url":"https://api.github.com/repos/aerogear/ups-config-operator/milestones{/number}","notifications_url":"https://api.github.com/repos/aerogear/ups-config-operator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aerogear/ups-config-operator/labels{/name}","releases_url":"https://api.github.com/repos/aerogear/ups-config-operator/releases{/id}","deployments_url":"https://api.github.com/repos/aerogear/ups-config-operator/deployments","created_at":"2018-03-13T16:53:12Z","updated_at":"2018-05-09T16:50:50Z","pushed_at":"2018-05-10T10:54:08Z","git_url":"git://github.com/aerogear/ups-config-operator.git","ssh_url":"git@github.com:aerogear/ups-config-operator.git","clone_url":"https://github.com/aerogear/ups-config-operator.git","svn_url":"https://github.com/aerogear/ups-config-operator","homepage":null,"size":12768,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":5,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"aerogear:master","ref":"master","sha":"c7b61eb35f2a4c5d95631cf23349df8744c46729","user":{"login":"aerogear","id":954205,"avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"repo":{"id":125085066,"name":"ups-config-operator","full_name":"aerogear/ups-config-operator","owner":{"login":"aerogear","id":954205,"avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aerogear/ups-config-operator","description":null,"fork":false,"url":"https://api.github.com/repos/aerogear/ups-config-operator","forks_url":"https://api.github.com/repos/aerogear/ups-config-operator/forks","keys_url":"https://api.github.com/repos/aerogear/ups-config-operator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aerogear/ups-config-operator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aerogear/ups-config-operator/teams","hooks_url":"https://api.github.com/repos/aerogear/ups-config-operator/hooks","issue_events_url":"https://api.github.com/repos/aerogear/ups-config-operator/issues/events{/number}","events_url":"https://api.github.com/repos/aerogear/ups-config-operator/events","assignees_url":"https://api.github.com/repos/aerogear/ups-config-operator/assignees{/user}","branches_url":"https://api.github.com/repos/aerogear/ups-config-operator/branches{/branch}","tags_url":"https://api.github.com/repos/aerogear/ups-config-operator/tags","blobs_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/refs{/sha}","trees_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aerogear/ups-config-operator/statuses/{sha}","languages_url":"https://api.github.com/repos/aerogear/ups-config-operator/languages","stargazers_url":"https://api.github.com/repos/aerogear/ups-config-operator/stargazers","contributors_url":"https://api.github.com/repos/aerogear/ups-config-operator/contributors","subscribers_url":"https://api.github.com/repos/aerogear/ups-config-operator/subscribers","subscription_url":"https://api.github.com/repos/aerogear/ups-config-operator/subscription","commits_url":"https://api.github.com/repos/aerogear/ups-config-operator/commits{/sha}","git_commits_url":"https://api.github.com/repos/aerogear/ups-config-operator/git/commits{/sha}","comments_url":"https://api.github.com/repos/aerogear/ups-config-operator/comments{/number}","issue_comment_url":"https://api.github.com/repos/aerogear/ups-config-operator/issues/comments{/number}","contents_url":"https://api.github.com/repos/aerogear/ups-config-operator/contents/{+path}","compare_url":"https://api.github.com/repos/aerogear/ups-config-operator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aerogear/ups-config-operator/merges","archive_url":"https://api.github.com/repos/aerogear/ups-config-operator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aerogear/ups-config-operator/downloads","issues_url":"https://api.github.com/repos/aerogear/ups-config-operator/issues{/number}","pulls_url":"https://api.github.com/repos/aerogear/ups-config-operator/pulls{/number}","milestones_url":"https://api.github.com/repos/aerogear/ups-config-operator/milestones{/number}","notifications_url":"https://api.github.com/repos/aerogear/ups-config-operator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aerogear/ups-config-operator/labels{/name}","releases_url":"https://api.github.com/repos/aerogear/ups-config-operator/releases{/id}","deployments_url":"https://api.github.com/repos/aerogear/ups-config-operator/deployments","created_at":"2018-03-13T16:53:12Z","updated_at":"2018-05-09T16:50:50Z","pushed_at":"2018-05-10T10:54:08Z","git_url":"git://github.com/aerogear/ups-config-operator.git","ssh_url":"git@github.com:aerogear/ups-config-operator.git","clone_url":"https://github.com/aerogear/ups-config-operator.git","svn_url":"https://github.com/aerogear/ups-config-operator","homepage":null,"size":12768,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":5,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/34"},"html":{"href":"https://github.com/aerogear/ups-config-operator/pull/34"},"issue":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/issues/34"},"comments":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/aerogear/ups-config-operator/statuses/f44c59339501b81c03cb9dc16ce0b13139cbbffc"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"pb82"}}