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

Do not allow python2 to be added to salt-ssh tar by default #58389

Merged
merged 4 commits into from
Sep 30, 2020

Conversation

Ch3LL
Copy link
Contributor

@Ch3LL Ch3LL commented Sep 5, 2020

What does this PR do?

After dropping python 2 support from Salt we should not be adding python 2 modules to the salt-ssh binary by default. This PR addresses this by removing the code that automatically looked for python 2 modules and added them to the tar. This also ensures that ssh_ext_alternatives can still work with older python 2 supported salt versions. For example, when using ssh_ext_alternatives you can use the 2019.2.3 version of salt that is copied over in the tar. This version still supports Python 2 so we should still allow a user to use this version when using the ssh_ext_alternatives feature.

What issues does this PR fix or reference?

Fixes: #57647

Previous Behavior

Misleading error when python 3 is not installed on the target host:

        ERROR: Python version error. Recommendation(s) follow:
        - Install Python 2.6/2.7 Salt dependencies on the Salt SSH 
          master to interact with Python 2.6/2.7 targets
        - Install Python 3 on the target machine(s)

and python 2 modules added to the tar even though they will not be used.

New Behavior

New Error to inform user they need to install Python 3 on target host.

        ERROR: Python version error. Recommendation(s) follow:
        - Install Python 3 on the target machine(s)
        - You can use ssh_pre_flight or raw shell (-r) to install Python 3

Merge requirements satisfied?

Commits signed with GPG?

Yes

@Ch3LL Ch3LL requested a review from a team as a code owner September 5, 2020 02:27
@ghost ghost requested review from dwoz and removed request for a team September 5, 2020 02:27
@Ch3LL Ch3LL changed the title Do not allow python2 to be added to salt-ssh tar Do not allow python2 to be added to salt-ssh tar by default Sep 5, 2020
@Ch3LL
Copy link
Contributor Author

Ch3LL commented Sep 9, 2020

re-run full all

@sagetherage sagetherage added the Magnesium Mg release after Na prior to Al label Sep 14, 2020
@Ch3LL
Copy link
Contributor Author

Ch3LL commented Sep 15, 2020

re-run full all

1 similar comment
@sagetherage
Copy link
Contributor

re-run full all

@Ch3LL
Copy link
Contributor Author

Ch3LL commented Sep 25, 2020

re-run full all

@Ch3LL
Copy link
Contributor Author

Ch3LL commented Sep 28, 2020

re-run full all

Copy link
Contributor

@DmitryKuzmenko DmitryKuzmenko left a comment

Choose a reason for hiding this comment

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

LGTM

from tests.support.mock import MagicMock, patch


@pytest.fixture()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@pytest.fixture()
@pytest.fixture

"argv": argv,
"__role": "master",
"cachedir": tmpdir.strpath,
"extension_modules": tmpdir.join("extmods"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"extension_modules": tmpdir.join("extmods"),
"extension_modules": tmpdir.join("extmods").strpath,

DmitryKuzmenko
DmitryKuzmenko previously approved these changes Sep 29, 2020
@Ch3LL
Copy link
Contributor Author

Ch3LL commented Sep 29, 2020

@s0undt3ch ready for re-review

if _six.PY2:
import concurrent

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need this if _six.PY2 check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This keeps support for https://docs.saltstack.com/en/master/topics/ssh/ssh_ext_alternatives.html which allows you to bundle up an old version of salt that uses python 2 to use on the target host. This PR removes salt-ssh trying to automatically add python2 libraries automatically, but if a user is intentionally using ssh_ext_alternatives I think they should still be able to add python 2 libraries for older versions of salt.

@@ -381,7 +389,7 @@ def _get_supported_py_config(tops, extended_cfg):
for the supported Python interpreter versions. This is then written into the thin.tgz
archive and then verified by salt.client.ssh.ssh_py_shim.get_executable()

Note: Minimum default of 2.x versions is 2.7 and 3.x is 3.0, unless specified in namespaces.
Note: Minimum default of 3.x is 3.0, unless specified in namespaces.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure on 3.0, salt is only meant to work with 3.5, right?
Or for this piece of code it doesn't really matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will re-word this. You can even actually use 2.7 if using an older version of salt.

s0undt3ch
s0undt3ch previously approved these changes Sep 30, 2020
@dwoz dwoz merged commit 0127a78 into saltstack:master Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Magnesium Mg release after Na prior to Al
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] 06.11.2020 -- salt-ssh -- salt doesn't properly recognize appropriate python versions
5 participants