Skip to content

Conversation

prestonvasquez
Copy link
Member

@@ -974,18 +974,26 @@ functions:
${PREPARE_SHELL}

cd ${DRIVERS_TOOLS}/.evergreen/csfle
source activate_venv.sh || :
Copy link
Member Author

Choose a reason for hiding this comment

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

This pipe was being used to prevent errors on the 3.0 1404 ubunutu version, which doesn't appear to have venv installed. To get around this, we check to see if it's installed before running activate_venv, since source is not cygwin-friendly.

source activate_venv.sh || :

# only run this if virtualenv is installed
if ${PYTHON3_BINARY} -m venv ./venv; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Were we getting errors from virtualenv not being installed? Or is this just precautionary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we get this error on 3.0 Ubuntu 14.04:

[2022/06/30 19:38:34.921] /usr/bin/python3: No module named virtualenv

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we not even try to start CSE servers when virtualenv is not available, then? Otherwise, I imagine 3.0 Ubuntu will start system failing.

Copy link
Member Author

Choose a reason for hiding this comment

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

This branch prevents a script error from exiting when a dependency of activate_venv.sh is not available on the distribution. The resulting background job won't have the necessary tools to start the server if activate_venv.sh doesn't run. Do you have an alternative approach in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, I keep forgetting that because we have pre_error_fails_tasks: true in the config, using something like exit 1 in a pre task will cause the entire test to fail. I think the current setup is fine, then.

To check my understanding: if virtualenv is not an available module attached to the PYTHON3_BINARY, we'll echo "error: no Module named venv", and the background task that starts the CSE servers in the next command will fail silently?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is my understanding, here is a test that does that: https://evergreen.mongodb.com/task/mongo_go_driver_tests_legacy_noauth_nossl__version~3.0_os_ssl_32~ubuntu1604_64_go_1_17_test_replicaset_noauth_nossl_patch_404a99a20576ef7d86f62910917c53baf0dd9319_62be16763e8e866769a62b83_22_06_30_21_33_07##comparehashes=404a99a20576ef7d86f62910917c53baf0dd9319&threads=maxonly

We could wrap the logic that starts the server in the next command, though? IIUC the background job will error silently, but that may not be the most graceful way of handling this?

Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Please add at least one Windows task that currently fails on the waterfall to the Evergreen build for this PR to confirm it resolves the failures.

kmstlsvenv/Scripts/python.exe -u kms_kmip_server.py --port 5698
else
./kmstlsvenv/bin/python3 -u kms_kmip_server.py --port 5698
fi
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary to use the Python 3 executable from the venv? Most scripts use the Evergreen expansion ${PYTHON3_BINARY} which is set to a different value on Windows vs Linux vs macOS builds. Could we replace these two different commands with

${PYTHON3_BINARY} -u kms_kmip_server.py --port 5698

?

Copy link
Member Author

@prestonvasquez prestonvasquez Jul 1, 2022

Choose a reason for hiding this comment

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

It is necessary, the python executable created through activate_venv.sh has dependencies that the pre-installed python3 binary does not have. This is what happens when using the pre-install exe:

Administrator@EC2AMAZ-KTJHJ9U ~/drivers-evergreen-tools/.evergreen/csfle
$ C:/python/Python38/python.exe -u kms_kmip_server.py --port 5698
Traceback (most recent call last):
  File "kms_kmip_server.py", line 6, in <module>
    from kmip.services.server import KmipServer
ModuleNotFoundError: No module named 'kmip'

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

They should be totally unrelated to this ticket, feel free to ignore. Opened GODRIVER-2483.

source activate_venv.sh || :

# only run this if virtualenv is installed
if ${PYTHON3_BINARY} -m venv ./venv; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, I keep forgetting that because we have pre_error_fails_tasks: true in the config, using something like exit 1 in a pre task will cause the entire test to fail. I think the current setup is fine, then.

To check my understanding: if virtualenv is not an available module attached to the PYTHON3_BINARY, we'll echo "error: no Module named venv", and the background task that starts the CSE servers in the next command will fail silently?

Copy link
Collaborator

@matthewdale matthewdale 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 👍

# TODO (GODRIVER-2239): Stabilize this pip install with a non-forked version of PyKMIP in
pip install git+https://github.com/kevinAlbs/PyKMIP.git@expand_tls12_ciphers
else
echo "error: No module named venv"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional: Is this actually an error case, or is it expected? If it's expected, consider changing the wording of this line to prevent confusion.

E.g.

Python module venv not found, skipping virtual environment setup...

@prestonvasquez prestonvasquez merged commit 6f2489e into mongodb:master Jul 7, 2022
@prestonvasquez prestonvasquez deleted the GODRIVER-2480 branch July 7, 2022 21:43
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