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

refactor: swap mssql driver to 'microsoft' driver #29694

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

cwegener
Copy link
Contributor

@cwegener cwegener commented Dec 7, 2023

Description:

The old driver ('denisenkom') is only receiving limited attention. The
new driver ('microsoft') is maintained by the vendor of the actual RDBMS
now. And is also the driver listed on golang.org

Link to tracking Issue:

#27200

Testing:

No integration tests exist for MSSQL, only for Oracle, Postgres and MySQL

TODO: add MSSQL integration tests.

Documentation:

Revelant documentation is available upstream:
https://github.com/microsoft/go-mssqldb/blob/main/README.md

@cwegener cwegener requested a review from a team December 7, 2023 20:43
Copy link

linux-foundation-easycla bot commented Dec 7, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@andrzej-stencel
Copy link
Member

It's shame we don't have integration tests for MS SQL Server, they would be ideal here to verify that the feature still works. 😅
@cwegener did you run any manual tests?

@cwegener cwegener requested a review from mx-psi as a code owner December 8, 2023 10:23
@github-actions github-actions bot added cmd/configschema configschema command cmd/otelcontribcol otelcontribcol command labels Dec 8, 2023
@andrzej-stencel
Copy link
Member

@cwegener I allowed myself to push the make gotidy commit to your branch, hope you don't mind 🙏

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

TODO: add MSSQL integration tests.

Is the TODO something you want to add to this PR or separately? If it's separate, please file an issue

@cwegener
Copy link
Contributor Author

cwegener commented Dec 8, 2023

It's shame we don't have integration tests for MS SQL Server, they would be ideal here to verify that the feature still works. 😅 @cwegener did you run any manual tests?

This patch has been used in production for a few months at 3 different customers.

EDIT: Furthermore, the connection strings from the legacy driver are compatible with the fork. And this change is not a breaking change.

@cwegener
Copy link
Contributor Author

cwegener commented Dec 8, 2023

Thanks for the PR!

TODO: add MSSQL integration tests.

Is the TODO something you want to add to this PR or separately? If it's separate, please file an issue

There is a separate issues for this that is linked to this PR.

#29695

@cwegener
Copy link
Contributor Author

cwegener commented Dec 8, 2023

@cwegener I allowed myself to push the make gotidy commit to your branch, hope you don't mind 🙏

Thanks! I only ran gotidy in the sqlqueryreceiver folder. my bad. 😄

@cwegener
Copy link
Contributor Author

@astencel-sumo @codeboten This patch is now rebased for v0.91.0 updates

Copy link
Member

@andrzej-stencel andrzej-stencel left a comment

Choose a reason for hiding this comment

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

Thank you!

@atoulme
Copy link
Contributor

atoulme commented Dec 14, 2023

Please fix new conflicts, sorry.

@cwegener
Copy link
Contributor Author

@atoulme All done.

_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
_ "github.com/microsoft/go-mssqldb"
_ "github.com/microsoft/go-mssqldb/integratedauth/krb5"
Copy link
Member

@dmitryax dmitryax Dec 14, 2023

Choose a reason for hiding this comment

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

Why do we need the second import?

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 is what the change is - Swapping the old 'denisenkom' driver for the new microsoft driver.

With regards to the github.com/microsoft/go-mssqldb/integratedauth/krb5 module, this is required to be able to use kerberos authentication mechanism.

Copy link
Member

Choose a reason for hiding this comment

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

Why only this one? Other authentication mechanisms also have init() func https://github.com/microsoft/go-mssqldb/tree/main/integratedauth

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

The reason that krb5 is added is because that is actually the auth mechanism that I have used so far myself.

We may actually need the other additional ones as well!

I will investigate and come back shortly.

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 is the source:
https://github.com/microsoft/go-mssqldb/blob/c902b674869e3f177b723cf2a5b1364c14efda47/README.md?plain=1#L93-L125

Basically, the summary is:

The driver has support to perform three different "integrated auth" mechanism, depending on which platform the driver is executing on:

https://github.com/microsoft/go-mssqldb/blob/main/README.md?plain=1#L129

  • On Windows, the default auth mechanism is something called SSPI, which is only available when building the driver for Windows https://github.com/microsoft/go-mssqldb/tree/main/integratedauth/winsspi (which basically automatically will chose either kerberos or ntlm)
  • On Linux, the two options are either ntlm or krb5 explicitely, with ntlm being the default in the driver

I do not know why the krb5 package was designed in such way that it needs an explicit import.

There is some dicsussion on the original thread when the feature was implemented, but I can't quickly glean why this kerberos features was designed in this particular way.

microsoft/go-mssqldb#35

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why only this one? Other authentication mechanisms also have init()

In summary. The Kerberos on Non-Windows integratedauth package is special compared to the winsspi and ntlm packages in that it is required to be imported explicitly, but I have no understanding of why the krb5 package was designed in this way.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Thanks. I see that other mechanisms are imported already https://github.com/microsoft/go-mssqldb/blob/main/auth_windows.go but krb5 is not

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@cwegener
Copy link
Contributor Author

cwegener commented Jan 2, 2024

Rebased and force pushed again.

@github-actions github-actions bot removed the Stale label Jan 2, 2024
**Description:**

The old driver ('denisenkom') is only receiving limited attention. The
new driver ('microsoft') is maintained by the vendor of the actual RDBMS
now. And is also the driver listed on golang.org

**Link to tracking Issue:**

open-telemetry#27200

**Testing:**

No integration tests exist for MSSQL, only for Oracle, Postgres and MySQL

TODO: add MSSQL integration tests.

**Documentation:**

Revelant documentation is available upstream:
https://github.com/microsoft/go-mssqldb/blob/main/README.md

make gotidy

Signed-off-by: Christoph Wegener <cwegener@users.noreply.github.com>
@cwegener
Copy link
Contributor Author

cwegener commented Jan 3, 2024

Rebased and force pushed again.

And one more time ..

_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
_ "github.com/microsoft/go-mssqldb"
_ "github.com/microsoft/go-mssqldb/integratedauth/krb5"
Copy link
Member

Choose a reason for hiding this comment

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

Ok. Thanks. I see that other mechanisms are imported already https://github.com/microsoft/go-mssqldb/blob/main/auth_windows.go but krb5 is not

@dmitryax dmitryax merged commit 0c27a3b into open-telemetry:main Jan 3, 2024
85 checks passed
@github-actions github-actions bot added this to the next release milestone Jan 3, 2024
cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this pull request Jan 10, 2024
…emetry#29694)

**Description:**

The old driver ('denisenkom') is only receiving limited attention. The
new driver ('microsoft') is maintained by the vendor of the actual RDBMS
now. And is also the driver listed on golang.org

**Link to tracking Issue:**

open-telemetry#27200

**Documentation:**

Revelant documentation is available upstream:
https://github.com/microsoft/go-mssqldb/blob/main/README.md

Signed-off-by: Christoph Wegener <cwegener@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/configschema configschema command cmd/otelcontribcol otelcontribcol command receiver/sqlquery SQL query receiver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants