Skip to content

CDRIVER-4272: Add options and code to load the csfle dynamic library #968

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

Merged
merged 45 commits into from
Apr 27, 2022

Conversation

vector-of-bool
Copy link
Contributor

This is an initial basic implementation of the csfle options from the new CSE spec changes to support the dynamic library. This also adds mlib as a support library, which now requires some C99 support.

TODO: A a testing scenario that injects the csfle library. Ensure tests do not load a csfle from the system, only from the isolated test copy or relies on mongocrypd.

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

The new options and code to load csfle LGTM.

If mlib is only used for csfle_override_path, I suggest leaving it out for now. It may be better to add mlib as a separate PR to expedite unblocking other drivers testing with csfle.

…ions.

This is discovered because the mongocryptd spawner will cause the
atexit() code to run from the csfle library loaded in the
process.
@vector-of-bool vector-of-bool marked this pull request as ready for review April 20, 2022 20:21
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

Looking good overall.

The mongodl.py script looks robust and generally useful.

Great catch with the exit and allocation unsafety within the child process.

@vector-of-bool
Copy link
Contributor Author

@kevinAlbs I've found that I need to add an option for a test to completely disable csfle as the test will rely on mongocryptd behaviors. Take a look at the latest few commits.

@@ -123,6 +123,9 @@
"autoEncryptOpts": {
"kmsProviders": {
"aws": {}
},
"extra": {
"__csfleDisabled": true
Copy link
Contributor

Choose a reason for hiding this comment

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

Confirming, has the spec test this test file corresponds to been updated in the spec repo? If not, this test might not belong under the json directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. This is somewhat experimenting on how to "disable" csfle for testing. We don't want to publish an "official" way to disable csfle, but this spec test also changed behavior depending on whether csfle is present. It's a catch-22.

Copy link
Contributor

@eramongodb eramongodb Apr 22, 2022

Choose a reason for hiding this comment

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

I think it is fine to include the field in spec tests so long as it is clearly documented as for testing purposes only. However, if the specification repo will not be updated to match proposed test file contents, I would like the __csfleDisabled test to be moved out of the json directory and tested as a prose test instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This test failing may be a bug in csfle. csfle and mongocryptd should have the same output(slack thread for reference).

Copy link
Contributor

@eramongodb eramongodb left a comment

Choose a reason for hiding this comment

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

Other than the issue with __csfleDisabled in a modified unified spec test, LGTM.

@@ -123,6 +123,9 @@
"autoEncryptOpts": {
"kmsProviders": {
"aws": {}
},
"extra": {
"__csfleDisabled": true
Copy link
Contributor

@eramongodb eramongodb Apr 22, 2022

Choose a reason for hiding this comment

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

I think it is fine to include the field in spec tests so long as it is clearly documented as for testing purposes only. However, if the specification repo will not be updated to match proposed test file contents, I would like the __csfleDisabled test to be moved out of the json directory and tested as a prose test instead.

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

I left a suggestion to skip tests based on test environment rather than a __csfleDisabled option.

@@ -123,6 +123,9 @@
"autoEncryptOpts": {
"kmsProviders": {
"aws": {}
},
"extra": {
"__csfleDisabled": true
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test failing may be a bug in csfle. csfle and mongocryptd should have the same output(slack thread for reference).

"]",
"mongocryptdURI",
"mongodb://localhost:27021/?serverSelectionTimeoutMS=1000",
"__csfleDisabled",
Copy link
Collaborator

Choose a reason for hiding this comment

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

All drivers will need a solution to skip this prose test when running with csfle. I prefer not adding a hidden option to the API. I think it adds small risk that users rely on it.

I suggest only run this test if the test runner expects to use csfle. That could be passed through an environment variable. There is precedence: (e.g. MONGOC_TEST_IS_SERVERLESS, MONGOC_TEST_LOADBALANCED.

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

Latest changes and tests look good. Skipping Windows is not ideal, but seems low risk given that it has been validated locally, and libmongocrypt tests with the stub library in CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants