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

Apply erratas to Debian / Ubuntu systems (resolve package names and version listed in a debian advisory) #416

Open
wants to merge 1 commit into
base: openSUSE/release/3002.2
Choose a base branch
from

Conversation

rpasche
Copy link

@rpasche rpasche commented Aug 20, 2021

This is basically a copy of uyuni-project/uyuni#2068

cc @brejoc , @paususe

I applied this fix to a running Debian minion having salt-minon-3002.2+ds-1+142.2.uyuni

This is Uyuni specific. The salt master on a Uyuni server needs to be
prepared to allow minions to access the spacewalk API via a runner.

In case the advisory is found, it will return the package names
of already installed packages, but with the versions listed within
the advisory.

This basically replaces the errata.py script in older, traditional
clients.

What does this PR do?

If applied to a Debian minion (connected to a Uyuni server),
allows the installation of errata on Debian systems.
This basically replaces the old errata.py on traditional Debian clients.

What issues does this PR fix or reference?

Fixes:

Previous Behavior

Remove this section if not relevant

New Behavior

Remove this section if not relevant

Merge requirements satisfied?

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

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices.

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

This is Uyuni specific. The salt master on a Uyuni server needs to be
prepared to allow minions to access the 'spacewalk' API via a runner.

In case the advisory is found, it will return the package names
of already installed packages, but with the versions listed within
the advisory.

This basically replaces the 'errata.py' script in older, traditional
clients.
@rpasche rpasche marked this pull request as ready for review August 20, 2021 14:40
@mcalmer
Copy link
Member

mcalmer commented Aug 20, 2021

I wonder if we should better solve this in the java side, without the need of calling back from the client to the server.
AFAIK we still should have the required code as in the early days also RedHat clients had the problem of not been able to install a patch/errata.
The code which resolve errata to package list should still be there. We just need to take care that we call it in case of debian/ubuntu

@rpasche
Copy link
Author

rpasche commented Oct 15, 2021

I wonder if we should better solve this in the java side, without the need of calling back from the client to the server. AFAIK we still should have the required code as in the early days also RedHat clients had the problem of not been able to install a patch/errata. The code which resolve errata to package list should still be there. We just need to take care that we call it in case of debian/ubuntu

HI @mcalmer could you point me to some direction to this "old" code that might still be there?

@mcalmer
Copy link
Member

mcalmer commented Oct 15, 2021

CC @lucidd - AFAIK you are currently looking into this as well. Do you have a pointer to the code?

@lucidd
Copy link
Member

lucidd commented Oct 21, 2021

@rpasche we seem to have had some code for this in the past https://github.com/SUSE/spacewalk/blob/Manager-3.0-MU-201705-release/java/code/src/com/suse/manager/webui/services/SaltServerActionService.java#L331-L355 but its not in the current version anymore. I think this was removed at a time when deb was not supported. It looks like listNewestPkgsForServerErrata is still there which does most of the heavy lifting.

@an0nz
Copy link

an0nz commented Feb 17, 2022

@lucidd is that available in a public repository? I have been unable to find it in in older Uyuni commits.

@lucidd
Copy link
Member

lucidd commented Feb 18, 2022

@an0nz in the meantime we implemented ubuntu errata management and its already merged in uyuni uyuni-project/uyuni#4733. It uses the old method i linked above with some modifications. Let me know if anything is unclear.

@an0nz
Copy link

an0nz commented Feb 18, 2022

@lucidd thanks for the great work, I just spent the day updating rpasche’s aptpkg code to work with salt 3002 and Uyuni 2022.01 and was considering pushing it out to our minions so I’ll hold off and wait until the next release.

@rpasche
Copy link
Author

rpasche commented Feb 19, 2022 via email

@SchoolGuy SchoolGuy changed the base branch from openSUSE-3002.2 to openSUSE/release/3002.2 September 12, 2022 11:23
@gabardyne
Copy link

gabardyne commented Nov 17, 2023

Hello,

I encounter a python error on a Debian 10 client when I want to apply a patch.

I'm using @rpasche aptpkg.py:


      ID: mgr_regular_patches
Function: pkg.installed
    Name: mgr_regular_patches
  Result: false
 Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/state.py", line 2401, in call
  ret = self.states[cdata["full"]](
File "/usr/lib/venv-salt-minion/lib/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/lib/python3.10/site-packages/salt/loader/lazy.py", line 1234, in run
  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/loader/lazy.py", line 1249, in _run_as
  return _func_or_method(*args, **kwargs)
File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/loader/lazy.py", line 1282, in wrapper
  return f(*args, **kwargs)
File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/states/pkg.py", line 2386, in patch_installed
  pkg_ret = __salt__["pkg.install"](
File "/usr/lib/venv-salt-minion/lib/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/lib/python3.10/site-packages/salt/loader/lazy.py", line 1234, in run
  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/loader/lazy.py", line 1249, in _run_as
  return _func_or_method(*args, **kwargs)
File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/modules/aptpkg.py", line 596, in install
  pkgs = _runner_errata_packagelist(kwargs['advisory_ids'])
File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/modules/aptpkg.py", line 3147, in 
_runner_errata_packagelist
   pkglist = pkglist + _get_packages_from_errata(adv)
File "/usr/lib/venv-salt-minion/lib/python3.10/site-packages/salt/modules/aptpkg.py", line 3127, in 
_get_packages_from_errata
  return list(pkglist.values())[0]
IndexError: list index out of range

 Started: 16:59:44.818179
Duration: 24.856
     SLS: packages.patchinstall
 Changed: {}

The salt agent is : venv-salt-minion 3006.0-21.8.uyuni

Uyuni version 2023.10

It's been working on Uyuni version 2022.11

Any ideas?

Regards,

Paul

@rpasche
Copy link
Author

rpasche commented Nov 17, 2023

Sorry... I'm out on this topic since April 2022. My first guess was, that maybe the advisory was found, but does not include packages. But...I don't know. Thought that this topic is meanwhile done by uyuni itself. Hope you can fix it.

@rpasche
Copy link
Author

rpasche commented Nov 18, 2023

You might be able and try to check pkglist first. list(pkglist.values())[0] is what is failing. Pretty sure, pkglist is empty. So trying to fetch the first element causes "index out of bounds".

@gabardyne
Copy link

gabardyne commented Nov 20, 2023

Hi!
Thanks a lot for answering this.
I will investigate this pkglist thing.

@gabardyne
Copy link

Ok, I run some test today, but i can't figure out how to test the python script out of Uyuni.

I'm running into various import error.

Is there a way to execute the script from uyuni master, and see the result of some 'print' i put into the script?

@gabardyne
Copy link

My mistake, i'm working on new integration uyuni server, and i forgot to configure the runner with spacewalk.py.

It's ok now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants