-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Broken fileserver.file_list, dir_list for gitpython using python3.x #54402
Comments
Thanks for addressing this and submitting an issue. I'll ping @saltstack/team-core to see what the verdict is. I'll added the appropriate labels to this. |
@xeacott Without looking at the code we should probably be wrapping it in a |
I took a closer look into the existing tests to see why this was not caught in the existing file_list test here Turns out, for testing repo So the root cause of this was using fileserver.file_list and other operations on a repo which has symlinks which in my case happens to be the salt-formula :) https://github.com/saltstack-formulas/salt-formula/blob/master/salt/pkgrepo/arch with python3. Note: shutil.copytree has a different behavior with python3 than python2. It would not copy the metadata in python2 if Python2:
Python3:
This should be harmless for this case. I have created a separate PR to fix the test to copy symlinks as symlinks and it does seem to generate the right result by encountering the bytes error: https://jenkinsci.saltstack.com/job/pr-kitchen-debian9-py3/job/PR-54453/1/console |
@waynew It would be great to hear some feedback so that this can be closed some time soon. |
I believe those fixes seem reasonable, but the definitely need some reviews. I don't know if you've seen the new SEP, but we're changing to a single-branch release model. If you could rebase and re-target your PRs to |
Looks like the automatic reviewer assignment is not functional for master branch. I have opened another PR to avoid the conflict resolution with previous ones. Awaiting review. |
This can be closed now as #54900 is merged. |
Description of Issue
gitpython returns
bytes
with python3.x when traversing the commit tree and it returnsstring
with python2.7. This leads to a failure infileserver.file_list
,fileserver.dir_list
for salt and more failures are also possible wherever this functionality is used.It also leads to errors being generated in logs while using
state.show_sls
.Steps to Reproduce Issue
Run salt master with gitpython using python3.x and attempt to
salt-run fileserver.file_list
Versions Report
PoC offending code
Offending code block: https://github.com/saltstack/salt/blob/develop/salt/utils/gitfs.py#L1320
Demonstration:
Possible solution
Instead of assuming string output from gitpython, we could expect bytes and handle it using
six.BytesIO
fake file object. This is also what I believe gitpython would prefer as @Byron mentions in this gitpython issue This works with python2.7 as well.If this approach of handling this in Salt itself makes sense, I will be happy to send a PR.
Thanks!
The text was updated successfully, but these errors were encountered: