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

[BUG] Check file is not empty before attempting to read pillar disk cache file #63729

Closed
1 of 9 tasks
dmurphy18 opened this issue Feb 16, 2023 · 1 comment · Fixed by #63732
Closed
1 of 9 tasks

[BUG] Check file is not empty before attempting to read pillar disk cache file #63729

dmurphy18 opened this issue Feb 16, 2023 · 1 comment · Fixed by #63732
Assignees
Labels
Bug broken, incorrect, or confusing behavior Sulfur v3006.0 release code name and version

Comments

@dmurphy18
Copy link
Contributor

dmurphy18 commented Feb 16, 2023

Description
During investigation of a customer issue, it was noted that msgpack will produce errors if it attempts to unpack an empty file.

Setup
User had enabled pillar caching, and then removed all pillar cached files etc. The code then create the replacement cache files, but they are empty and msgpack then will error when trying to unpack an empty file.
This was on RHEL 7 with msgpack 0.5.6.

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior

2023-02-09 15:43:02,891 [salt.master      :1916][ERROR   ][22024] Error in function _pillar:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/master.py", line 1910, in run_func
    ret = getattr(self, func)(load)
  File "/usr/lib/python3.6/site-packages/salt/master.py", line 1604, in _pillar
    clean_cache=load.get("clean_cache"),
  File "/usr/lib/python3.6/site-packages/salt/pillar/__init__.py", line 83, in get_pillar
    clean_cache=clean_cache,
  File "/usr/lib/python3.6/site-packages/salt/pillar/__init__.py", line 432, in __init__
    minion_cache_path=self._minion_cache_path(minion_id),
  File "/usr/lib/python3.6/site-packages/salt/utils/cache.py", line 34, in factory
    return CacheDisk(ttl, kwargs["minion_cache_path"], *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/utils/cache.py", line 89, in __init__
    self._read()
  File "/usr/lib/python3.6/site-packages/salt/utils/cache.py", line 147, in _read
    fp_, encoding=__salt_system_encoding__, raw=False
  File "/usr/lib/python3.6/site-packages/salt/utils/msgpack.py", line 145, in unpack
    return msgpack.unpack(stream, **_sanitize_msgpack_unpack_kwargs(kwargs))
  File "/usr/local/lib64/python3.6/site-packages/msgpack/__init__.py", line 58, in unpack
    return unpackb(data, **kwargs)
  File "msgpack/_unpacker.pyx", line 200, in msgpack._unpacker.unpackb
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfe in position 0: invalid start byte

Expected behavior
Not to throw errors in log files, by checking if file is not empty before attempting to load (unpack) with msgpack

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

This version report shows msgpack 0.5.6 but a correct installation should show msgpack 0.6.2, hence this is not a correct installation, and questions have been asked of the customer about how they have installed Salt. Response has not been received at this time.

   - Salt Version:
          Salt: 3005.1

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: 3.9.8
        pygit2: Not Installed
        Python: 3.6.8 (default, Aug 13 2020, 07:46:32)
  python-gnupg: Not Installed
        PyYAML: 3.13
         PyZMQ: 18.0.1
         smmap: Not Installed
       timelib: Not Installed
      Tornado: 4.5.3
           ZMQ: 4.1.4

Salt Extensions:
        SSEAPE: 8.9.0.5

System Versions:
          dist: rhel 7.9 Maipo
        locale: UTF-8
       machine: x86_64
       release: 3.10.0-1160.76.1.el7.x86_64
        system: Linux
       version: Red Hat Enterprise Linux Server 7.9 Maipo

Additional context
Add any other context about the problem here.

@dmurphy18 dmurphy18 added Bug broken, incorrect, or confusing behavior needs-triage Sulfur v3006.0 release code name and version labels Feb 16, 2023
@dmurphy18 dmurphy18 self-assigned this Feb 16, 2023
@dmurphy18
Copy link
Contributor Author

Closing PR #63732 merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Sulfur v3006.0 release code name and version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant