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

Gracefully handle non-XML output in GlusterFS execution module. #34492

Merged
merged 3 commits into from
Jul 6, 2016
Merged

Gracefully handle non-XML output in GlusterFS execution module. #34492

merged 3 commits into from
Jul 6, 2016

Conversation

zer0def
Copy link
Contributor

@zer0def zer0def commented Jul 6, 2016

This PR gracefully handles non-XML gluster command output. An example would be to attempt to list an inappropriate amount of bricks compared to what stripe and replica options define, resulting in a non-descriptive ParseError.

Example execution module run before PR:

# salt 'gluster1' glusterfs.create gluster '["10.0.0.2:/mnt","10.0.0.3:/mnt","10.0.0.4:/mnt"]' stripe=2
gluster1:
    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1318, in _thread_return
        return_data = executor.execute()
      File "/usr/lib/python2.7/dist-packages/salt/executors/direct_call.py", line 28, in execute
        return self.func(*self.args, **self.kwargs)
      File "/usr/lib/python2.7/dist-packages/salt/modules/glusterfs.py", line 271, in create
        _gluster_xml(cmd)
      File "/usr/lib/python2.7/dist-packages/salt/modules/glusterfs.py", line 79, in _gluster_xml
        root = ET.fromstring(_gluster_output_cleanup(result))
      File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML
        parser.feed(text)
      File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1642, in feed
        self._raiseerror(v)
      File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
        raise err
    ParseError: syntax error: line 1, column 0

Example regular command output:

# gluster --xml --mode=script volume create gluster stripe 2 10.0.0.2:/mnt 10.0.0.3:/mnt 10.0.0.4:/mnt
number of bricks is not a multiple of stripe count

Example execution module run after PR:

# salt 'gluster1' glusterfs.create gluster '["10.0.0.2:/mnt","10.0.0.3:/mnt","10.0.0.4:/mnt"]' stripe=2
gluster1:
    ERROR: number of bricks is not a multiple of stripe count

@rallytime
Copy link
Contributor

Thank you @zer0def - always good to clean these types of things up.

@rallytime rallytime merged commit 6ce7cb9 into saltstack:2015.8 Jul 6, 2016
gitebra pushed a commit to gitebra/salt that referenced this pull request Jul 8, 2016
* upstream/develop: (168 commits)
  Pylint fix - import fnmatch
  documentation typo
  setup.py will not print each individual file
  Add apt key proxy support (saltstack#34407)
  Pylint fix
  for options method, authorization_type should always be NONE, otherwise CORS support will not work properly when other methods are using authorization_type  AWS_IAM.
  Add support to reject keys
  Add check.event (and clean a print)
  update docker_events dependency reference
  Lower the log level for modules which cannot be loaded to trace
  Integration test for grains data in templatized files (saltstack#34487)
  Rename some unit test files by adding _test (saltstack#34503)
  Improve top file merging documentation (saltstack#34505)
  Use correct resourcegroup for network interfaces
  Completely remove Python and verify
  Errors will stop the scripts
  Use Python 2.7.12 for Windows Build (saltstack#34468)
  Use -O in wget develop example in bootstrap tutorial
  remove unnecessary block parsing ip addrs for nova
  Gracefully handle non-XML output in GlusterFS execution module. (saltstack#34492)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants