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.15k stars 5.48k forks source link

[BUG] invalid arguments passed into fileserver.update from saltutil runner #66793

Open emoscardini opened 2 months ago

emoscardini commented 2 months ago

Description Running the fileserver.update through saltutil.runner causes extra argument __pub_user to be passed into the function

Setup Salt 3006.x and above.

Steps to Reproduce the behavior Run: salt master_minion saltutil.runner fileserver.update

Error:


    Passed invalid arguments: update() got an unexpected keyword argument '__pub_user'

    Usage:

        Update the fileserver cache. If no backend is provided, then the cache for
        all configured backends will be updated.

        backend
            Narrow fileserver backends to a subset of the enabled ones.

            .. versionchanged:: 2015.5.0
                If all passed backends start with a minus sign (``-``), then these
                backends will be excluded from the enabled backends. However, if
                there is a mix of backends with and without a minus sign (ex:
                ``backend=-roots,git``) then the ones starting with a minus
                sign will be disregarded.

                Additionally, fileserver backends can now be passed as a
                comma-separated list. In earlier versions, they needed to be passed
                as a python list (ex: ``backend="['roots', 'git']"``)

        kwargs
            Pass additional arguments to backend. See example below

        CLI Example:

        .. code-block:: bash

            salt-run fileserver.update
            salt-run fileserver.update backend=roots,git
            salt-run fileserver.update backend=git remotes=myrepo,yourrepo

Expected behavior

master_minion:
    True

Additional context Was introduced with this commit: https://github.com/saltstack/salt/commit/d5b31df509c45f7d67e5b16900262400550a7ab5

Workaround:
Edit modules/saltutil.py & comment out:

pub_data["user"] = kwargs.pop("__pub_user", "UNKNOWN")

Versions Report

salt --versions-report Salt Version: Salt: 3006.9 Python Version: Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0] Dependency Versions: cffi: 1.14.6 cherrypy: unknown cryptography: 42.0.5 dateutil: 2.8.1 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 3.1.4 libgit2: Not Installed looseversion: 1.0.2 M2Crypto: Not Installed Mako: Not Installed msgpack: 1.0.2 msgpack-pure: Not Installed mysql-python: Not Installed packaging: 22.0 pycparser: 2.21 pycrypto: Not Installed pycryptodome: 3.19.1 pygit2: Not Installed python-gnupg: 0.4.8 PyYAML: 6.0.1 PyZMQ: 23.2.0 relenv: 0.17.0 smmap: Not Installed timelib: 0.2.4 Tornado: 4.5.3 ZMQ: 4.3.4 System Versions: dist: ubuntu 22.04.4 jammy locale: utf-8 machine: x86_64 release: 6.5.0-1020-aws system: Linux version: Ubuntu 22.04.4 jammy ```
gilou commented 1 month ago

Hi, I can confirm that issue, on Saltstack 3007.1

Salt Version:                                                                                                                               
          Salt: 3007.1                                                                                                                      

Python Version:                                                                                                                             
        Python: 3.10.14 (main, Apr  3 2024, 21:30:09) [GCC 11.2.0]                                                                          

Dependency Versions:                                                  
          cffi: 1.16.0       
      cherrypy: unknown      
      dateutil: 2.8.2        
     docker-py: Not Installed
         gitdb: Not Installed                                         
     gitpython: Not Installed
        Jinja2: 3.1.4        
       libgit2: 1.3.0        
  looseversion: 1.3.0        
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7        
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1         
     pycparser: 2.21         
      pycrypto: Not Installed
  pycryptodome: 3.19.1       
        pygit2: 1.7.0        
  python-gnupg: 0.5.2        
        PyYAML: 6.0.1        
         PyZMQ: 25.1.2       
        relenv: 0.16.0       
         smmap: Not Installed
       timelib: 0.3.0        
       Tornado: 6.3.3    
           ZMQ: 4.3.4                                                 

Salt Package Information:                                             
  Package Type: onedir                                                

System Versions:                                                      
          dist: debian 12.7 bookworm             
        locale: utf-8                                                 
       machine: x86_64
       release: 6.8.12-1-pve
        system: Linux
       version: Debian GNU/Linux 12.7 bookworm

salt-run fileserver.update works, but using the runner, I get the same error as @emoscardini. This is a bit annoying for the orchestrator.

# salt-run state.orchestrate orchestrator.gitfs                                                                
salt_master:                                            
----------                                                                                                                                  
          ID: update_gitfs                                                                                                                  
    Function: salt.runner
        Name: fileserver.update
      Result: True             
     Comment: Runner function 'fileserver.update' executed.           
     Started: 14:22:28.791045  
    Duration: 167.125 ms                                              
     Changes:                                                         
              ----------                                              
              return:     

                  Passed invalid arguments: update() got an unexpected keyword argument '__pub_user'

Given fix works, but I have no real idea if that will break something else, however it seems that __pub_user is not of much use in that case anyway…