Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Fix compatibility when map is actually imap. #3350

Merged
merged 1 commit into from
Nov 9, 2016

Conversation

christophebiocca
Copy link
Contributor

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

haproxy

ANSIBLE VERSION
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
SUMMARY

2 functions return map(some_stuff) but those do not work when map is actually imap.

While I still have no idea why or how the map call is being swapped out while still running in python 2.7, this change will fix the following error, as well as improve py3 compatiblity:

Before:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Value of unknown type: <type 'itertools.imap'>, <itertools.imap object at 0x7fdb35c4b110>, pysys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0); from {'changed': True, 'command': ['get weight servers/server8888; enable server servers/server8888; set weight servers/server8888 0'], 'state_after': <itertools.imap object at 0x7fdb35c4b110>, 'invocation': {'module_args': {'shutdown_sessions': False, 'socket': '/var/run/haproxy/admin.sock', 'weight': '0', 'wait_interval': 5, 'wait_retries': 25, 'state': 'enabled', 'fail_on_not_found': False, 'host': 'server8888', 'wait': False, 'backend': 'servers'}}, 'output': ['0 (initial 1)'], 'state_before': <itertools.imap object at 0x7fdb35bd9fd0>}[state_after]
fatal: [server0.staging.internal.encircleapp.com]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_z7IB5b/ansible_module_haproxy.py\", line 350, in <module>\n    main()\n  File \"/tmp/ansible_z7IB5b/ansible_module_haproxy.py\", line 345, in main\n    ansible_haproxy.act()\n  File \"/tmp/ansible_z7IB5b/ansible_module_haproxy.py\", line 317, in act\n    self.module.exit_json(**self.command_results)\n  File \"/tmp/ansible_z7IB5b/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1799, in exit_json\n  File \"/tmp/ansible_z7IB5b/ansible_modlib.zip/ansible/module_utils/basic.py\", line 388, in remove_values\n  File \"/tmp/ansible_z7IB5b/ansible_modlib.zip/ansible/module_utils/basic.py\", line 388, in <genexpr>\n  File \"/tmp/ansible_z7IB5b/ansible_modlib.zip/ansible/module_utils/basic.py\", line 399, in remove_values\nTypeError: Value of unknown type: <type 'itertools.imap'>, <itertools.imap object at 0x7fdb35c4b110>, pysys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0); from {'changed': True, 'command': ['get weight servers/server8888; enable server servers/server8888; set weight servers/server8888 0'], 'state_after': <itertools.imap object at 0x7fdb35c4b110>, 'invocation': {'module_args': {'shutdown_sessions': False, 'socket': '/var/run/haproxy/admin.sock', 'weight': '0', 'wait_interval': 5, 'wait_retries': 25, 'state': 'enabled', 'fail_on_not_found': False, 'host': 'server8888', 'wait': False, 'backend': 'servers'}}, 'output': ['0 (initial 1)'], 'state_before': <itertools.imap object at 0x7fdb35bd9fd0>}[state_after]\n", "module_stdout": "", "msg": "MODULE FAILURE"}

After

TASK [Drain HTTP connections from webserver] ***********************************
ok: [server0.-------]

While I still have no idea why or how the `map` call is being swapped out while still running in python 2.7, this change will fix the following error, as well as improve py3 compatiblity:

```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Value of unknown type: <type 'itertools.imap'>, <itertools.imap object at 0x7fdb35c4b110>, pysys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0); from {'changed': True, 'command': ['get weight servers/server8888; enable server servers/server8888; set weight servers/server8888 0'], 'state_after': <itertools.imap object at 0x7fdb35c4b110>, 'invocation': {'module_args': {'shutdown_sessions': False, 'socket': '/var/run/haproxy/admin.sock', 'weight': '0', 'wait_interval': 5, 'wait_retries': 25, 'state': 'enabled', 'fail_on_not_found': False, 'host': 'server8888', 'wait': False, 'backend': 'servers'}}, 'output': ['0 (initial 1)'], 'state_before': <itertools.imap object at 0x7fdb35bd9fd0>}[state_after]
fatal: [server0.staging.internal.encircleapp.com]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_z7IB5b/ansible_module_haproxy.py\", line 350, in <module>\n    main()\n  File \"/tmp/ansible_z7IB5b/ansible_module_haproxy.py\", line 345, in main\n    ansible_haproxy.act()\n  File \"/tmp/ansible_z7IB5b/ansible_module_haproxy.py\", line 317, in act\n    self.module.exit_json(**self.command_results)\n  File \"/tmp/ansible_z7IB5b/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1799, in exit_json\n  File \"/tmp/ansible_z7IB5b/ansible_modlib.zip/ansible/module_utils/basic.py\", line 388, in remove_values\n  File \"/tmp/ansible_z7IB5b/ansible_modlib.zip/ansible/module_utils/basic.py\", line 388, in <genexpr>\n  File \"/tmp/ansible_z7IB5b/ansible_modlib.zip/ansible/module_utils/basic.py\", line 399, in remove_values\nTypeError: Value of unknown type: <type 'itertools.imap'>, <itertools.imap object at 0x7fdb35c4b110>, pysys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0); from {'changed': True, 'command': ['get weight servers/server8888; enable server servers/server8888; set weight servers/server8888 0'], 'state_after': <itertools.imap object at 0x7fdb35c4b110>, 'invocation': {'module_args': {'shutdown_sessions': False, 'socket': '/var/run/haproxy/admin.sock', 'weight': '0', 'wait_interval': 5, 'wait_retries': 25, 'state': 'enabled', 'fail_on_not_found': False, 'host': 'server8888', 'wait': False, 'backend': 'servers'}}, 'output': ['0 (initial 1)'], 'state_before': <itertools.imap object at 0x7fdb35bd9fd0>}[state_after]\n", "module_stdout": "", "msg": "MODULE FAILURE"}
```
@leewin12
Copy link

leewin12 commented Nov 3, 2016

+1
I had experienced same problem and came to report, but you make it right on time!
thank you!

@dougstanley
Copy link

It's because map is being imported from the six module, which swaps it out with imap. If that helps any. I just got done tracking this problem myself.

@gregdek
Copy link
Contributor

gregdek commented Nov 7, 2016

Thanks @christophebiocca. To the current maintainers, @ravibhure please review according to guidelines (http://docs.ansible.com/ansible/developing_modules.html#module-checklist) and comment with text 'shipit', 'needs_revision' or 'close_me' as appropriate.

[This message brought to you by your friendly Ansibull-bot.]

@ravibhure
Copy link
Contributor

+1 shipit
Thanks @christophebiocca

@nerzhul
Copy link
Contributor

nerzhul commented Nov 9, 2016

Same problem here, please merge it and include it in next bugfix release, it's very anoying :(

@gregdek
Copy link
Contributor

gregdek commented Nov 9, 2016

Thanks again to @christophebiocca for this PR, and thanks @ravibhure for reviewing. Marking for inclusion.

[This message brought to you by your friendly Ansibull-bot.]

@resmo resmo merged commit b23740e into ansible:devel Nov 9, 2016
resmo pushed a commit that referenced this pull request Nov 9, 2016
While I still have no idea why or how the `map` call is being swapped out while still running in python 2.7, this change will fix the following error, as well as improve py3 compatibility.
(cherry picked from commit b23740e)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants