salt icon indicating copy to clipboard operation
salt copied to clipboard

`make html` fails in `salt/returners/mongo_return.py`

Open rhansen opened this issue 11 years ago • 9 comments

With the current tip of the develop branch (fc9b244) on Ubuntu 15.04:

$ make -C doc html
No need to update translations. Skipping...
sphinx-build -b html -d _build/doctrees    . _build/html
Running Sphinx v1.3.1
loading translations [en]... done
loading pickled environment... done
[autosummary] generating autosummary for: contents-1.rst, contents-2.rst, contents-3.rst, contents-4.rst, contents.rst, faq.rst, glossary.rst, index.rst, ref/auth/all/index.rst, ref/auth/all/salt.auth.auto.rst, ..., topics/tutorials/walkthrough.rst, topics/tutorials/walkthrough_macosx.rst, topics/tutorials/writing_tests.rst, topics/virt/disk.rst, topics/virt/index.rst, topics/virt/nic.rst, topics/windows/index.rst, topics/windows/windows-package-manager.rst, topics/windows/windows-specific-behavior.rst, topics/yaml/index.rst
Failed to import 'salt.modules.cytest': no module named salt.modules.cytest
Failed to import 'salt.states.libvirt': no module named salt.states.libvirt

Exception occurred:
  File "/home/rhansen/salt/salt/returners/mongo_return.py", line 60, in <module>
    version = '.'.join(version.split('.')[:2])
TypeError: 'Mock' object has no attribute '__getitem__'
The full traceback has been saved in /tmp/sphinx-err-2Gkv1Q.log, if you want to report the issue to the developers.

Full traceback info:

# Sphinx version: 1.3.1
# Python version: 2.7.9 (CPython)
# Docutils version: 0.12 release
# Jinja2 version: 2.7.3
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 244, in main
    opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/application.py", line 188, in __init__
    self._init_builder(buildername)
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/application.py", line 250, in _init_builder
    self.emit('builder-inited')
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/application.py", line 497, in emit
    results.append(callback(self, *args))
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/__init__.py", line 564, in process_generate_options
    base_path=app.srcdir)
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/generate.py", line 115, in generate_autosummary_docs
    items = find_autosummary_in_files(sources)
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/generate.py", line 228, in find_autosummary_in_files
    filename=filename))
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/generate.py", line 326, in find_autosummary_in_lines
    current_module, filename=filename))
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/generate.py", line 238, in find_autosummary_in_docstring
    real_name, obj, parent, modname = import_by_name(name)
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/__init__.py", line 473, in import_by_name
    obj, parent, modname = _import_by_name(prefixed_name)
  File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/__init__.py", line 502, in _import_by_name
    __import__(modname)
  File "/home/rhansen/salt/salt/returners/mongo_return.py", line 60, in <module>
    version = '.'.join(version.split('.')[:2])
TypeError: 'Mock' object has no attribute '__getitem__'

rhansen avatar Sep 29 '15 23:09 rhansen

Unsurprisingly, git bisect shows the problem is with 63153322b9b4ef8d852c8e8a1621a724b8a56ac7.

ping @rallytime @rhealitycheck

rhansen avatar Sep 29 '15 23:09 rhansen

Reverting both 63153322b9b4ef8d852c8e8a1621a724b8a56ac7 and e49a6dc449ea7731e433720a557030f28154be9e makes it possible to build the docs again.

rhansen avatar Sep 30 '15 00:09 rhansen

That's actually necessary in order for the returner to be compatible with older versions of pymongo. However I'm happy to take that out and simplify my life by just supporting people on 3.0 or newer.

rhealitycheck avatar Sep 30 '15 00:09 rhealitycheck

I think it would be better to leave your code in place and figure out a way to unbreak the documentation. But if that's not easy to do, then reverting those commits might be a reasonable temporary solution.

rhansen avatar Sep 30 '15 02:09 rhansen

@richardhansen Does #27474 solve this for you? (Note - that fix hasn't been merged forward from 2015.8 to develop yet, but I believe that change will solve your problem.)

rallytime avatar Sep 30 '15 03:09 rallytime

Oh! I spoke too soon about the merge forward. One was just merged in with #27531. Is this still a problem with the current HEAD of develop?

rallytime avatar Sep 30 '15 03:09 rallytime

Works for me now. Thanks!

rhansen avatar Sep 30 '15 03:09 rhansen

:+1:

rallytime avatar Sep 30 '15 03:09 rallytime

@rallytime thanks for finding the fix!

rhealitycheck avatar Sep 30 '15 11:09 rhealitycheck