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

[BUG] pkg.uptodate(dist_upgrade=True) with zypper may miss updates #58109

Open JanZerebecki opened 4 years ago

JanZerebecki commented 4 years ago

Description pkg.uptodate(dist_upgrade=True) with zypper may miss updates as zypperpkg.list_upgrades does not implement dist_upgrade, so only considers normal upgrade. This is not a documented kwarg, but it does work for other implementations, like apt. See uptodate https://github.com/saltstack/salt/blob/dc0595cc811f541044efe89446d5f212968db7e3/salt/states/pkg.py#L3244 and compare https://github.com/saltstack/salt/blob/dc0595cc811f541044efe89446d5f212968db7e3/salt/modules/zypperpkg.py#L517 with https://github.com/saltstack/salt/blob/dc0595cc811f541044efe89446d5f212968db7e3/salt/modules/aptpkg.py#L1435 .

Setup (Please provide relevant configs and/or SLS files (be sure to remove sensitive info). Tested on openSUSE.

pkgs-dist-upgraded:
  pkg.uptodate:
    - refresh: True
    - dist_upgrade: True

Steps to Reproduce the behavior Create a situation where upgrade and dist-upgrade would do different things. Would probably happen when you install Leap 15.1 and change to 15.2 repos. Then apply state.

Expected behavior Do the same as zypper dist-upgrade.

Versions Report Verified in source on master, see links to source above.

cmcmarrow commented 4 years ago

@JanZerebecki if zypperpkg had dist_upgrade I would say this is a consistency problem. But zypperpkg does not have this arg because its has not been implemented. So I believe this to be a feature request more then a bug. I also think the documentation should be updated until the feature is add it.

sagetherage commented 4 years ago

this sounds like two tickets - one to update the docs and one that is a feature request @ScriptAutomate is that how you read this?

ScriptAutomate commented 4 years ago

@cmcmarrow @sagetherage I think this is either a bug or a needed feature, from looking at it more, and should probably not involve documentation updates. pkg.uptodate should be able to pass dist_upgrade=true properly to salt.modules.zypperpkg.list_upgrades(), I think, since zypperpkg.upgrade() itself does support dist_upgrade, and would be in line with what pkg.uptodate is meant to do as far as I can tell.

I'm not sure if there is anything to do at the Documentation level, otherwise Docs would just be saying, "This isn't supported yet for SUSE/SLES systems with the dist_upgrade option, as the execution module for zypperpkg currently doesn't support querying whether a dist_upgrade is available via `zypperpkg.list_upgrades()." or something like that, and then having to remove it once it is. This issue should act as documentation of the bug/need-of-feature until it is fixed/introduced.

Seems like zypperpkg.list_upgrades() needs to be looked at? I'm not familiar enough with this module to know whether OOB it lists dist_upgrade potential, or whether it needs to be extended to support it with an arg.