salt icon indicating copy to clipboard operation
salt copied to clipboard

PR 48222 broke the GlusterFS module for versions not 4.0 and above

Open robertpenberthy opened this issue 8 years ago • 7 comments

Description of Issue/Question

PR #48222 breaks this module, if you're running a version of GlusterFS not 4.0 and above.

Setup

I upgraded from 2017.7.0 to 2018.3.3 (looks like this change was also backported to 2017.7 branch and later releases).

Run a version of GlusterFS not 4.0+. Specifically, I'm running a 3.x version (test environment has 3.7.9). The gluster --version command returns glusterfs 3.7.9 built on Mar 20 2016 03:19:49 with that version and so with the change from [1] to [-1] in the line.split is what causes the issue, as the module now returns 03:19:49 and therefore cannot be processed correctly.

I have no idea how a 4.0+ return looks like, but the PR broke this module for older versions of GlusteFS.

Steps to Reproduce Issue

With a GlusterFS version of 3.x, run just about any of the module commands, as they're passed through _gluster_xml method that calls _get_version(). You should get a stack trace back similar to mine:

An exception occurred in this state: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/state.py", line 1913, in call
    **cdata['kwargs'])
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1898, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/states/glusterfs.py", line 84, in peered
    peers = __salt__['glusterfs.peer_status']()
  File "/usr/lib/python2.7/site-packages/salt/modules/glusterfs.py", line 162, in peer_status
    root = _gluster_xml('peer status')
  File "/usr/lib/python2.7/site-packages/salt/modules/glusterfs.py", line 74, in _gluster_xml
    if _get_version() < (3, 6,):
  File "/usr/lib/python2.7/site-packages/salt/modules/glusterfs.py", line 40, in _get_version
    version = [int(i) for i in version]
ValueError: invalid literal for int() with base 10: '03:19:49'

Versions Report

salt --versions-report
Salt Version:
           Salt: 2018.3.3
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Jul 13 2018, 13:06:57)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.5.1804 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-862.14.4.el7.x86_64
         system: Linux
        version: CentOS Linux 7.5.1804 Core

robertpenberthy avatar Nov 30 '18 19:11 robertpenberthy

https://github.com/saltstack/salt/commit/d5d01f66988e79ff4d5e077af8b8c77fcb2dd071

robertpenberthy avatar Nov 30 '18 19:11 robertpenberthy

@Martin819 can you take a look at this, looks like you made the offending change.

Thanks, Daniel

gtmanfred avatar Nov 30 '18 19:11 gtmanfred

Maybe pulling out the version from the line with a regex might be a way that works for both 4.0+ versions and versions older than 4.0?

robertpenberthy avatar Nov 30 '18 19:11 robertpenberthy

Can someone could provide the full output of the gluster --version command for a 4.0+ version of Glusterfs?

I think it would be good to mock tests for the method, if possible, to validate the method can correctly return the version from the differing outputs. Here is the full output of that command from my machine:

glusterfs 3.7.9 built on Mar 20 2016 03:19:49
Repository revision: git://git.gluster.com/glusterfs.git
Copyright (c) 2006-2011 Gluster Inc. <http://www.gluster.com>
GlusterFS comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GlusterFS under the terms of the GNU General Public License.

robertpenberthy avatar Nov 30 '18 19:11 robertpenberthy

glusterfs 6.1
Repository revision: git://git.gluster.org/glusterfs.git
Copyright (c) 2006-2016 Red Hat, Inc. <https://www.gluster.org/>
GlusterFS comes with ABSOLUTELY NO WARRANTY.
It is licensed to you under your choice of the GNU Lesser
General Public License, version 3 or any later version (LGPLv3
or later), or the GNU General Public License, version 2 (GPLv2),
in all cases as published by the Free Software Foundation.

Manpage of debian stretch of glusterfs 3.8.8: https://manpages.debian.org/stretch/glusterfs-server/gluster.8.en.html

To run the program and display gluster prompt:

gluster [--remote-host=<gluster_node>] [--mode=script] [--xml]

(or)

To specify a command directly:

gluster [commands] [options] [--remote-host=<gluster_node>] [--mode=script] [--xml]

As the manpage suggests commands should be passed directly via the gluster command instead of passing the commands via stdin as the function _gluster_xml https://github.com/saltstack/salt/blob/develop/salt/modules/glusterfs.py#L69 does which runs through the interactive glusterfs prompt which also generates the welcome banner as described in the issue #52318.

The python bindings by gluster invoke the commands as arguments to gluster https://github.com/gluster/glustercli-python/blob/master/gluster/cli/utils.py#L34

Why must the commands be passed through stdin? The only use is here https://github.com/saltstack/salt/blob/develop/salt/modules/glusterfs.py#L76 with the comment:

# We will pass the command string as stdin to allow for much longer
# command strings. This is especially useful for creating large volumes
# where the list of bricks exceeds 128 characters.

How is there a limit of 128 chars? Is this specific to cmd.run?

dgengtek avatar Jun 13 '19 14:06 dgengtek

Hadn't realized someone had responded to this issue... don't know where the github notification went. Looks like from the output provided by dgengtek, the version is still the second item in the output and therefore there was no need to change the position check from 1 to -1. Assuming the version is always the second item on the line that starts with glusterfs, reverting the -1 back to 1 will resolve the version check issue.

robertpenberthy avatar Apr 14 '20 17:04 robertpenberthy

ZD-6204.

oeuftete avatar Jan 14 '21 14:01 oeuftete