Skip to content

[BUG] 3002.6 redis_cache.py not decoding responses #60273

Closed

Description

@major0

Description
Redis added a decode_responses parameter to deal with the change from Python2 ASCII strings to Python3 bytes. It appears that the redis_return.py source was updated to use this parameter in commit bdaef39 , but redis_cache.py was not.

Have not yet confirmed this is a bug. Noticed this when tracking down a bug in the redis_return.py (issue #60272 )

Proposed fix:

diff --git a/salt/cache/redis_cache.py b/salt/cache/redis_cache.py
index 21bdcae3f7..5c60cb52f1 100644
--- a/salt/cache/redis_cache.py
+++ b/salt/cache/redis_cache.py
@@ -243,6 +243,7 @@ def _get_redis_server(opts=None):
         REDIS_SERVER = StrictRedisCluster(
             startup_nodes=opts["startup_nodes"],
             skip_full_coverage_check=opts["skip_full_coverage_check"],
+            decode_responses=True,
         )
     else:
         REDIS_SERVER = redis.StrictRedis(
@@ -251,6 +252,7 @@ def _get_redis_server(opts=None):
             unix_socket_path=opts["unix_socket_path"],
             db=opts["db"],
             password=opts["password"],
+            decode_responses=True,
         )
     return REDIS_SERVER

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
$ salt --versions-report
Salt Version:
          Salt: 3002.6
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: unknown
      dateutil: 2.7.3
     docker-py: Not Installed
         gitdb: 2.0.6
     gitpython: 3.0.7
        Jinja2: 2.10.1
       libgit2: 0.28.3
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: 3.6.1
        pygit2: 1.0.3
        Python: 3.8.5 (default, Jan 27 2021, 15:41:15)
  python-gnupg: 0.4.5
        PyYAML: 5.3.1
         PyZMQ: 18.1.1
         smmap: 2.0.5
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.2
 
System Versions:
          dist: ubuntu 20.04 focal
        locale: utf-8
       machine: aarch64
       release: 5.4.0-1038-aws
        system: Linux
       version: Ubuntu 20.04 focal

Activity

  1. added
    bug
    on May 28, 2021
  2. marbx commented on May 31, 2021

    @marbx
    Contributor

    I had to use decode_responses=True since Python3.

    (Unfortunately, I have overlooked redis_cache and therefore reprogrammed it)

  3. changed the title [-][BUG] redis_cache.py not decoding responses[/-] [+][BUG] 3002.6 redis_cache.py not decoding responses[/+] on Jun 1, 2021
  4. s0undt3ch commented on Jun 28, 2021

    @s0undt3ch
    Contributor

    Valid issue, the module needs to be updated to use decode_responses=True

  5. added
    severity-critical
    and removed on Jun 28, 2021
  6. added
    severity-high
    Silicon v3004.0
    and removed
    severity-critical
    on Jun 28, 2021
  7. added this to the Silicon milestone on Jun 28, 2021
  8. s0undt3ch commented on Jun 28, 2021

    @s0undt3ch
    Contributor

    @Ch3LL also mentioned that the sdb redis module also suffers from this.

  9. modified the milestones: Silicon, Approved on Aug 9, 2021
  10. removed
    Silicon v3004.0
    on Oct 20, 2021
  11. waynew commented on Nov 18, 2021

    @waynew
    Contributor

    Was just trying to verify this and it turns out that for the redis_cache this
    isn't actually a problem. We're using salt.payload.dumps/loads to convert
    to/from bytes so text goes in and text comes out. My PR #61229 verifies this.
    However - sdb redis probably still isn't fixed.

    I'm going to go ahead and close this and open a new issue for sdb functional
    tests, and note that redis sdb module will need to be updated correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugseverity-high

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions