Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 add ability to send success notifications on webhook #5517

Merged

Conversation

prasrvenkat
Copy link
Contributor

@prasrvenkat prasrvenkat commented Aug 19, 2021

What

Ability to get notified on successful sync as well. This makes the success/failure notifications configurable with toggle on the webhook settings page. This is based on #2706 and will fix #4519

How

  • Adds two flags sendOnSuccess and sendOnFailure to indicate whether to send notification on success and/or failure.
  • Default value is true for sendOnFailure and false for sendOnSuccess to keep it same as current behavior.
  • Ability in front-end to toggle both on/off. I am not that familiar with frontend in general, but tried to get a working solution, which works with current state.
    • The toggle is not auto-save, its tied to the current formik form so reflects only after save changes.
    • Test will send different notifications for success and failure
  • The call site for successful notification is in JobSubmitter after finishing something that is a success. Let me know if this not the right place. Ideally, I thought notification will be downstream option after tracking but there was a notifier already available there so re-used it.
  • Migration test was failing so I had to add one, let me know if that is fine, especially the version

image

Recommended reading order

Common

  1. config.yaml and SlackNotificationConfiguration.yaml for reviewing the new boolean toggles.

Backend

  1. NotificationClient.java to see methods to notify success and failure separately.
  2. JobNotifier.java to see handling success/failure job notifications properly, especially the updated time handling.
  3. JobSubmitter.java to see call-site for invoking JobNotifier on successful job completion.
  4. Migrations and the new migration added.

Frontend

  1. WehbhookForm changes
  2. Other files.

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • docs/SUMMARY.md
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions
  • Connector added to connector index like described here

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here

Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions
  • Connector version bumped like described here

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here

Connector Generator

  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed.

@github-actions github-actions bot added area/api Related to the api area/platform issues related to the platform area/documentation Improvements or additions to documentation area/frontend labels Aug 19, 2021
@jrhizor jrhizor requested review from ChristopheDuong, davinchia and cgardens and removed request for davinchia August 19, 2021 21:00
Comment on lines +191 to +194
final String messageFormat = "Hello World! This is a test from Airbyte to try %s notification settings for sync %s";
final boolean failureNotified = notificationClient.notifyFailure(String.format(messageFormat, notification.getNotificationType(), "failures"));
final boolean successNotified = notificationClient.notifySuccess(String.format(messageFormat, notification.getNotificationType(), "successes"));
if (failureNotified || successNotified) {
Copy link
Contributor

@ChristopheDuong ChristopheDuong Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint is called for testing when editing the workspace settings (not a real sync notification)

Do we really need to send both success and failure (two notifications) as tests to try if the webhook works?

Only one "test" notification should be enough since they are using the same webhook URL and only differs in the messaging?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have strong preference. Only reasoning I had was the flags control success and/or failure notifications so it seemed right to send both if both are enabled and send one or other if only one of them (or none if none of them) is enabled.

If you feel strongly, I can drop one. Let me know.

Copy link
Contributor

@cgardens cgardens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prasrvenkat thank you for this PR! We really appreciate you digging into so many pieces of our system to put this together. I'm definitely happy to work with you to get this merged!

Here's the plan.

  • I left a few comments throughout the PR. LMK if anything doesn't make sense. I think there is only one significant change that I am suggesting around the data model.
  • I tried to address some of the questions you left in the PR body below. Again, lmk if anything doesn't make sense!
  • After we iterate one more time, I'll loop in our FE guy to help out with the refreshing issue you mentioned.

Ability in front-end to toggle both on/off. I am not that familiar with frontend in general, but tried to get a working solution.
The toggle is not auto-save, its tied to the current formik form so reflects only after save changes.

@jamakase can you take a look at the FE change in this PR and leave any feedback please?

The call site for successful notification is in JobSubmitter after finishing something that is a success. Let me know if this not the right place. Ideally, I thought notification will be downstream option after tracking but there was a notifier already available there so re-used it.

I agree with your assessment that this is not the ideal place. We want to change it so that the notifier happens from within a Temporal Activity. That being said, I think what you have done for now is a good compromise and we can move the call site in the future. So let's stick with what you have!

Migration test was failing so I had to add one, let me know if that is fine, especially the version

That looks right to me! I will re-review after you address some of the data model comments.

Thanks again!

@prasrvenkat prasrvenkat force-pushed the feat/add_sync_success_notification branch from db9bc2c to 2daf991 Compare August 24, 2021 17:03
@prasrvenkat
Copy link
Contributor Author

@prasrvenkat thank you for this PR! We really appreciate you digging into so many pieces of our system to put this together. I'm definitely happy to work with you to get this merged!

Here's the plan.

  • I left a few comments throughout the PR. LMK if anything doesn't make sense. I think there is only one significant change that I am suggesting around the data model.
  • I tried to address some of the questions you left in the PR body below. Again, lmk if anything doesn't make sense!
  • After we iterate one more time, I'll loop in our FE guy to help out with the refreshing issue you mentioned.

Ability in front-end to toggle both on/off. I am not that familiar with frontend in general, but tried to get a working solution.
The toggle is not auto-save, its tied to the current formik form so reflects only after save changes.

@jamakase can you take a look at the FE change in this PR and leave any feedback please?

The call site for successful notification is in JobSubmitter after finishing something that is a success. Let me know if this not the right place. Ideally, I thought notification will be downstream option after tracking but there was a notifier already available there so re-used it.

I agree with your assessment that this is not the ideal place. We want to change it so that the notifier happens from within a Temporal Activity. That being said, I think what you have done for now is a good compromise and we can move the call site in the future. So let's stick with what you have!

Migration test was failing so I had to add one, let me know if that is fine, especially the version

That looks right to me! I will re-review after you address some of the data model comments.

Thanks again!

Thanks for detailed review, appreciate it. I reworked based on your comment. Let me know what you think @cgardens.

@prasrvenkat prasrvenkat force-pushed the feat/add_sync_success_notification branch from 2daf991 to f23a84f Compare August 24, 2021 21:20
Copy link
Contributor

@cgardens cgardens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prasrvenkat thank you! the changes you made on the backend look good to me.

Once you are done iterating on @jamakase 's feedback on the frontend part, I will help you merge this.

@jamakase
Copy link
Contributor

My overall comment is next: is it actually a good idea to extend notifications interface for every new state we want to add? Is it possible that in the future, we may want to add more types of events on which we notify like onStart or update with some onProgress? Isn't it better to have generic method that will handle them as boolean notify(Job job, EventType type)

@prasrvenkat prasrvenkat requested a review from jamakase August 25, 2021 01:03
@prasrvenkat
Copy link
Contributor Author

prasrvenkat commented Aug 25, 2021

My overall comment is next: is it actually a good idea to extend notifications interface for every new state we want to add? Is it possible that in the future, we may want to add more types of events on which we notify like onStart or update with some onProgress? Isn't it better to have generic method that will handle them as boolean notify(Job job, EventType type)

If you are talking about toggles then we need individual states if we want to allow that level of control for all such states in notifications.
If you are talking about backend interface/methods, I was just trying to build on top of what is already there. Happy to rework to make it generic if you want. Let me know. cc @cgardens (But that refactoring might make more sense once we actually have such well-defined EventTypes defined which afaik is not there yet?)

@marcosmarxm
Copy link
Member

@prasrvenkat could you resolve the conflicts? After that we can start the process of merging this! thanks a lot

prasrvenkat and others added 2 commits September 6, 2021 18:52
@prasrvenkat prasrvenkat force-pushed the feat/add_sync_success_notification branch from d5a655f to 0e1fcf1 Compare September 7, 2021 02:06
@prasrvenkat
Copy link
Contributor Author

@prasrvenkat could you resolve the conflicts? After that we can start the process of merging this! thanks a lot

@marcosmarxm Done, let me know if anything else needs to be fixed. Thanks

Copy link
Contributor

@cgardens cgardens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prasrvenkat Awesome! This looks like it is ready to go. I am running the acceptance tests on this branch now. Once they are done I will merge.

Thanks for your patience. I was on vacation last week which is why review was postponed.

@prasrvenkat
Copy link
Contributor Author

@prasrvenkat Awesome! This looks like it is ready to go. I am running the acceptance tests on this branch now. Once they are done I will merge.

Thanks for your patience. I was on vacation last week which is why review was postponed.

Sounds good, thanks!

@cgardens cgardens changed the title add ability to send success notifications on webhook 🎉 add ability to send success notifications on webhook Sep 7, 2021
@cgardens cgardens merged commit 1ff177d into airbytehq:master Sep 7, 2021
@michel-tricot
Copy link
Contributor

Thank you @prasrvenkat. This is a great new feature!

@jrhizor
Copy link
Contributor

jrhizor commented Sep 7, 2021

🎉

@tuliren
Copy link
Contributor

tuliren commented Sep 10, 2021

This is a file based migration, which will mess up our database migration. It needs to be replaced with a Flyway migration.

@prasrvenkat prasrvenkat deleted the feat/add_sync_success_notification branch September 21, 2021 22:50
@sheshan-doye-konvergeai
Copy link

Is there a way I can update the webhook config programatically ( without going to setting and updating manually) ?

@prasrvenkat
Copy link
Contributor Author

Is there a way I can update the webhook config programatically ( without going to setting and updating manually) ?

It is part of the workspace so you can check that endpoint in APIs. I don't think a specific endpoint exists just for updating notification afaik.

@sheshan-doye-konvergeai
Copy link

the web hook doesn't work if endpoint is localhost or 0.0.0.0. it works if i set up my service with tools like ngrok.
but if airbyte is locally deployed it should also detect local endpoints. is it possible ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Related to the api area/documentation Improvements or additions to documentation area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow configuring a sync_success webhook
9 participants