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

🎉 Destination Snowflake + Normalization Core: Added OAuth support #11093

Merged
merged 146 commits into from
Mar 25, 2022

Conversation

grubberr
Copy link
Contributor

@grubberr grubberr commented Mar 13, 2022

What

Describe what the change is solving
It helps to add screenshots if it affects the frontend.

TODO:
** Release Normalization (NormalizationRunnerFactory and where else?)**

How

Describe the solution

Tested with local deployment:
Selection_050
Selection_051
Selection_049
Selection_048

Recommended reading order

  1. x.java
  2. y.python

🚨 User Impact 🚨

No breaking changes expected for existing connections, but eventually users will have to re-create connection to use new approach for either user\pass or oauth mode

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
    • Connector's bootstrap.md. See description and examples
    • 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

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
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as 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
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

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
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

etsybaev and others added 30 commits February 13, 2022 14:56
…rt-oauth

# Conflicts:
#	airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/SnowflakeDatabase.java
#	airbyte-integrations/connectors/destination-snowflake/src/test-integration/java/io/airbyte/integrations/destination/snowflake/SnowflakeDestinationIntegrationTest.java
Co-authored-by: timroes <timroes@users.noreply.github.com>
* fix(shopify): wrong type for tax_exemptions

abandoned_checkouts customer tax_exemptions had the wrong field type

* fix(shopify): wrong type for tax_exemptions

abandoned_checkouts customer tax_exemptions had the wrong field type

* bump connector version

Co-authored-by: marcosmarxm <marcosmarxm@gmail.com>
…an 50 (#10588)

* fix execute_in_batch

* add tests

* fix pre-commit config

Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
Co-authored-by: Eugene Kulak <kulak.eugene@gmail.com>
Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
Move the feature flag checks to the handler instead of the configuration API. This could have avoid some bug related to the missing flag check in the cloud project.
This is changing the check to see if a connection exist in order to make it more performant and more accurate. It makes sure that the workflow is reachable by trying to query it.
* add timeout to init container command

* add disk usage check into init command

* fix up disk usage checking and logs from init entrypoint

* run format
* test time ranges for cancellations

* try with wait

* fix cancellation on worker restart

* revert for CI testing that the test fails without the retry policy

* revert testing change

* matrix test the different possible cases

* re-enable new retry policy

* switch to no_retry

* switch back to new retry

* paramaterize correctly

* revert to no-retry

* re-enable new retry policy

* speed up test + fixees

* significantly speed up test

* fix ordering

* use multiple task queues in connection manager test

* use versioning for task queue change

* remove sync workflow registration for the connection manager queue

* use more specific example

* respond to parker's comments
* cast timestamp to date

* change test name

* fix corner cases

* fix corner cases 2

* format code

* changed method name

* add return typing

* bump version

* updated spec and def yaml

Co-authored-by: auganbay <auganenu@gmail.com>
as helm templates integers as float64, when using %d, it renders the value of external airbyte.minio.endpoint to "S3_MINIO_ENDPOINT: "http://minio-service:%!d(float64=9000)", therefore needed to be changed to %g
* Add custom survey_ids

* bump version

* Update survey_question schema

* Add changelog

* Allow null objects

* merge master and format

* Make all types safe with NULL and add survey_ids to all streams

* Make additional types safe with NULL

* Make additional types safe with NULL

* One last safe NULL type

* small fixes

* solve conflic

* small fixes

* revert fb wrong commit

* small fb correction

* bump connector version

Co-authored-by: marcosmarxm <marcosmarxm@gmail.com>
…om PR 9027) (#10631)

* Added associations to some CRM Object streams in Hubspot connector

* Added associations in the relevant schemas

* fix eof

* bump connector version

Co-authored-by: ksoenandar <kevin.soenandar@gmail.com>
* added transactions model

* changes

* fix

* few changes

* fix

* added new stream in configured_catalog*.json

* changes

* removed new stream in configured_catalog*.json

* solve small schema issues

* add eof

* bump connector version

Co-authored-by: marcosmarxm <marcosmarxm@gmail.com>
Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com>
Co-authored-by: benmoriceau <benmoriceau@users.noreply.github.com>
@grubberr
Copy link
Contributor Author

/publish connector=bases/base-normalization

2 similar comments
@grubberr
Copy link
Contributor Author

/publish connector=bases/base-normalization

@etsybaev
Copy link
Contributor

/publish connector=bases/base-normalization

@grubberr
Copy link
Contributor Author

grubberr commented Mar 24, 2022

/publish connector=bases/base-normalization

🕑 bases/base-normalization https://github.com/airbytehq/airbyte/actions/runs/2034970757
❌ bases/base-normalization https://github.com/airbytehq/airbyte/actions/runs/2034970757

@grubberr
Copy link
Contributor Author

/publish connector=bases/base-normalization

@grubberr
Copy link
Contributor Author

/publish connector=bases/base-normalization

@etsybaev etsybaev linked an issue Mar 24, 2022 that may be closed by this pull request
@grubberr
Copy link
Contributor Author

grubberr commented Mar 24, 2022

/publish connector=bases/base-normalization

🕑 bases/base-normalization https://github.com/airbytehq/airbyte/actions/runs/2036648814
✅ bases/base-normalization https://github.com/airbytehq/airbyte/actions/runs/2036648814

Comment on lines -67 to -71
"password": {
"description": "The password associated with the username.",
"type": "string",
"airbyte_secret": true,
"title": "Password",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does removing this field make the new connector version non-backward compatible with older configurations without migrating the old configs? (or update them?)

Can we tolerate config with the old password field being at this location in the spec? (making sure with a test too?)

Copy link
Contributor

@etsybaev etsybaev Mar 25, 2022

Choose a reason for hiding this comment

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

Hi @ChristopheDuong.
Nope, we have AdditionalProperties is set to true.
https://github.com/airbytehq/airbyte/pull/11093/files#diff-e1acb96aaf759d23333bec115cba9c1d1af77282bdd7dcdc1346240f7f871d01L3858

So it's not explicitly described in spec, but we handle this in java code:
https://github.com/airbytehq/airbyte/pull/11093/files#diff-0fd1ff4a11af6edb89860081578c13598aa6cdb289c3e6ceae2a9d44eb708b80R95

` if (credentials != null && credentials.has("auth_type") && "OAuth2.0".equals(
credentials.get("auth_type").asText())) {
LOGGER.debug("OAuth login mode is used");
...
...

} else if (credentials != null && credentials.has("password")) {
  LOGGER.debug("User/password login mode is used");
  // Username and pass login option is selected on UI
  dataSource.setUsername(username);
  dataSource.setPassword(credentials.get("password").asText());

} else {
  LOGGER.warn(
      "Obsolete User/password login mode is used. Please re-create a connection to use the latest connector's version");
  // case to keep the backward compatibility
  dataSource.setUsername(username);
  dataSource.setPassword(config.get("password").asText());
}`

and in normalization side:
https://github.com/airbytehq/airbyte/pull/11093/files#diff-76b45d3c5541ea23ab17d448c349c37f1a4d12bf1a604cfa7cceedb130588facR236

if credentials.get("auth_type") == "OAuth2.0":
dbt_config["authenticator"] = "oauth"
dbt_config["oauth_client_id"] = credentials["client_id"]
dbt_config["oauth_client_secret"] = credentials["client_secret"]
dbt_config["token"] = credentials["refresh_token"]
elif credentials.get("password"):
dbt_config["password"] = credentials["password"]
else:
dbt_config["password"] = config["password"]
return dbt_config

I also added a test to check it:
https://github.com/airbytehq/airbyte/pull/11093/files#diff-aa693e6356d71e05c008807f89cc10f5f2bfb495c14086472892cd08ca02436eR175

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, this sounds good!

I just arrived on this PR because I couldn't figure out why the snowflake tests were failing on other branches... it might have been nice to keep the old password field in the secret of the CI, so other branches without your changes wouldn't start failing though

@@ -169,6 +171,17 @@ protected void tearDown(final TestDestinationEnv testEnv) throws Exception {
database.close();
}

@Test
public void testBackwardCompatibilityAfterAddingOauth() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

// --------------------------------------------

private String extractAuthorizeUrl(JsonNode inputOAuthConfiguration) {
// var url = inputOAuthConfiguration.get("authorize_url");
Copy link
Contributor

Choose a reason for hiding this comment

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

is that needed?

Suggested change
// var url = inputOAuthConfiguration.get("authorize_url");

Copy link
Contributor

Choose a reason for hiding this comment

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

updated, thanks

props.getProperty("refresh_token"));
props.setProperty("token", token);

LOGGER.info("New refresh token has been obtained");
Copy link
Contributor

Choose a reason for hiding this comment

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

the new refresh token is never persisted back with the config though? does it need to be propagated all the way back to the airbyte DB?

Copy link
Contributor

Choose a reason for hiding this comment

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

updated, thanks

@etsybaev etsybaev temporarily deployed to more-secrets March 25, 2022 10:38 Inactive
@etsybaev etsybaev temporarily deployed to more-secrets March 25, 2022 10:38 Inactive
@etsybaev
Copy link
Contributor

etsybaev commented Mar 25, 2022

/publish connector=connectors/destination-snowflake

🕑 connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2039790563
✅ connectors/destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/2039790563

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

Successfully merging this pull request may close these issues.

Normalization Snowflake: support oauth Destination Snowflake: support oauth