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

gce: Exclude GCENodeDriver objects from _expand_node result #40120

Merged
merged 1 commit into from Mar 20, 2017

Conversation

Projects
None yet
3 participants
@sergeizv
Copy link
Contributor

commented Mar 17, 2017

The dictionary returned by _expand_node contains libcloud's GCENodeDriver
objects which arent't properly serialized. With 'update_cachedir: True' setting
in salt-cloud config file show_instance fails because
utils['cloud.cache_node'] submits that dictionary to msgpack:

(py2-env) salt-test@tommynaut:~> salt-cloud -l debug -a show_instance foo
...
[ERROR   ] There was an error actioning machines: Cannot serialize <libcloud.compute.drivers.gce.GCENodeDriver object at 0x7ff3817cca10>
Traceback (most recent call last):
  File "/home/salt-test/salt/salt/cloud/cli.py", line 252, in run
    ret = mapper.do_action(names, kwargs)
  File "/home/salt-test/salt/salt/cloud/__init__.py", line 1527, in do_action
    vm_name, call='action'
  File "/home/salt-test/salt/salt/cloud/clouds/gce.py", line 277, in show_instance
    __utils__['cloud.cache_node'](node, __active_provider_name__, __opts__)
  File "/home/salt-test/salt/salt/utils/cloud.py", line 2921, in cache_node
    msgpack.dump(node, fh_)
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/__init__.py", line 38, in pack
    stream.write(packer.pack(o))
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 738, in pack
    self._pack(obj)
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 730, in _pack
    nest_limit - 1)
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 828, in _fb_pack_map_pairs
    self._pack(v, nest_limit - 1)
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 730, in _pack
    nest_limit - 1)
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 828, in _fb_pack_map_pairs
    self._pack(v, nest_limit - 1)
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 730, in _pack
    nest_limit - 1)
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 828, in _fb_pack_map_pairs
    self._pack(v, nest_limit - 1)
  File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 735, in _pack
    raise TypeError("Cannot serialize %r" % obj)
TypeError: Cannot serialize <libcloud.compute.drivers.gce.GCENodeDriver object at 0x7ff3817cca10>

Those GCENodeDriver objects don't contain info on the node itself so may be
safely excluded from _expand_node result. Remove ret['driver'] and
ret['extra']['zone']['driver'] keys containing them.

NOTE: As the purpose of _expand_node is to serialize libcloud node object, those GCENodeDriver objects at ret['driver'] and ret['extra']['zone']['driver'] are useless, so from my point of view removing them doesn't hurt backward compatibility. But I'm not pretty sure and would appreciate feedback on this. Maybe a correct solution would be setting those keys to None instead...

gce: Exclude GCENodeDriver objects from _expand_node result
The dictionary returned by _expand_node contains libcloud's GCENodeDriver
objects which arent't properly serialized. With 'update_cachedir: True' setting
in salt-cloud config file show_instance fails because
__utils__['cloud.cache_node'] submits that dictionary to msgpack:

    (py2-env) salt-test@tommynaut:~> salt-cloud -l debug -a show_instance foo
    ...
    [ERROR   ] There was an error actioning machines: Cannot serialize <libcloud.compute.drivers.gce.GCENodeDriver object at 0x7ff3817cca10>
    Traceback (most recent call last):
      File "/home/salt-test/salt/salt/cloud/cli.py", line 252, in run
        ret = mapper.do_action(names, kwargs)
      File "/home/salt-test/salt/salt/cloud/__init__.py", line 1527, in do_action
        vm_name, call='action'
      File "/home/salt-test/salt/salt/cloud/clouds/gce.py", line 277, in show_instance
        __utils__['cloud.cache_node'](node, __active_provider_name__, __opts__)
      File "/home/salt-test/salt/salt/utils/cloud.py", line 2921, in cache_node
        msgpack.dump(node, fh_)
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/__init__.py", line 38, in pack
        stream.write(packer.pack(o))
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 738, in pack
        self._pack(obj)
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 730, in _pack
        nest_limit - 1)
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 828, in _fb_pack_map_pairs
        self._pack(v, nest_limit - 1)
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 730, in _pack
        nest_limit - 1)
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 828, in _fb_pack_map_pairs
        self._pack(v, nest_limit - 1)
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 730, in _pack
        nest_limit - 1)
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 828, in _fb_pack_map_pairs
        self._pack(v, nest_limit - 1)
      File "/home/salt-test/py2-env/lib/python2.7/site-packages/msgpack/fallback.py", line 735, in _pack
        raise TypeError("Cannot serialize %r" % obj)
    TypeError: Cannot serialize <libcloud.compute.drivers.gce.GCENodeDriver object at 0x7ff3817cca10>

Those GCENodeDriver objects don't contain info on the node itself so may be
safely excluded from _expand_node result. Remove ret['driver'] and
ret['extra']['zone']['driver'] keys containing them.
@salt-jenkins

This comment has been minimized.

Copy link
Contributor

commented Mar 17, 2017

@sergeizv, thanks for your PR! By analyzing the history of the files in this pull request, we identified @erjohnso, @techhat and @gtmanfred to be potential reviewers.

@cachedout cachedout merged commit 33ba782 into saltstack:2016.3 Mar 20, 2017

6 checks passed

default Build finished.
Details
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #12231 — SUCCESS
Details
jenkins/PR/salt-pr-docs-n Pull Requests » salt-pr-docs-n #5067 — SUCCESS
Details
jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt Linode Ubuntu14.04 #9543 — SUCCESS
Details
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #9602 — SUCCESS
Details
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #9746 — SUCCESS
Details

@sergeizv sergeizv deleted the sergeizv:gce-expand-node-fix branch Mar 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.