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] yumpkg option "get_extra_options" leads to CLI parameter error #64476

Open
2 tasks done
hurzhurz opened this issue Jun 13, 2023 · 3 comments
Open
2 tasks done

[BUG] yumpkg option "get_extra_options" leads to CLI parameter error #64476

hurzhurz opened this issue Jun 13, 2023 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior Regression The issue is a bug that breaks functionality known to work in previous releases. RHEL Related to running salt on or targeting Red Had Enterprise Linux

Comments

@hurzhurz
Copy link
Contributor

Description
The yumpkg module has the option to pass additional CLI parameters to yum/dnf by stating them as kwargs. This can be enabled by setting kwarg get_extra_options: True:
https://github.com/saltstack/salt/blob/master/salt/modules/yumpkg.py#L294
https://github.com/saltstack/salt/blob/master/salt/modules/yumpkg.py#L328

I use this in special cases to let yum use a different config file via the CLI option --config (see SLS example below).
And this was working fine for 3004.2, but in 3005.1 and 3006.1, yum throws an error:
Command line error: argument --version: ignored explicit argument 'None'

It looks like there is an kwarg "version" with value None present, which is given to yum as --version=None.
I can't tell for sure if kwarg "version" was present in 3004.2 already in my case, but it probably got simply ignored as it was a NoneType and not a string or True: https://github.com/saltstack/salt/blob/master/salt/modules/yumpkg.py#L334
But there was a change that always converts it to a string, and so it is not ignored anymore: 2962b04

A possible fix I can think of is to extend the cases where kwargs are ignored here:
https://github.com/saltstack/salt/blob/master/salt/modules/yumpkg.py#L331
So not only ignore kwarg names starting with "__" but also blacklist "version", as passing --version as parameter doesn't make sense anyway.

Log with error message
[root@oel ~]# salt-call -l info state.apply test-yum
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file from saltenv 'base', ** done ** 'test-yum.sls'
[INFO    ] Running state [wget] at time 10:41:15.542053
[INFO    ] Executing state pkg.installed for [wget]
[INFO    ] Executing command rpm in directory '/root'
[INFO    ] Found extra option --config=/tmp/yum.conf
[INFO    ] Found extra option --version=None
[INFO    ] Adding extra options: ['--config=/tmp/yum.conf', '--version=None']
[INFO    ] Found extra option --config=/tmp/yum.conf
[INFO    ] Found extra option --version=None
[INFO    ] Adding extra options: ['--config=/tmp/yum.conf', '--version=None']
[INFO    ] Executing command systemd-run in directory '/root'
[INFO    ] Executing command systemd-run in directory '/root'
[WARNING ] 'version' argument will be ignored for multiple package targets
[INFO    ] Executing command systemd-run in directory '/root'
[ERROR   ] Command 'systemd-run' failed with return code: 1
[ERROR   ] stdout: Running scope as unit: run-r210f8d34a1d94666a42b7181dbbd5f2a.scope
Command line error: argument --version: ignored explicit argument 'None'
usage: dnf [-c [config file]] [-q] [-v] [--version] [--installroot [path]]
           [--nodocs] [--noplugins] [--enableplugin [plugin]]
           [--disableplugin [plugin]] [--releasever RELEASEVER]
           [--setopt SETOPTS] [--skip-broken] [-h] [--allowerasing]
           [-b | --nobest] [-C] [-R [minutes]] [-d [debug level]]
           [--debugsolver] [--showduplicates] [-e ERRORLEVEL] [--obsoletes]
           [--rpmverbosity [debug level name]] [-y] [--assumeno]
           [--enablerepo [repo]] [--disablerepo [repo] | --repo [repo]]
           [--enable | --disable] [-x [package]] [--disableexcludes [repo]]
           [--repofrompath [repo,path]] [--noautoremove] [--nogpgcheck]
           [--color COLOR] [--refresh] [-4] [-6] [--destdir DESTDIR]
           [--downloadonly] [--comment COMMENT] [--bugfix] [--enhancement]
           [--newpackage] [--security] [--advisory ADVISORY] [--bz BUGZILLA]
           [--cve CVES] [--sec-severity {Critical,Important,Moderate,Low}]
           [--forcearch ARCH]
[ERROR   ] retcode: 1
[INFO    ] Executing command rpm in directory '/root'
[ERROR   ] Error occurred installing package(s). Additional info follows:

errors:
    - Running scope as unit: run-r210f8d34a1d94666a42b7181dbbd5f2a.scope
      Command line error: argument --version: ignored explicit argument 'None'
      usage: dnf [-c [config file]] [-q] [-v] [--version] [--installroot [path]]
                 [--nodocs] [--noplugins] [--enableplugin [plugin]]
                 [--disableplugin [plugin]] [--releasever RELEASEVER]
                 [--setopt SETOPTS] [--skip-broken] [-h] [--allowerasing]
                 [-b | --nobest] [-C] [-R [minutes]] [-d [debug level]]
                 [--debugsolver] [--showduplicates] [-e ERRORLEVEL] [--obsoletes]
                 [--rpmverbosity [debug level name]] [-y] [--assumeno]
                 [--enablerepo [repo]] [--disablerepo [repo] | --repo [repo]]
                 [--enable | --disable] [-x [package]] [--disableexcludes [repo]]
                 [--repofrompath [repo,path]] [--noautoremove] [--nogpgcheck]
                 [--color COLOR] [--refresh] [-4] [-6] [--destdir DESTDIR]
                 [--downloadonly] [--comment COMMENT] [--bugfix] [--enhancement]
                 [--newpackage] [--security] [--advisory ADVISORY] [--bz BUGZILLA]
                 [--cve CVES] [--sec-severity {Critical,Important,Moderate,Low}]
                 [--forcearch ARCH]
[INFO    ] Completed state [wget] at time 10:41:16.204927 (duration_in_ms=662.874)
local:
----------
          ID: test
    Function: pkg.installed
        Name: wget
      Result: False
     Comment: Error occurred installing package(s). Additional info follows:

              errors:
                  - Running scope as unit: run-r210f8d34a1d94666a42b7181dbbd5f2a.scope
                    Command line error: argument --version: ignored explicit argument 'None'
                    usage: dnf [-c [config file]] [-q] [-v] [--version] [--installroot [path]]
                               [--nodocs] [--noplugins] [--enableplugin [plugin]]
                               [--disableplugin [plugin]] [--releasever RELEASEVER]
                               [--setopt SETOPTS] [--skip-broken] [-h] [--allowerasing]
                               [-b | --nobest] [-C] [-R [minutes]] [-d [debug level]]
                               [--debugsolver] [--showduplicates] [-e ERRORLEVEL] [--obsoletes]
                               [--rpmverbosity [debug level name]] [-y] [--assumeno]
                               [--enablerepo [repo]] [--disablerepo [repo] | --repo [repo]]
                               [--enable | --disable] [-x [package]] [--disableexcludes [repo]]
                               [--repofrompath [repo,path]] [--noautoremove] [--nogpgcheck]
                               [--color COLOR] [--refresh] [-4] [-6] [--destdir DESTDIR]
                               [--downloadonly] [--comment COMMENT] [--bugfix] [--enhancement]
                               [--newpackage] [--security] [--advisory ADVISORY] [--bz BUGZILLA]
                               [--cve CVES] [--sec-severity {Critical,Important,Moderate,Low}]
                               [--forcearch ARCH]
     Started: 10:41:15.542053
    Duration: 662.874 ms
     Changes:

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time: 662.874 ms
[root@oel ~]#

Setup

test-yum.sls:

test:
  pkg.installed:
    - name: wget
    - kwargs:
      get_extra_options: True
      config: /tmp/yum.conf
# config option not needed to reproduce the issue, setting get_extra_options is sufficient
  • VM (Virtualbox, KVM, etc. please specify)
  • onedir packaging

Steps to Reproduce the behavior

salt-call state.apply test-yum
(with test-yum.sls from above)

Versions Report

salt --versions-report
Salt Version:
          Salt: 3006.1

Python Version:
        Python: 3.10.11 (main, May  5 2023, 02:31:54) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: 18.6.1
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.2
       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.9.8
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 5.4.1
         PyZMQ: 23.2.0
        relenv: 0.12.3
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: oracle 8.8
        locale: utf-8
       machine: x86_64
       release: 5.4.0-148-generic
        system: Linux
       version: Oracle Linux Server 8.8
@hurzhurz hurzhurz added Bug broken, incorrect, or confusing behavior needs-triage labels Jun 13, 2023
@OrangeDog OrangeDog added the RHEL Related to running salt on or targeting Red Had Enterprise Linux label Jun 14, 2023
@s0undt3ch s0undt3ch added Regression The issue is a bug that breaks functionality known to work in previous releases. and removed needs-triage labels Jun 15, 2023
@s0undt3ch s0undt3ch added this to the Sulfur v3006.2 milestone Jun 15, 2023
@s0undt3ch
Copy link
Collaborator

Same root cause as #64563

@dwoz
Copy link
Contributor

dwoz commented Jun 18, 2024

@hurzhurz Can this fix be backported to 3006.x?

@hurzhurz
Copy link
Contributor Author

@hurzhurz Can this fix be backported to 3006.x?

Yes, I think so. The changes from @bdrx312 in db5704b are minimal and should be applicable to 3006.x, too.

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 Regression The issue is a bug that breaks functionality known to work in previous releases. RHEL Related to running salt on or targeting Red Had Enterprise Linux
Projects
None yet
Development

No branches or pull requests

6 participants