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

MS SQL Server Destination implementation #3195

Merged
merged 9 commits into from
May 17, 2021
Merged

MS SQL Server Destination implementation #3195

merged 9 commits into from
May 17, 2021

Conversation

masonwheeler
Copy link
Contributor

No description provided.

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

LGTM but requesting changes to confirm we're not forgetting a required param

config.get("username").asText(),
config.get("password").asText()));

if (config.has("ssl") && config.get("ssl").asBoolean()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ssl on v1, nice!

Copy link
Contributor

Choose a reason for hiding this comment

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

the SSL stuff is great. I think we need at least one test to check it. There are 2 options here:

  1. just right a one off unit test that runs check connection with SSL turned on and sanity check that it works.
  2. add a test in TestDestination that only runs if the destination is configurable with SSL. it would similarly probably just run check connection.

i don't have a really strong preference either way. 1 is probably easier 🤷‍♀️

Copy link
Member

@marcosmarxm marcosmarxm left a comment

Choose a reason for hiding this comment

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

I was very curious about the implementation of a target, so I was super 🕵️ leave some comments in general LGTM

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.

one question about why database is being removed from the implementation. after that's resolved i think this is good to go! nice work.

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

I believe we're using params not declared in spec.json so double checking on this.

additionalParameters.add("ssl=true");
additionalParameters.add("sslmode=require");
additionalParameters.add("encrypt=true");
if (config.has("trustServerCertificate") && config.get("trustServerCertificate").asBoolean()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

where would these params come from? I don't see this in spec.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been added to spec.json

additionalParameters.add("trustServerCertificate=true");
} else {
additionalParameters.add("trustServerCertificate=false");
additionalParameters.add("trustStore=" + config.get("trustStoreName").asText());
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not declared in spec.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has now been added to spec.json.

@sherifnada
Copy link
Contributor

sherifnada commented May 4, 2021

/test connector=destination-mssql

🕑 destination-mssql https://github.com/airbytehq/airbyte/actions/runs/811386089
✅ destination-mssql https://github.com/airbytehq/airbyte/actions/runs/811386089

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.

nice! a few more comments (each is described in more detail in line):

  1. SSL needs to be in the spec.
  2. SSL needs a test
  3. we shouldn't need to implement getDatabase

if (config.has("trustServerCertificate") && config.get("trustServerCertificate").asBoolean()) {
additionalParameters.add("trustServerCertificate=true");
} else {
additionalParameters.add("trustServerCertificate=false");
Copy link
Contributor

Choose a reason for hiding this comment

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

how is this getting set? it seems like you want to add some fields for users to optionally configure. if so you need to add them in the spec.json. ping me if the relationship between the 2 isn't clear and i can walk through it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has now been added to spec.json.

config.get("username").asText(),
config.get("password").asText()));

if (config.has("ssl") && config.get("ssl").asBoolean()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

the SSL stuff is great. I think we need at least one test to check it. There are 2 options here:

  1. just right a one off unit test that runs check connection with SSL turned on and sanity check that it works.
  2. add a test in TestDestination that only runs if the destination is configurable with SSL. it would similarly probably just run check connection.

i don't have a really strong preference either way. 1 is probably easier 🤷‍♀️

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.

Great! 3 other things you need to do in order to get this ready (other than what is mentioned in the comments below:

  1. Please make sure you add a documentation page. You can use the postgres one as an example.
  2. Add this destination to https://github.com/airbytehq/airbyte/blob/master/airbyte-config/init/src/main/resources/seed/destination_definitions.yaml so that this new destination will appear in the UI by default.
  3. Actually run a sync in the UI manually with this destination to sanity check that the E2E experience is good!

import org.testcontainers.containers.MSSQLServerContainer;
import org.testcontainers.utility.DockerImageName;

public class MSSQLIntegrationTestSSL extends TestDestination {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you create an issue that we should figure out a way to consolidate SSL tests for destinations, so that we don't have top copy and paste test classes like this. definitely don't think we need to worry about doing this right now, but i want us to keep track of it.

Comment on lines 55 to 89
"ssl": {
"title": "SSL Connection",
"description": "Encrypt data using SSL.",
"type": "boolean",
"default": false,
"order": 6
},
"trustServerCertificate": {
"title": "Trust Server Certificate",
"type": "boolean",
"default": false,
"description": "Whether or not to implicitly trust the server certificate without verification. (Useful for local test databases.)",
"examples": [true, false],
"order": 7
},
"trustStoreName": {
"title": "Trust Store Name",
"type": "string",
"description": "The full path (including filename) to the certificate trustStore file, which contains the list of certificates that the client trusts.",
"order": 8
},
"trustStorePassword": {
"title": "Trust Store Password",
"type": "string",
"description": "The password used to check the integrity of the trustStore data.",
"order": 9
},
"hostNameInCertificate": {
"title": "Host Name In Certificate",
"type": "string",
"description": "Specifies the host name of the server. The value of this property must match the subject property of the certificate.",
"order": 10
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it should be a oneOf for clarity. I would suggest replacing this configuration with something that looks like this:

      "ssl_method": {
        "title": "SSL Method",
        "type": "object",
        "description": "Encryption method to use when communicating with the database",
        "order": 6,
        "oneOf": [
          {
            "title": "Unencrypted",
            "additionalProperties": false,
            "description": "Data transfer will not be encrypted.",
            "required": ["ssl_method"],
            "properties": {
              "ssl_method": {
                "type": "string",
                "enum": ["unencrypted"],
                "default": "unencrypted"
              }
            }
          },
          {
            "title": "Encrypted (trust server certificate)",
            "additionalProperties": false,
            "description": "Use the cert provided by the server.",
            "required": ["ssl_method"],
            "properties": {
              "ssl_method": {
                "type": "string",
                "enum": ["encrypted_trust_server_certificate"],
                "default": "encrypted_trust_server_certificate"
              }
            }
          },
          {
            "title": "Encrypted (verify certificate)",
            "additionalProperties": false,
            "description": "Data transfer will not be encrypted.",
            "required": ["ssl_method", "trustStoreName", "trustStorePassword"],
            "properties": {
              "ssl_method": {
                "type": "string",
                "enum": ["encrypted_verify_certificate"],
                "default": "encrypted_verify_certificate"
              },
              "trustStoreName": {
                "title": "Trust Store Name",
                "type": "string",
                "description": "The full path (including filename) to the certificate trustStore file, which contains the list of certificates that the client trusts.",
                "order": 8
              },
              "trustStorePassword": {
                "title": "Trust Store Password",
                "type": "string",
                "description": "The password used to check the integrity of the trustStore data.",
                "order": 9
              },
              "hostNameInCertificate": {
                "title": "Host Name In Certificate",
                "type": "string",
                "description": "Specifies the host name of the server. The value of this property must match the subject property of the certificate.",
                "order": 10
              }
            }
          }
        ]
      }

This displays in the UI as follows:

Screen Shot 2021-05-12 at 3 15 19 PM
Screen Shot 2021-05-12 at 3 15 13 PM
Screen Shot 2021-05-12 at 3 15 08 PM

What do you think? If you adopt this configuration, you'll have to adjust how the config is parsed in the MSSQLDestination and the config that gets passed in the test suites.

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

LGTM with requested changes from charles

masonwheeler and others added 2 commits May 13, 2021 11:10
Co-authored-by: Charles <giardina.charles@gmail.com>
@sherifnada sherifnada linked an issue May 13, 2021 that may be closed by this pull request
Adding the destination to the list
Reworking SSL configuration to move internal information out of config
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.

Looks good. I think you're ready to ship it.

To deploy this you need to add this command as a comment in this PR:

/publish connector=connectors/source-mssql

You can see an example of this here. That will publish your docker container to docker hub. Once that succeeds, re-run the build in the PR. That should get you past the current build failure (which is just checking that the connector is published).

@masonwheeler
Copy link
Contributor Author

masonwheeler commented May 17, 2021

/publish connector=connectors/destination-mssql

🕑 connectors/destination-mssql https://github.com/airbytehq/airbyte/actions/runs/850263597
✅ connectors/destination-mssql https://github.com/airbytehq/airbyte/actions/runs/850263597

@masonwheeler masonwheeler dismissed marcosmarxm’s stale review May 17, 2021 15:51

After addressing the requested changes, GitHub is glitching, saying there are changes to address. Dismissing the review to get it to go away.

@masonwheeler masonwheeler merged commit a67c769 into master May 17, 2021
@masonwheeler masonwheeler deleted the issue_613 branch May 17, 2021 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL Server on premise as destination
6 participants