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

[2018.3] Do not report patches as installed when not all the related pkgs are installed (yumpkg) #52657

Conversation

meaksh
Copy link
Contributor

@meaksh meaksh commented Apr 22, 2019

What does this PR do?

This PR fixes an issue in the _get_patches function from the yumpkg module which affects the output from pkg.list_patches method on yum based systems. Currently, this function is reporting that a given patch is "installed" even when not all its related packages are actually installed on the system.

The _get_patches function from yumpkg parses the output from yum --quiet updateinfo list all command in order to figure out which patches are "available/installed". But there is a problem when this output is handled so the resulting dictionary is setting any patch as "installed" as soon as one of its related packages is installed. The right behavior here would be to set a patch as "installed" only if all its related packages are installed.

Previous Behavior

An example with a patch named suse-res7ct-client-tools-201705-13137:

[root@suma40-min-centos7 ~]# yum --quiet updateinfo list all | grep 13137
Failed to set locale, defaulting to C
  suse-res7ct-client-tools-201705-13137 recommended    osa-common-5.11.80.2-24.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    osad-5.11.80.2-24.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    python-hwdata-2.3.4-9.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhn-custom-info-5.4.33.2-12.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhn-virtualization-common-5.4.57.1-15.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhn-virtualization-host-5.4.57.1-15.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhncfg-5.10.103.2-15.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhncfg-actions-5.10.103.2-15.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhncfg-client-5.10.103.2-15.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhncfg-management-5.10.103.2-15.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhnlib-2.7.2.1-21.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    rhnpush-5.5.104.1-15.4.noarch
  suse-res7ct-client-tools-201705-13137 recommended    spacecmd-2.7.8.3-32.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    spacewalk-abrt-2.7.1.2-12.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    spacewalk-backend-libs-2.7.73.3-49.2.noarch
i suse-res7ct-client-tools-201705-13137 recommended    spacewalk-check-2.7.6.2-48.2.noarch
i suse-res7ct-client-tools-201705-13137 recommended    spacewalk-client-setup-2.7.6.2-48.2.noarch
i suse-res7ct-client-tools-201705-13137 recommended    spacewalk-client-tools-2.7.6.2-48.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    spacewalk-koan-2.7.0.2-18.2.noarch
i suse-res7ct-client-tools-201705-13137 recommended    spacewalk-oscap-2.7.0.3-12.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    spacewalk-remote-utils-2.7.4.1-15.2.noarch
i suse-res7ct-client-tools-201705-13137 recommended    spacewalk-usix-2.7.5.2-2.2.noarch
  suse-res7ct-client-tools-201705-13137 recommended    spacewalksd-5.0.26.2-21.2.x86_64
i suse-res7ct-client-tools-201705-13137 recommended    suseRegisterInfo-3.1.1-18.2.x86_64
i suse-res7ct-client-tools-201705-13137 recommended    yum-rhn-plugin-2.7.4.2-21.2.noarch

[root@suma40-min-centos7 ~]# salt-call --local pkg.list_patches
...
    suse-res7ct-client-tools-201705-13137:
        ----------
        installed:
            True
        summary:
            yum-rhn-plugin-2.7.4.2-21.2.noarch
...

New Behavior

[root@suma40-min-centos7 ~]# salt-call --local pkg.list_patches
...
    suse-res7ct-client-tools-201705-13137:
        ----------
        installed:
            False
        summary:
            - osa-common-5.11.80.2-24.2.noarch
            - osad-5.11.80.2-24.2.noarch
            - python-hwdata-2.3.4-9.2.noarch
            - rhn-custom-info-5.4.33.2-12.2.noarch
            - rhn-virtualization-common-5.4.57.1-15.2.noarch
            - rhn-virtualization-host-5.4.57.1-15.2.noarch
            - rhncfg-5.10.103.2-15.2.noarch
            - rhncfg-actions-5.10.103.2-15.2.noarch
            - rhncfg-client-5.10.103.2-15.2.noarch
            - rhncfg-management-5.10.103.2-15.2.noarch
            - rhnlib-2.7.2.1-21.2.noarch
            - rhnpush-5.5.104.1-15.4.noarch
            - spacecmd-2.7.8.3-32.2.noarch
            - spacewalk-abrt-2.7.1.2-12.2.noarch
            - spacewalk-backend-libs-2.7.73.3-49.2.noarch
            - spacewalk-check-2.7.6.2-48.2.noarch
            - spacewalk-client-setup-2.7.6.2-48.2.noarch
            - spacewalk-client-tools-2.7.6.2-48.2.noarch
            - spacewalk-koan-2.7.0.2-18.2.noarch
            - spacewalk-oscap-2.7.0.3-12.2.noarch
            - spacewalk-remote-utils-2.7.4.1-15.2.noarch
            - spacewalk-usix-2.7.5.2-2.2.noarch
            - spacewalksd-5.0.26.2-21.2.x86_64
            - suseRegisterInfo-3.1.1-18.2.x86_64
            - yum-rhn-plugin-2.7.4.2-21.2.noarch
...

Tests written?

No

Commits signed with GPG?

Yes

@meaksh
Copy link
Contributor Author

meaksh commented May 9, 2019

Looking at the output from the jenkins/pr/docs and jenkins/pr/pylint jobs, it looks like there is an exception produced by my surname.. 😄 (which contains some UTF-8 characters)

15:44:14 Running session docs
15:44:14 Creating virtualenv using python2.7 in /var/jenkins/workspace/pr-doc_PR-52657-VSXIWMKQWKQI3QQQATNU3DUJ73OX7Y62NG5GFAVRTH4CLAGFFMDQ/.nox/docs
15:44:17 pip install --progress-bar=off -r requirements/static/py2.7/docs.txt
15:44:17 Session docs raised exception UnicodeEncodeError('ascii', u'Pablo Su\xe1rez Hern\xe1ndez', 8, 9, 'ordinal not in range(128)')
15:44:17 Traceback (most recent call last):
15:44:17   File "/usr/local/pyenv/versions/2.7.15/lib/python2.7/site-packages/nox/sessions.py", line 328, in execute
15:44:17     self.func(session)
15:44:17   File "/var/jenkins/workspace/pr-doc_PR-52657-VSXIWMKQWKQI3QQQATNU3DUJ73OX7Y62NG5GFAVRTH4CLAGFFMDQ/noxfile.py", line 896, in docs
15:44:17     session.install('--progress-bar=off', '-r', 'requirements/static/py2.7/docs.txt', silent=PIP_INSTALL_SILENT)
15:44:17   File "/usr/local/pyenv/versions/2.7.15/lib/python2.7/site-packages/nox/sessions.py", line 248, in install
15:44:17     self._run("pip", "install", *args, external="error", **kwargs)
15:44:17   File "/usr/local/pyenv/versions/2.7.15/lib/python2.7/site-packages/nox/sessions.py", line 211, in _run
15:44:17     return nox.command.run(args, env=env, path=self.bin, **kwargs)
15:44:17   File "/usr/local/pyenv/versions/2.7.15/lib/python2.7/site-packages/nox/command.py", line 114, in run
15:44:17     [cmd_path] + list(args), silent=silent, env=env, **popen_kws
15:44:17   File "/usr/local/pyenv/versions/2.7.15/lib/python2.7/site-packages/nox/popen.py", line 23, in popen
15:44:17     proc = subprocess.Popen(args, env=env, stdout=stdout, stderr=stderr)
15:44:17   File "/usr/local/pyenv/versions/2.7.15/lib/python2.7/subprocess.py", line 394, in __init__
15:44:17     errread, errwrite)
15:44:17   File "/usr/local/pyenv/versions/2.7.15/lib/python2.7/subprocess.py", line 1047, in _execute_child
15:44:17     raise child_exception
15:44:17 UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 8: ordinal not in range(128)
15:44:17 Session docs failed.

@garethgreenaway
Copy link
Contributor

@meaksh Thanks for the PR, logic looks correct, we do need a test for this change though. 😄

@garethgreenaway garethgreenaway added the Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases label Jun 25, 2019
@meaksh meaksh force-pushed the 2018.3-yumpkg-do-not-report-uninstalled-patches-as-installed branch from 6380445 to aac8210 Compare July 1, 2019 14:25
@meaksh
Copy link
Contributor Author

meaksh commented Jul 1, 2019

@garethgreenaway - done! here you have a unit test! 😄 👍

@garethgreenaway garethgreenaway removed the Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases label Jul 2, 2019
@garethgreenaway
Copy link
Contributor

@meaksh Awesome! Thanks!

@meaksh
Copy link
Contributor Author

meaksh commented Dec 10, 2019

Closing in favor of #55582

@meaksh meaksh closed this Dec 10, 2019
@waynew waynew added the has master-port port to master has been created label Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has master-port port to master has been created Reviewers-Assigned
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants