saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.14k stars 5.47k forks source link

[TECH DEBT] Salt fails to load top.sls on Python3.13rc2 #66898

Open marmarek opened 3 weeks ago

marmarek commented 3 weeks ago

Description of the tech debt to be addressed, include links and screenshots

A recent change in Python 3.13 causes salt to fails on loading top.sls. With debugging enabled, I see now:

[DEBUG   ] Could not find file 'salt://.sls' in saltenv 'base'
[DEBUG   ] No contents loaded for saltenv 'base'

This seems to be directly caused by the change in Python: https://github.com/python/cpython/issues/85110

Old behavior:

>>> urllib.parse.urlunparse(("file", "", "top.sls", "", "", ""))
'file:///top.sls'

New behavior:

>>> urllib.parse.urlunparse(("file", "", "top.sls", "", "", ""))
'file:top.sls'

Technically, I think the latter might be more correct. But it still breaks salt's expectations. Specifically here: https://github.com/saltstack/salt/blob/246d0664577ef72da8bd1f0c4dff0d18b4428b23/salt/utils/url.py#L49-L50

With file:top.sls, looking for length of file:/// is wrong now.

Versions Report

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

Salt Version:
          Salt: 3006.9

Python Version:
        Python: 3.13.0rc2 (main, Sep  7 2024, 00:00:00) [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)]

Dependency Versions:
          cffi: 1.17.0
      cherrypy: Not Installed
  cryptography: Not Installed
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.4
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.1
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.20.0
        pygit2: Not Installed
  python-gnupg: Not Installed
        PyYAML: 6.0.1
         PyZMQ: 25.1.1
        relenv: Not Installed
         smmap: Not Installed
       timelib: Not Installed
       Tornado: Not Installed
           ZMQ: 4.3.5

System Versions:
          dist: qubes 4.3 R4.3
        locale: utf-8
       machine: x86_64
       release: 6.6.48-1.qubes.fc41.x86_64
        system: Linux
       version: Qubes OS 4.3 R4.3

The same issue applies to Fedora 41 (in beta now). And while I tested using Salt 3006.9, the relevant code is the same in master.

ptitdoc commented 3 weeks ago

Take care that as if is related to cython it's independent from python3.13.

I have the same bug (and same fix working) for python 3.12.6/cython 3.0.11

marmarek commented 3 weeks ago

Indeed Python 3.12.6 is affected too, and so is Fedora 40 and 39.