saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

Elasticsearch `get_load` throws warning trying to return JSON #53472

Open calvinhp opened 5 years ago

calvinhp commented 5 years ago

This issue has shown up in a previous issue in the repo, but it appears that sometime along the line the elasticsearch Python API changed to return dictionaries instead of the current behavior which is to return a dictionary of the job cache.

Originally posted by @msteed in https://github.com/saltstack/salt/issues/23125#issuecomment-140512958

$ salt --versions-report
Salt Version:
           Salt: 2019.2.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.4.2
      docker-py: Not Installed
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.3
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.12 (default, Nov 12 2018, 14:36:49)
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: Ubuntu 16.04 xenial
         locale: UTF-8
        machine: x86_64
        release: 4.4.0-148-generic
         system: Linux
        version: Ubuntu 16.04 xenial
$ pip freeze | grep elastic
elasticsearch==6.4.0
$ salt salt elasticsearch.info
salt:
    ----------
    cluster_name:
        elasticsearch_calvin
    cluster_uuid:
        GjYi_ICTQJGolj3Lo42DQg
    name:
        Yv7_FY8
    tagline:
        You Know, for Search
    version:
        ----------
        build_date:
            2019-05-15T20:06:13.172855Z
        build_flavor:
            oss
        build_hash:
            65b6179
        build_snapshot:
            False
        build_type:
            tar
        lucene_version:
            7.7.0
        minimum_index_compatibility_version:
            5.0.0
        minimum_wire_compatibility_version:
            5.6.0
        number:
            6.8.0
Ch3LL commented 5 years ago

thanks for the PR :) any chance you can paste the error here just to make it easier for others who might be running into the same issue?

calvinhp commented 5 years ago

The error you will see when this is happening is the following:

vagrant@salt:~$ sudo salt salt test.ping
[WARNING ] Returner unavailable: expected string or buffer
salt:
    True

and in the debug mode you will see the following traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/client/__init__.py", line 1074, in get_iter_returns
    if self.returners['{0}.get_load'.format(self.opts['master_job_cache'])](jid) == {}:
  File "/usr/lib/python2.7/dist-packages/salt/returners/elasticsearch_return.py", line 410, in get_load
    return salt.utils.json.loads(data)
  File "/usr/lib/python2.7/dist-packages/salt/utils/json.py", line 98, in loads
    raise exc
TypeError: expected string or buffer
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

calvinhp commented 4 years ago

This PR is still open

stale[bot] commented 4 years ago

Thank you for updating this issue. It is no longer marked as stale.