-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Added support for openSUSE MicroOS #5998
Added support for openSUSE MicroOS #5998
Conversation
… to support microos closes #5615
Looks good to me, thank you! shipit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a tiny editorial change for the changelog fragment :)
Co-authored-by: Felix Fontein <felix@fontein.de>
Done :) |
plugins/modules/zypper.py
Outdated
@@ -512,7 +512,8 @@ def repo_refresh(m): | |||
|
|||
|
|||
def transactional_updates(): | |||
return os.path.exists('/var/lib/misc/transactional-update.state') | |||
return os.path.exists('/var/lib/misc/transactional-update.state') \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return os.path.exists('/var/lib/misc/transactional-update.state') \ | |
return any(map(os.path.exists, ['/var/lib/misc/transactional-update.state', '/usr/sbin/transactional-update'])) |
another way to write this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the suggested change makes the boolean operation non-trivial anymore, in the way that it allocates an array and has to reflectively apply the list items to the supplied function. For more items i'd be with you, but for two..?
Thx for the suggestion nevertheless! Phyton's not my native language and i'm happy to learn about new ways to do stuff :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Python 3 it the map
result is a generator, but on Python 2 this causes two calls to os.path.exists
, while the original statement only makes two calls if the first one returns False
.
But using a generator expression would make it rather efficient (though still slower than the original version) even on Python 2.6 and 2.7: any(os.path.exists(path) for path in ('/var/lib/misc/transactional-update.state', '/usr/sbin/transactional-update'))
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the explanation 🤗 Makes sense.
So should i change it, or leave it as is? What's preferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 2 is dead and is probably irrelevant if something there is slower than the supported release. What does /var/lib/misc/transactional-update.state contain? And is the system in a valid state if this file is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for pinging me.
Is the pure existence of the executable enough to check if transactional updates are actually in use? It may be true for MicroOS, which only exists in the transaction-variant. In openSUSE (e.g. Tumbleweed) I can as well install transactional-update
and have the executable on the disk. That does not mean I actually activated transactional updates. That's the reason why I checked for the state file.
If there's a better way to check if transactional updates are really in use (and not only "possible"), I'm for the change. But not when we break the usage of the module on other systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to identify MicroOS? Maybe looking at /etc/os-release
or /etc/lsb-release
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixfontein in my MicroOS installation there is no /etc/lsb-release
file, but /etc/os-release
contains:
NAME="openSUSE MicroOS"
# VERSION="20230130"
ID="opensuse-microos"
ID_LIKE="suse opensuse opensuse-tumbleweed"
VERSION_ID="20230130"
PRETTY_NAME="openSUSE MicroOS"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:microos:20230130"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:MicroOS"
LOGO="distributor-logo-MicroOS"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe looking at
/etc/os-release
or/etc/lsb-release
?
It's id is opensuse-microos
, so yes.
But we shouldn't only rely on that, as the state-file doesn't exist on a transactional Tumbleweed/Leap install.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should replicate the checks zypper uses, if suitable. And it doesn't seem to use black magic, so we should be able to do so: https://github.com/openSUSE/zypper/blob/master/src/commands/conditions.cc#L44
I just pushed an update that checks if the filesystem is btrfs and readonly and contains the binary. Only if all of these are true, the transactional-update method will be used.
|
This comment was marked as outdated.
This comment was marked as outdated.
Looks good to me! Thank you for getting into detail. |
I'll merge this this weekend if nobody objects. |
I'm fine here. |
Thank you @andre161292 for your time and efforts! |
You're welcome! |
Backport to stable-5: 💚 backport PR created✅ Backport PR branch: Backported as #6077 🤖 @patchback |
* fix(zypper): Added condition to check for transactional-update binary to support microos closes #5615 * style(changelog): Made zypper-change uppercase Co-authored-by: Felix Fontein <felix@fontein.de> * fix(zypper): Removed check for /var/lib/misc/transactional-update.state * feat(zypper): Aligned transactional-update checks with zypper's * refactor(zypper): Removed dependency to psutil and made use of parsing /proc/mount * refactor(zypper): Removed need for regex, plus small refactoring --------- Co-authored-by: André Dörscheln <ad@itesign.de> Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 2c762c4)
Backport to stable-6: 💚 backport PR created✅ Backport PR branch: Backported as #6078 🤖 @patchback |
* fix(zypper): Added condition to check for transactional-update binary to support microos closes #5615 * style(changelog): Made zypper-change uppercase Co-authored-by: Felix Fontein <felix@fontein.de> * fix(zypper): Removed check for /var/lib/misc/transactional-update.state * feat(zypper): Aligned transactional-update checks with zypper's * refactor(zypper): Removed dependency to psutil and made use of parsing /proc/mount * refactor(zypper): Removed need for regex, plus small refactoring --------- Co-authored-by: André Dörscheln <ad@itesign.de> Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 2c762c4)
@andre161292 thanks a lot for your contribution! |
…roOS (#6077) Added support for openSUSE MicroOS (#5998) * fix(zypper): Added condition to check for transactional-update binary to support microos closes #5615 * style(changelog): Made zypper-change uppercase Co-authored-by: Felix Fontein <felix@fontein.de> * fix(zypper): Removed check for /var/lib/misc/transactional-update.state * feat(zypper): Aligned transactional-update checks with zypper's * refactor(zypper): Removed dependency to psutil and made use of parsing /proc/mount * refactor(zypper): Removed need for regex, plus small refactoring --------- Co-authored-by: André Dörscheln <ad@itesign.de> Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 2c762c4) Co-authored-by: andre161292 <andre161292@users.noreply.github.com>
…roOS (#6078) Added support for openSUSE MicroOS (#5998) * fix(zypper): Added condition to check for transactional-update binary to support microos closes #5615 * style(changelog): Made zypper-change uppercase Co-authored-by: Felix Fontein <felix@fontein.de> * fix(zypper): Removed check for /var/lib/misc/transactional-update.state * feat(zypper): Aligned transactional-update checks with zypper's * refactor(zypper): Removed dependency to psutil and made use of parsing /proc/mount * refactor(zypper): Removed need for regex, plus small refactoring --------- Co-authored-by: André Dörscheln <ad@itesign.de> Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 2c762c4) Co-authored-by: andre161292 <andre161292@users.noreply.github.com>
Docs Build 📝Thank you for contribution!✨ This PR has been merged and your docs changes will be incorporated when they are next published. |
* fix(zypper): Added condition to check for transactional-update binary to support microos closes ansible-collections#5615 * style(changelog): Made zypper-change uppercase Co-authored-by: Felix Fontein <felix@fontein.de> * fix(zypper): Removed check for /var/lib/misc/transactional-update.state * feat(zypper): Aligned transactional-update checks with zypper's * refactor(zypper): Removed dependency to psutil and made use of parsing /proc/mount * refactor(zypper): Removed need for regex, plus small refactoring --------- Co-authored-by: André Dörscheln <ad@itesign.de> Co-authored-by: Felix Fontein <felix@fontein.de>
SUMMARY
Added condition to check for
/usr/sbin/transactional-update
binary, which is the way to go for openSUSE MicroOS.Fixes #5615
ISSUE TYPE
COMPONENT NAME
plugins/modules/zypper.py