New: Added Pagerduty Integration (fixes #37) - #48
Conversation
|
Hey @vegetableman, thanks for working on this! On the features you said are left to do:
I think we need a way to let users link their Banjaxed and PagerDuty users together. The simplest way would be a form where they enter their PagerDuty user ID, but maybe we could pull a list of users from the PagerDuty API and let the user choose which one is them. We could even try to match the email address from their GitHub account to the one in PagerDuty, but that could be added later. Some feedback on the implementation:
I have a few other minor thoughts; I'll add them as inline comments on the code. |
There was a problem hiding this comment.
The with: :exception option here is important; it changes how invalid requests are handled, which can have security implications - without it you can no longer distinguish between a logged out user and a CSRF attack, for example.
Could you revert this change, and just skip the protection in the controller where it's necessary? As documented here: http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#method-i-protect_from_forgery
5d0158e to
a93c46d
Compare
|
@eugeneius Thanks for the detailed review. Have addressed most of the issues.
Please correct me if am wrong, an incident from pagerduty could be created by any program/user, it does not correspond to a single user. And the webhook api does not provide details on the user/program creating the incident. So, what could be
Agree with the form approach.
No pagerduty gem supports posting of notes as of yet. |
a93c46d to
0677804
Compare
|
Added migrate to travis to fix build issues. |
|
@eugeneius Could you review the changes? |
|
Travis CI shouldn't need to perform database migrations; you should commit the new version of You're right: PagerDuty incidents can be triggered in several ways, and sometimes there is no user involved - like when an automated alarm creates an incident, for example. I think there should be a user in the database named "PagerDuty", and this user should be the opener for all Banjaxed incidents created automatically by callbacks from PagerDuty. Here's a rake task that does that. I got the data from the GitHub API response for the PagerDuty organisation: https://api.github.com/users/PagerDuty namespace :pagerduty do
desc 'Create a PagerDuty user in the database'
task create_user: :environment do
PagerDutyGithubUser = Struct.new(:id, :login, :name, :avatar_url)
pagerduty_github_user = PagerDutyGithubUser.new(
766800,
'PagerDuty',
'',
'https://avatars.githubusercontent.com/u/766800?v=3'
)
User.create_or_update_from_github_user(pagerduty_github_user)
end
endWhen creating an incident from a PagerDuty callback, you could look this user up by its |
|
Would you mind splitting the AJAX updates for the incident page into its own pull request? I think it's a good idea, but a few things need work (it doesn't play nicely with the incident status filters, for example). The PagerDuty-specific parts of this are pretty close to being done, and it would be great to be able to merge them without having to wait for the AJAX stuff to be ready. |
0677804 to
b7139f8
Compare
|
Updated. PR #50 for ajax related changes. Also, couldn't find any issues with status filters. Could you provide more details? |
|
Is this ready to be merged?. Let me know if it's alright, I could write a few test cases. |
There was a problem hiding this comment.
This is related to the AJAX updating functionality, could you remove it here?
|
Sorry for the delay @vegetableman. I just made a few more small comments, but I think this is good to merge after that! If you're going to write tests, I think the part that most needs coverage is the PagerDuty controller - that bug with the code still running even if the PagerDuty user doesn't exist would have been caught by a test, for example. |
|
Making the However when I ran the This will cause problems in tests, since string IDs won't be saved correctly. This will also happen when using I think you should leave the It looks like full support for non-integer primary keys will be added in Rails 5: rails/rails@3628025 |
b7139f8 to
e805b9d
Compare
|
@eugeneius Have updated the code with tests and refactored it a bit. Thanks again for the review and the detailed pointer on primary keys. sure learnt a lot. |
e805b9d to
6fae944
Compare
|
Could this be merged? |
There was a problem hiding this comment.
This test passes, but the behaviour seems wrong. Shouldn't this be the ID of the incident that was created? https://github.com/vegetableman/banjaxed/blob/6fae9440b07489a61d715240b88dca4495d7af0e/app/services/pagerduty.rb#L17
There was a problem hiding this comment.
Since, the data get's regenerated every time the spec runs. was assuming it to be 0. Pushed a fix 👍 .
6fae944 to
a61db8e
Compare
|
hey @eugeneius , Sorry for troubling you. Would love to see this merged and make myself some bounty 😄 . Let me know if anything's left. |
New: Added Pagerduty Integration (fixes #37)
|
Thanks for sticking with this @vegetableman! |
|
Thanks again @eugeneius. you were awesome !. |
Also leaves the id column as an integer, see: #48 (comment)
fixes #37
An overview of this PR:-
Things left:
There is no support for other users in the app currently. How to go about it?
and tests.
To run:-
rake db:migratePAGERDUTY_API_KEY,PAGERDUTY_SUBDOMAIN,PAGERDUTY_REQUESTER_ID.PAGERDUTY_SUBDOMAIN.<subdomain>.pagerduty.com/api_keys and create the api key forPAGERDUTY_API_KEY.<subdomain>.pagerduty.com/users/<user_id>. Use<user_id>forPAGERDUTY_REQUESTER_ID.<app_domain>.herokuapp.com/pagerduty/callback to pagerduty for webhook.