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

salt-ssh can't work in python2.6 because "AttributeError: 'TarFile' object has no attribute '__exit__'" #7991

Closed
puluto opened this issue Oct 21, 2013 · 7 comments
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix severity-low 4th level, cosemtic problems, work around exists

Comments

@puluto
Copy link
Contributor

puluto commented Oct 21, 2013

salt-ssh can't work in python2.6

Process Process-1:
Traceback (most recent call last):
File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
  self.run()
File "/usr/lib64/python2.6/multiprocessing/process.py", line 88, in run
  self._target(*self._args, **self._kwargs)
File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 224, in  handle_routine
stdout, stderr = single.run()
File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 400, in run
stdout, stderr = self.run_wfunc()
File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 468, in run_wfunc
ret = json.dumps(self.wfuncs[self.fun](*self.arg))
File "/usr/lib/python2.6/site-packages/salt/client/ssh/wrapper/state.py", line 54, in sls
file_refs)
File "/usr/lib/python2.6/site-packages/salt/client/ssh/state.py", line 145, in prep_trans_tar
with tarfile.open(trans_tar, 'w:gz') as tfp:
AttributeError: 'TarFile' object has no attribute '__exit__'

that because the TarFile class don't have

'__exit__'

funtion in python2.6

if fixed that need replace the:

with tarfile.open(trans_tar, 'w:gz') as tfp:
    for root, dirs, files in os.walk(gendir):
        for name in files:
            full = os.path.join(root, name)
            tfp.add(full[len(gendir):].lstrip(os.sep))

to

try:
    tfp =  tarfile.open(trans_tar, 'w:gz')
    for root, dirs, files in os.walk(gendir):
        for name in files:
            full = os.path.join(root, name)
            tfp.add(full[len(gendir):].lstrip(os.sep))
except Exception, ex:
    print ex
finally:
    tfp.close()

in /usr/lib/python2.6/site-packages/salt/client/ssh/state.py file.

@clavinli
Copy link

thx, it works

@basepi
Copy link
Contributor

basepi commented Oct 21, 2013

Is this resolved with your above pull req, @puluto?

@terminalmage
Copy link
Contributor

salt-ssh tested against CentOS 6.4 with Python 2.6, and was not able to replicate. It looks like the pull request referenced above worked. Marking closed.

basepi pushed a commit that referenced this issue Oct 30, 2013
@dcapwell
Copy link

salt-ssh --version
salt-ssh 0.17.1

python --version
Python 2.6.6

cat /etc/*release*
CentOS release 6.4 (Final)

This is broken for me. I have a very simple state that will setup salt minions on all nodes.

cat /srv/salt/top.sls 
base:
  '*':
    - salt

cat /srv/salt/salt/init.sls 
/etc/salt/minion:
  file:
    - managed
    - source: salt://salt/minion.template
    - user: root
    - group: root

salt:
  pkg:
    - installed
    - name: salt-minion
    - require:
      - file: /etc/salt/minion
  service:
    - running
    - name: salt-minion
    - enable: True
    - require:
      - pkg: salt
    - watch:
      - pkg: salt
      - file: /etc/salt/minion

salt-ssh '*' state.highstate 2>&1 | head -n 25
Process Process-5:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
    self.run()
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 88, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 224, in handle_routine
Process Process-10:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
Process Process-9:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
    self.run()
    stdout, stderr = single.run()
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 88, in run
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 400, in run
    self.run()
    self._target(*self._args, **self._kwargs)
    stdout, stderr = self.run_wfunc()
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 224, in handle_routine
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 88, in run
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 468, in run_wfunc
    self._target(*self._args, **self._kwargs)
    ret = json.dumps(self.wfuncs[self.fun](*self.arg))

@terminalmage
Copy link
Contributor

@dcapwell This is clearly not the same error. Please open a separate issue.

@dcapwell
Copy link

Sorry, when used head it seems that it would cut off this error. Here is an example that shows the error. If I don't use head, I see "AttributeError: 'TarFile' object has no attribute 'exit'" for every node:

salt-ssh '*' state.highstate 2>&1 | head -n 40
Process Process-7:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
    self.run()
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 88, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 224, in handle_routine
    stdout, stderr = single.run()
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 400, in run
    stdout, stderr = self.run_wfunc()
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 468, in run_wfunc
    ret = json.dumps(self.wfuncs[self.fun](*self.arg))
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/wrapper/state.py", line 159, in highstate
    file_refs)
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/state.py", line 145, in prep_trans_tar
    with tarfile.open(trans_tar, 'w:gz') as tfp:
AttributeError: 'TarFile' object has no attribute '__exit__'
Process Process-2:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
    self.run()
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 88, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 224, in handle_routine
    stdout, stderr = single.run()
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 400, in run
    stdout, stderr = self.run_wfunc()
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/__init__.py", line 468, in run_wfunc
    ret = json.dumps(self.wfuncs[self.fun](*self.arg))
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/wrapper/state.py", line 159, in highstate
    file_refs)
  File "/usr/lib/python2.6/site-packages/salt/client/ssh/state.py", line 145, in prep_trans_tar
    with tarfile.open(trans_tar, 'w:gz') as tfp:
AttributeError: 'TarFile' object has no attribute '__exit__'
Process Process-10:
Traceback (most recent call last):
Process Process-22:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap

@s0undt3ch
Copy link
Collaborator

@dcapwell This is a known and fixed issue. 0.17.2 will have this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix severity-low 4th level, cosemtic problems, work around exists
Projects
None yet
Development

No branches or pull requests

6 participants