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

error "ok = out_fp.tell() == metadata['size']" in ansible #391

Closed
changchichung opened this issue Oct 8, 2018 · 4 comments
Closed

error "ok = out_fp.tell() == metadata['size']" in ansible #391

changchichung opened this issue Oct 8, 2018 · 4 comments

Comments

@changchichung
Copy link

@changchichung changchichung commented Oct 8, 2018

I want to create /etc/hosts for clients using ansible with mitogen , but there`s error message like "ok = out_fp.tell() == metadata['size']"

here is the environments

ansible version

2018-10-08 11:38:50 [minion@hqs010 ansiblecontrol]$ ansible --version
ansible 2.6.2
  config file = /home/minion/D/ansiblecontrol/ansible.cfg
  configured module search path = [u'/home/minion/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
2018-10-08 11:38:54 [minion@hqs010 ansiblecontrol]$

Client : ubuntu 18.04.1 / Python 3.6

Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-29-generic x86_64)
administrator@dcpc056:~$ python -V
Python 3.6.5
administrator@dcpc056:~$

ansible config

DEFAULT_ROLES_PATH(/home/minion/D/ansiblecontrol/ansible.cfg) = [u'/home/minion/D/ansiblecontrol/roles']
DEFAULT_STRATEGY(/home/minion/D/ansiblecontrol/ansible.cfg) = mitogen_linear
DEFAULT_STRATEGY_PLUGIN_PATH(/home/minion/D/ansiblecontrol/ansible.cfg) = [u'/home/minion/D/ansiblecontrol/mitogen-0.2.2/ansible_mitogen/plugins/strategy']
DEFAULT_TIMEOUT(/home/minion/D/ansiblecontrol/ansible.cfg) = 60
HOST_KEY_CHECKING(/home/minion/D/ansiblecontrol/ansible.cfg) = False

ansible tasks

- name: load client_hosts
  include_vars: client_hosts.yml

- name: load server_hosts
  include_vars: server_hosts.yml

- set_fact:
    _inventory_domain: "{{ inventory_hostname|inventory_domain }}"

- set_fact:
    client_hosts_lines: "{{ client_hosts|as_hostentries(_inventory_domain)|list }}"

- set_fact:
    server_hosts_lines: "{{ server_hosts|as_hostentries(_inventory_domain)|list }}"

- set_fact:
    hosts_lines: "{{ server_hosts_lines + client_hosts_lines }}"

- name: setup /etc/hosts
  template:
    src: etc/hosts.j2
    dest: /etc/hosts
    mode: 0755

ansible error message

The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 138, in run
    res = self._execute()
  File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 576, in _execute
    result = self._handler.run(task_vars=variables)
  File "/home/minion/D/ansiblecontrol/mitogen-0.2.2/ansible_mitogen/mixins.py", line 115, in run
    return super(ActionModuleMixin, self).run(tmp, task_vars)
  File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/action/template.py", line 201, in run
    result.update(copy_action.run(task_vars=task_vars))
  File "/home/minion/D/ansiblecontrol/mitogen-0.2.2/ansible_mitogen/mixins.py", line 115, in run
    return super(ActionModuleMixin, self).run(tmp, task_vars)
  File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/action/copy.py", line 495, in run
    module_return = self._copy_file(source_full, source_rel, content, content_tempfile, dest, task_vars, follow)
  File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/action/copy.py", line 282, in _copy_file
    remote_path = self._transfer_file(source_full, tmp_src)
  File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 352, in _transfer_file
    self._connection.put_file(local_path, remote_path)
  File "/home/minion/D/ansiblecontrol/mitogen-0.2.2/ansible_mitogen/connection.py", line 719, in put_file
    out_path=out_path
  File "/home/minion/D/ansiblecontrol/mitogen-0.2.2/ansible_mitogen/connection.py", line 594, in call
    return self.call_async(func, *args, **kwargs).get().unpickle()
  File "/home/minion/D/ansiblecontrol/mitogen-0.2.2/mitogen/core.py", line 487, in unpickle
    raise obj
CallError: builtins.KeyError: 'size'
  File "<stdin>", line 2049, in _dispatch_calls
  File "<stdin>", line 2041, in _dispatch_one
  File "master:/home/minion/D/ansiblecontrol/mitogen-0.2.2/ansible_mitogen/target.py", line 123, in transfer_file
    out_fp=fp,
  File "master:/home/minion/D/ansiblecontrol/mitogen-0.2.2/mitogen/service.py", line 953, in get
    ok = out_fp.tell() == metadata['size']


fatal: [hqpc056]: FAILED! => {
    "msg": "Unexpected failure during module execution.", 
    "stdout": ""
}

if the client is ubuntu 14.04 then the task runs ok ,
but if the client is ubuntu 18.04 , althrough I cant pass the dryrun ,
but the task failed when really runs
any suggestions ?

update:
if clients runs ubuntu 18.04 and python 2.7 , then the task works.

@dw
Copy link
Member

@dw dw commented Oct 8, 2018

Hi Eric!

Thanks for reporting this. Are you using a Git version of the extension, or a release version?

Please include the previous ~100 lines of "-vvv" output before the error occurs.

@changchichung
Copy link
Author

@changchichung changchichung commented Oct 9, 2018

thanks for reply , here is the ansisble output

TASK [hosts-1804 : setup /etc/hosts] *******************************************************************************************************************************************
task path: /home/minion/D/ansiblecontrol/roles/hosts-1804/tasks/main.yml:19
[pid 4334] 08:58:47.097779 D ansible_mitogen.mixins: _make_tmp_path(remote_user=None)
[pid 4334] 08:58:47.098198 D ansible_mitogen.mixins: _remote_expand_user(u'~/.ansible/tmp', sudoable=False)
[pid 4334] 08:58:47.099083 D mitogen: unix.connect(path='/tmp/mitogen_unix_sZKZoV')
[pid 4334] 08:58:47.099540 D mitogen: unix.connect(): local ID is 2010, remote is 0
[pid 4334] 08:58:47.101262 D mitogen: Context(2, u'ssh.hqpc056.abc.com').call_async(): posixpath.expanduser(u'~/.ansible/tmp')
[pid 4334] 08:58:47.103299 D ansible_mitogen.connection: Call took 4 ms: posixpath.expanduser(u'~/.ansible/tmp', use_login_context=True)
[pid 4334] 08:58:47.103476 D mitogen: Context(2, u'ssh.hqpc056.abc.com').call_async(): ansible_mitogen.target.make_temp_directory(base_dir=u'/home/administrator/.ansible/tmp')
[pid 4334] 08:58:47.105696 D ansible_mitogen.connection: Call took 2 ms: ansible_mitogen.target.make_temp_directory(use_login_context=True, base_dir=u'/home/administrator/.ansible/tmp')
[pid 4334] 08:58:47.105850 D ansible_mitogen.mixins: Temporary directory: u'/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc'
[pid 4268] 08:58:47.115408 D ansible_mitogen.services: ContextService().put(Context(4, u'ssh.hqpc056.abc.com.sudo.root'))
[pid 4334] 08:58:47.116211 D ansible_mitogen.mixins: _remote_expand_user(u'/etc/hosts', sudoable=True)
[pid 4334] 08:58:47.118575 D ansible_mitogen.planner: BinaryPlanner() rejected u'stat'
[pid 4334] 08:58:47.118833 D ansible_mitogen.planner: NewStylePlanner() accepted u'stat' (filename u'/usr/local/lib/python2.7/dist-packages/ansible/modules/files/stat.py')
[pid 4268] 08:58:47.120377 D mitogen: PushFileService().propagate_to(Context(4, u'ssh.hqpc056.abc.com.sudo.root'), u'/usr/local/lib/python2.7/dist-packages/ansible/modules/files/stat.py')
[pid 4334] 08:58:47.123460 D mitogen: Context(4, u'ssh.hqpc056.abc.com.sudo.root').call_async(): ansible_mitogen.target.run_module(kwargs={u'module_map': {u'builtin': [u'ansible.module_utils._text', u'ansible.module_utils.basic', u'ansible.module_utils.parsing', u'ansible.module_utils.parsing.convert_bool', u'ansible.module_utils.pycompat24', u'ansible.module_utils.six'], u'custom': []}, u'emulate_tty': True, u'module': u'stat', u'cwd': None, u'service_context': Context(0, None), u'extra_env': None, u'is_python': None, u'env': {}, u'path': u'/usr/local/lib/python2.7/dist-packages/ansible/modules/files/stat.py', u'runner_name': u'NewStyleRunner', u'interpreter_fragment': None, u'json_args': '{"_ansible_version": "2.6.2", "follow": false, "_ansible_selinux_special_fs": ["fuse", "nfs", "vboxsf", "ramfs", "9p"], "_ansible_no_log": false, "_ansible_module_name": "stat", "_ansible_remote_tmp": "~/.ansible/tmp", "_ansible_verbosity": 3, "_ansible_keep_remote_files": false, "_ansible_syslog_facility": "LOG_USER", "_ansible_socket": null, "checksum_algo": "sha1", "_ansible_diff": false, "get_checksum": true, "_ansible_debug": false, "_ansible_shell_executable": "/bin/sh", "_ansible_check_mode": false, "path": "/etc/hosts", "_ansible_tmpdir": "/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc"}'})
[pid 4268] 08:58:47.125859 D mitogen.ctx.ssh.hqpc056.abc.com: mitogen: PushFileService().store_and_forward('/usr/local/lib/python2.7/dist-packages/ansible/modules/files/stat.py', [blob: 19647 bytes], Context(4, 'ssh.hqpc056.abc.com.sudo.root'))
[pid 4268] 08:58:47.128623 D mitogen.ctx.ssh.hqpc056.abc.com.sudo.root: mitogen: Importer(): master doesn't know 'ansible.module_utils.parsing.'
[pid 4268] 08:58:47.130920 D mitogen.ctx.ssh.hqpc056.abc.com.sudo.root: mitogen: PushFileService().store_and_forward('/usr/local/lib/python2.7/dist-packages/ansible/modules/files/stat.py', [blob: 19647 bytes], Context(4, 'ssh.hqpc056.abc.com.sudo.root'))
[pid 4268] 08:58:47.133293 D mitogen.ctx.ssh.hqpc056.abc.com.sudo.root: mitogen: Importer(): master doesn't know 'ansible.module_utils.six.'
[pid 4334] 08:58:47.144788 D ansible_mitogen.connection: Call took 21 ms: ansible_mitogen.target.run_module(kwargs={u'module_map': {u'builtin': [u'ansible.module_utils._text', u'ansible.module_utils.basic', u'ansible.module_utils.parsing', u'ansible.module_utils.parsing.convert_bool', u'ansible.module_utils.pycompat24', u'ansible.module_utils.six'], u'custom': []}, u'emulate_tty': True, u'module': u'stat', u'cwd': None, u'service_context': Context(0, None), u'extra_env': None, u'is_python': None, u'env': {}, u'path': u'/usr/local/lib/python2.7/dist-packages/ansible/modules/files/stat.py', u'runner_name': u'NewStyleRunner', u'interpreter_fragment': None, u'json_args': '{"_ansible_version": "2.6.2", "follow": false, "_ansible_selinux_special_fs": ["fuse", "nfs", "vboxsf", "ramfs", "9p"], "_ansible_no_log": false, "_ansible_module_name": "stat", "_ansible_remote_tmp": "~/.ansible/tmp", "_ansible_verbosity": 3, "_ansible_keep_remote_files": false, "_ansible_syslog_facility": "LOG_USER", "_ansible_socket": null, "checksum_algo": "sha1", "_ansible_diff": false, "get_checksum": true, "_ansible_debug": false, "_ansible_shell_executable": "/bin/sh", "_ansible_check_mode": false, "path": "/etc/hosts", "_ansible_tmpdir": "/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc"}'})
[pid 4268] 08:58:47.145735 D mitogen: FileService(): registering u'/home/minion/.ansible/tmp/ansible-local-4258jRr5qV/tmp8EOVYi/hosts.j2'
[pid 4334] 08:58:47.146172 D mitogen: Context(4, u'ssh.hqpc056.abc.com.sudo.root').call_async(): ansible_mitogen.target.transfer_file(in_path=u'/home/minion/.ansible/tmp/ansible-local-4258jRr5qV/tmp8EOVYi/hosts.j2', out_path=u'/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc/source', context=Context(0, None))
[pid 4268] 08:58:47.148130 D mitogen.ctx.ssh.hqpc056.abc.com.sudo.root: ansible_mitogen.target: transfer_file('/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc/source') temporary file: /home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc/.ansible_mitogen_transfer-uw_pkhib.tmp
[pid 4268] 08:58:47.148338 D mitogen.ctx.ssh.hqpc056.abc.com.sudo.root: mitogen: get_file(): fetching '/home/minion/.ansible/tmp/ansible-local-4258jRr5qV/tmp8EOVYi/hosts.j2' from Context(0, None)
[pid 4268] 08:58:47.148629 D mitogen: Serving u'/home/minion/.ansible/tmp/ansible-local-4258jRr5qV/tmp8EOVYi/hosts.j2'
[pid 4268] 08:58:47.152504 D mitogen.ctx.ssh.hqpc056.abc.com.sudo.root: mitogen: get_file('/home/minion/.ansible/tmp/ansible-local-4258jRr5qV/tmp8EOVYi/hosts.j2'): received 58310 bytes
[pid 4334] 08:58:47.153762 D ansible_mitogen.connection: Call took 7 ms: ansible_mitogen.target.transfer_file(in_path=u'/home/minion/.ansible/tmp/ansible-local-4258jRr5qV/tmp8EOVYi/hosts.j2', out_path=u'/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc/source', context=Context(0, None))
[pid 4334] 08:58:47.154081 D ansible_mitogen.mixins: _remove_tmp_path(u'/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc')
[pid 4334] 08:58:47.154256 D mitogen: Context(4, u'ssh.hqpc056.abc.com.sudo.root').call_async(): shutil.rmtree(u'/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc')
[pid 4334] 08:58:47.155729 D ansible_mitogen.connection: Call took 1 ms: shutil.rmtree(u'/home/administrator/.ansible/tmp/ansible-mitogen-tmp-r5p75xlc')
[pid 4268] 08:58:47.157460 D ansible_mitogen.services: ContextService().put(Context(4, u'ssh.hqpc056.abc.com.sudo.root'))
[pid 4334] 08:58:47.157828 D mitogen: mitogen.core.Stream(u'unix_listener.4268').on_disconnect()
[pid 4268] 08:58:47.158013 D mitogen: mitogen.core.Stream(u'unix_client.4334').on_disconnect()
[pid 4334] 08:58:47.158225 D mitogen: Waker(Broker(0x7f0f0faa2c50) rfd=13, wfd=14).on_disconnect()
@dw dw added the user-reported label Oct 23, 2018
@dw
Copy link
Member

@dw dw commented Nov 6, 2018

Hi Eric,

Sorry for the delay. I thought this might be a duplicate of #364 but it seems not. It looks a lot like a bytes vs. Unicode issue, since you are crossing major interpreter versions. The fix should therefore be simple :)

Thanks for reporting this!

dw added a commit that referenced this issue Nov 7, 2018
This is a regression since moving FileService from a 2.6-compatible file
with unicode_literals set, to a <2.5-compatible file.
@dw dw closed this in 4553039 Nov 7, 2018
dw added a commit that referenced this issue Nov 7, 2018
- 3.x target test job support
- new 2.x->3.x Mitogen job
- 3.x runner regression
- 3.x importer regression
- #109
- #391
@dw
Copy link
Member

@dw dw commented Nov 7, 2018

Hi Eric!

Thanks a ton for reporting this -- it seems nobody is actually using the code against 3.x targets. This was a supported configuration a few months back, but something really terrible happened. It turns out 3.x targets were never added to the CI whatsoever. So 3.x is quite regressed just now.

You might want to wait for 0.2.4 before trying this again, once #426 has been closed.

Thanks again!


This is now on the master branch and will make it into the next release. To be updated when a new release is made, subscribe to https://networkgenomics.com/mail/mitogen-announce/

Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants