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

Fix py2 thin dir issues #48234

Merged
merged 1 commit into from
Jun 25, 2018
Merged

Fix py2 thin dir issues #48234

merged 1 commit into from
Jun 25, 2018

Conversation

dwoz
Copy link
Contributor

@dwoz dwoz commented Jun 20, 2018

What does this PR do?

Fixes a missing thin directory dependency when running under python2 and adds regression test for fix.

What issues does this PR fix or reference?

#46507

Previous Behavior

Running salt-call in thin directory will fail due to missing concurrent.futures import which can break salt-ssh under Python 2.

New Behavior

salt-ssh runs under both Python 2 and Python 3

Tests written?

Yes

Commits signed with GPG?

Yes

@dwoz dwoz requested review from s0undt3ch and gtmanfred June 20, 2018 21:35
@ghost ghost requested review from a team June 20, 2018 21:35
@@ -1106,7 +1106,10 @@ def shim_cmd(self, cmd_str, extension='py'):
shim_tmp_file.write(salt.utils.to_bytes(cmd_str))

# Copy shim to target system, under $HOME/.<randomized name>
target_shim_file = '.{0}.{1}'.format(binascii.hexlify(os.urandom(6)), extension)
target_shim_file = '.{0}.{1}'.format(
binascii.hexlify(os.urandom(6)).decode('ascii'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

You likely only want to decode under py3 right?

Copy link
Contributor Author

@dwoz dwoz Jun 20, 2018

Choose a reason for hiding this comment

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

Good catch. I think we are alright though; decoding on python 2 doesn't cause an issue because the unicode string is decoded by format.

>>> '{}'.format(binascii.hexlify(os.urandom(6)).decode('ascii'))
'1f84d3dc6284'

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then, it looks good :)

Copy link
Contributor

@isbm isbm left a comment

Choose a reason for hiding this comment

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

@dwoz I have some questions before we move forward:

  • How exactly you've concluded that the problem is lack of concurrent.futures import?
  • Why this is affecting only Python 2 if the same module is not anywhere added also to Python 3?
  • Could you explain why Python 3 survives without this module at all? Because this module has to be added the same way as in Python 2. Yet it is not added and yet it works. Why?

Unless I am missing something, the concurrent.futures is only relevant to a transport under normal operation between Master and Minion, and so it is used by Tornado in tornado.concurrent.Futures class. Salt SSH is copying all the states to the target machine and executes all that locally without transport involved. So technically, this module is not supposed to be even triggered under Salt SSH operation.

In the original issue I see no evidence that this is about this module. And if it is, I still would like to see the evidence that lack of import of this module causing this (tracebacks, root of the cause etc).

And a very clear reproducer.

@s0undt3ch
Copy link
Collaborator

Python 3 includes concurrent.futures in stdlib.

@isbm
Copy link
Contributor

isbm commented Jun 21, 2018

@s0undt3ch right. Forgot to look at .spec that we explicitly require python-futures package for 2.x. 😣 That explains affection for Py2 only.

Any idea what exactly happening there and why?

@dwoz
Copy link
Contributor Author

dwoz commented Jun 21, 2018

@isbm Tornado is being included in the thin dir which is causing the need for concurrent.futures. I determined concurrent.futures is missing by running salt-call in a python 2 thin environment. The regression test in this PR confirms the issue and the fix. You can easily test this yourself by running the test without the rest of the patch.

Copy link
Contributor

@isbm isbm left a comment

Choose a reason for hiding this comment

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

@dwoz Ok, this makes sense. Thanks!

/me quietly ports the same thing to develop (Fluorine): #48289

@rallytime rallytime merged commit 3327181 into saltstack:2017.7 Jun 25, 2018
@dwoz dwoz deleted the thin_dir branch August 21, 2018 21:34
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.

5 participants