Skip to content

[Bug]: cached Salt-SSH thin archive ignores extension and thin_extra_mods changes #70287

Description

@jpmckinney

What happened?

salt.utils.thin.gen_thin() rebuilds a cached archive only when the Salt version or the Python major version changed. Everything else that decides its contents is ignored, so after the archive exists in <cachedir>/thin/thin.tgz:

  • installing, upgrading or removing a Salt extension does not change what is shipped;
  • setting or changing thin_extra_mods does not change what is shipped.

Both keep silently using the stale archive until --regen-thin is passed. This is easy to hit right after diagnosing a missing module, because the fix (installing an extension, or adding its pure-Python dependency to thin_extra_mods) appears to do nothing.

Separately, thin_extra_mods cannot name a module inside a namespace package, which is what every Salt extension is:

  File "salt/utils/thin.py", line 485, in get_tops
    moddir, modname = os.path.split(import(mod).file)
TypeError: expected str, bytes or os.PathLike object, not NoneType

__import__("saltext.mysql") returns the saltext namespace package, whose __file__ is None. This is the "different error" mentioned in #70284. It only surfaces when the archive is actually regenerated, since the cache check above returns before get_tops() runs.

What did you expect to happen?

A cached thin archive is rebuilt when its configured contents change, and thin_extra_mods
accepts a module inside a namespace package.

Steps to reproduce the behavior

With saltext.mysql and pymysql importable:

from salt.utils.thin import gen_thin

gen_thin("/tmp/cache")                         # archive built
gen_thin("/tmp/cache", extra_mods="pymysql")   # same archive, pymysql not packed
$ tar tf /tmp/cache/thin/thin.tgz | grep -c py3/pymysql/
0

And, on a cache directory where the archive has to be generated:

gen_thin("/tmp/cache2", extra_mods="saltext.mysql", overwrite=True)  # TypeError

Versions

Reproduced on master (691bf09) and on 3008.2.

Type of salt install

pip (pypi)

Major version

3008.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

macos-15

salt --versions-report output

Salt Version:
          Salt: 3008.2

Python Version:
        Python: 3.12.11 (main, Jun  3 2025, 15:41:47) [Clang 17.0.0 (clang-1700.0.13.3)]

Dependency Versions:
          cffi: 2.1.1
      cherrypy: 18.10.0
  cryptography: 50.0.1
      dateutil: 2.9.0.post0
     docker-py: Not Installed
         gitdb: 4.0.12
     gitpython: 3.1.62
        Jinja2: 3.1.6
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.2.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 3.00
      pycrypto: Not Installed
  pycryptodome: 3.23.0
        pygit2: Not Installed
  python-gnupg: 0.5.6
        PyYAML: 6.0.3
         PyZMQ: 27.2.0
        relenv: Not Installed
         smmap: 5.0.3
       timelib: 0.3.0
       Tornado: 6.5.10
           ZMQ: 4.3.5

Salt Extensions:
 saltext.mysql: 1.1.0

Salt Package Information:
  Package Type: Not Installed

System Versions:
          dist: darwin 25.6.0
        locale: utf-8
       machine: arm64
       release: 25.6.0
        system: Darwin
       version: 26.6.2 arm64

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbroken, incorrect, or confusing behaviorneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions