salt icon indicating copy to clipboard operation
salt copied to clipboard

Fix pkg.version_cmp on openEuler

Open raulillo82 opened this issue 2 years ago • 6 comments

What does this PR do?

Fixes pkg.version_cmp on openEuler systems (and a few other os flavors that were affected as well).

What issues does this PR fix or reference?

Fixes: #62248

Previous Behavior

uyuni:~ # salt '192*' pkg.version_cmp 4.10.0-3.oe2203 4
192.168.122.173:
    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/minion.py", line 1916, in _thread_return
        return_data = minion_instance._execute_job_function(
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/minion.py", line 1873, in _execute_job_function
        return_data = self.executors[fname](opts, data, func, args, kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 1203, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 1218, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/executors/venv.py", line 24, in execute
        return __executors__["direct_call.execute"](opts, data, func, args, kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 1203, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 1218, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/executors/direct_call.py", line 10, in execute
        return func(*args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 1203, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 1218, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/modules/yumpkg.py", line 685, in version_cmp
        return __salt__["lowpkg.version_cmp"](pkg1, pkg2, ignore_epoch=ignore_epoch)
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/context.py", line 78, in __getitem__
        return self.value()[item]
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/loader/lazy.py", line 334, in __getitem__
        super().__getitem__(item)  # try to get the item from the dictionary
      File "/usr/lib/venv-salt-minion/lib64/python3.10/site-packages/salt/utils/lazy.py", line 105, in __getitem__
        raise KeyError(key)
    KeyError: 'lowpkg.version_cmp'
ERROR: Minions returned with non-zero exit code

uyuni:~ # salt '192*' grains.get os_family
192.168.122.173:
    openEuler

New Behavior

uyuni:~ # salt '192*' pkg.version_cmp 4.10.0-3.oe2203 4
192.168.122.173:
    1

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

  • [ ] Docs
  • [x] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
  • [ ] Tests written/updated

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

raulillo82 avatar Jun 30 '22 09:06 raulillo82

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

welcome[bot] avatar Jun 30 '22 09:06 welcome[bot]

Related test passes successfully:

(salt) raul@laptop:~/gh-forked-projects/saltstack/salt-1>  (fix_issue_62248)$ python3 -m nox -e "pytest-3.7(coverage=False)" -- tests/pytests/unit/modules/test_rpm_lowpkg.py
nox > Running session pytest-3.7(coverage=False)
nox > Re-using existing virtual environment at .nox/pytest-3-7-coverage-false.
nox > Session pytest-3.7(coverage=False) was successful.
nox > Running session pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False)
nox > Re-using existing virtual environment at .nox/pytest-parametrized-3-7-crypto-none-transport-zeromq-coverage-false.
nox > python -m pip install --progress-bar=off -U 'pip>=20.2.4,<21.2' 'setuptools!=50.*,!=51.*,!=52.*,<59' wheel
nox > python -m pip install --progress-bar=off -r requirements/static/ci/py3.7/linux.txt
nox > python -m pytest --rootdir /home/raul/gh-forked-projects/saltstack/salt-1 --log-file=/home/raul/gh-forked-projects/saltstack/salt-1/artifacts/logs/runtests-20220630130202.869038.log --log-file-level=debug --show-capture=no -ra -s --showlocals --transport=zeromq tests/pytests/unit/modules/test_rpm_lowpkg.py
============================================================================================== test session starts ==============================================================================================
platform linux -- Python 3.7.0, pytest-7.0.1, pluggy-0.13.0
tempdir: /tmp/stsuite
max open files; soft: 3072; hard: 524288
rootdir: /home/raul/gh-forked-projects/saltstack/salt-1, configfile: pytest.ini
plugins: skip-markers-1.2.0, helpers-namespace-2021.4.29, tempdir-2019.10.12, system-statistics-1.0.2, shell-utilities-1.4.0, salt-factories-1.0.0rc17, timeout-1.4.2, subtests-0.4.0, httpserver-1.0.4, flaky-3.7.0
collected 19 items                                                                                                                                                                                              

tests/pytests/unit/modules/test_rpm_lowpkg.py ............s.s....

============================================================================================ short test summary info ============================================================================================
SKIPPED [1] tests/pytests/unit/modules/test_rpm_lowpkg.py:232: The RPM lib is not installed, skipping
SKIPPED [1] tests/pytests/unit/modules/test_rpm_lowpkg.py:226: The rpmdev-vercmp binary is not installed
========================================================================================= 17 passed, 2 skipped in 1.00s =========================================================================================
nox > Session pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False) was successful.
nox > Ran multiple sessions:
nox > * pytest-3.7(coverage=False): success
nox > * pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False): success

raulillo82 avatar Jun 30 '22 11:06 raulillo82

Additional tests after noticing some were missing:


(salt) raul@laptop:~/gh-forked-projects/saltstack/salt-1>  (fix_issue_62248)$ python3 -m nox -e "pytest-3.7(coverage=False)" -- tests/pytests/unit/modules/test_rpm_lowpkg.py
nox > Running session pytest-3.7(coverage=False)
nox > Re-using existing virtual environment at .nox/pytest-3-7-coverage-false.
nox > Session pytest-3.7(coverage=False) was successful.
nox > Running session pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False)
nox > Re-using existing virtual environment at .nox/pytest-parametrized-3-7-crypto-none-transport-zeromq-coverage-false.
nox > python -m pip install --progress-bar=off -U 'pip>=20.2.4,<21.2' 'setuptools!=50.*,!=51.*,!=52.*,<59' wheel
nox > python -m pip install --progress-bar=off -r requirements/static/ci/py3.7/linux.txt
nox > python -m pytest --rootdir /home/raul/gh-forked-projects/saltstack/salt-1 --log-file=/home/raul/gh-forked-projects/saltstack/salt-1/artifacts/logs/runtests-20220630132110.514809.log --log-file-level=debug --show-capture=no -ra -s --showlocals --transport=zeromq tests/pytests/unit/modules/test_rpm_lowpkg.py
============================================================================================== test session starts ==============================================================================================
platform linux -- Python 3.7.0, pytest-7.0.1, pluggy-0.13.0
tempdir: /tmp/stsuite
max open files; soft: 3072; hard: 524288
rootdir: /home/raul/gh-forked-projects/saltstack/salt-1, configfile: pytest.ini
plugins: skip-markers-1.2.0, helpers-namespace-2021.4.29, tempdir-2019.10.12, system-statistics-1.0.2, shell-utilities-1.4.0, salt-factories-1.0.0rc17, timeout-1.4.2, subtests-0.4.0, httpserver-1.0.4, flaky-3.7.0
collected 19 items                                                                                                                                                                                              

tests/pytests/unit/modules/test_rpm_lowpkg.py ............s......

============================================================================================ short test summary info ============================================================================================
SKIPPED [1] tests/pytests/unit/modules/test_rpm_lowpkg.py:232: The RPM lib is not installed, skipping
========================================================================================= 18 passed, 1 skipped in 1.00s =========================================================================================
nox > Session pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False) was successful.
nox > Ran multiple sessions:
nox > * pytest-3.7(coverage=False): success
nox > * pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False): success

raulillo82 avatar Jun 30 '22 11:06 raulillo82

Hi @raulillo82, thanks for the contribution. We will need tests for this in order to get it merged.

MKLeb avatar Jul 06 '22 19:07 MKLeb

Hi @raulillo82, thanks for the contribution. We will need tests for this in order to get it merged.

Tests added in latest commit, see output of it:

(salt) raul@laptop:~/gh-forked-projects/saltstack/salt-1>  (fix_issue_62248)$ python -m nox -e "pytest-3.7(coverage=False)" -- tests/pytests/unit/modules/test_rpm_lowpkg.py
nox > Running session pytest-3.7(coverage=False)
nox > Re-using existing virtual environment at .nox/pytest-3-7-coverage-false.
nox > Session pytest-3.7(coverage=False) was successful.
nox > Running session pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False)
nox > Re-using existing virtual environment at .nox/pytest-parametrized-3-7-crypto-none-transport-zeromq-coverage-false.
nox > python -m pip install --progress-bar=off -U 'pip>=20.2.4,<21.2' 'setuptools!=50.*,!=51.*,!=52.*,<59' wheel
nox > python -m pip install --progress-bar=off -r requirements/static/ci/py3.7/linux.txt
nox > python -m pytest --rootdir /home/raul/gh-forked-projects/saltstack/salt-1 --log-file=/home/raul/gh-forked-projects/saltstack/salt-1/artifacts/logs/runtests-20220711124643.239459.log --log-file-level=debug --show-capture=no -ra -s --showlocals --transport=zeromq tests/pytests/unit/modules/test_rpm_lowpkg.py
========================================================================================= test session starts ==========================================================================================
platform linux -- Python 3.7.0, pytest-7.0.1, pluggy-0.13.0
tempdir: /tmp/stsuite
max open files; soft: 3072; hard: 524288
rootdir: /home/raul/gh-forked-projects/saltstack/salt-1, configfile: pytest.ini
plugins: skip-markers-1.2.0, helpers-namespace-2021.4.29, tempdir-2019.10.12, system-statistics-1.0.2, shell-utilities-1.4.0, salt-factories-1.0.0rc17, timeout-1.4.2, subtests-0.4.0, httpserver-1.0.4, flaky-3.7.0
collected 23 items                                                                                                                                                                                     

tests/pytests/unit/modules/test_rpm_lowpkg.py ................s......

======================================================================================= short test summary info ========================================================================================
SKIPPED [1] tests/pytests/unit/modules/test_rpm_lowpkg.py:252: The RPM lib is not installed, skipping
==================================================================================== 22 passed, 1 skipped in 1.00s =====================================================================================
nox > Session pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False) was successful.
nox > Ran multiple sessions:
nox > * pytest-3.7(coverage=False): success
nox > * pytest-parametrized-3.7(crypto=None, transport='zeromq', coverage=False): success

raulillo82 avatar Jul 11 '22 10:07 raulillo82

@raulillo82 It seems there is some debate about whether this is the correct fix or if openEuler should be added to the RHEL family. I don't know enough about openEuler, but @OrangeDog and @agraul have raised some valid points. I think it makes sense to add it to the RHEL family if it's essentially a fork of RHEL, and as @OrangeDog said, openEuler is not officially supported by salt.

MKLeb avatar Sep 13 '22 22:09 MKLeb

@twangboy you don't think that openEuler should just be in the RedHat family?

OrangeDog avatar Oct 03 '22 18:10 OrangeDog

Taking a quick look at an openEuler system it does appear to use and have similar tools to Red Hat / CentOS systems but is different enough that it should be considered it's own os_family.

garethgreenaway avatar Oct 03 '22 20:10 garethgreenaway

Congratulations on your first PR being merged! :tada:

welcome[bot] avatar Oct 03 '22 21:10 welcome[bot]