-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat: add dnf charm library #75
Conversation
Notes: * This was done so that `config-manager` for add_repo would be available. `config-manager` is a plugin command outside of the base dnf distribution.
…ic LXD channel to use
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.
A lot of this is just nits on style, but I do think in places we're over-complicating things and we probably need to consider if the added complexity is bringing much value over a more simplistic approach.
Remember that in the life of the charm, these methods are likely to be used only during install
and upgrade-charm
, which represents a very small portion of the charm's life, and never concurrently.
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 a lot of this is overly complex, and I'm worried about the "available" cache and the side effects done at import time. I've submitted a lot of comments to this effect. I hope they're constructive!
I think we should look at some use cases to determine what we actually need. And ask whether the cache is needed, or can we use something like dnf info
instead.
Oh sorry, I spent a bunch of time reviewing this and just submitted my comments, but didn't see that @jnsgruk just had too. Looks like we have many of the same exact concerns. Sorry about the duplication! |
Thanks for reviewing this @jnsgruk and @benhoyt! I finished responding to most of your review comments. I am going to take dnf "back to the shop" and make some changes based on what has been discussed here. I will re-comment once I am done implementing my changes and ready for the next round of reviews. |
Notes: * I removed the _Cache class for managing data about what packages are currently installed on the unit. * I removed the _MetaDNF class that checked if `dnf` was installed and brought in the `dnf-plugins-core` package. * I removed all the threading. * I removed the __getitem__ interface for retrieving package data.
Okay @jnsgruk and @benhoyt, I have completed my initial passthrough for improving the dnf charm library. Big changes that I made to this new revision is that I removed |
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.
This is so much simpler, with any complexity that's left commensurate with what we're doing. Thanks! Just a few minor comments.
Notes: * Removed hashbang from top of file. * Renamed ExecutionError -> Error. * Removed UNKNOWN state as I find it to not be helpful. * Simplified `version()` and as such removed need for StringIO. * Refactored `upgrade()` so that upgrade can be performed even if no packages are specified. * Refactored how missing args are evaluated. * Refactored `fetch()` to be more resilient. i.e. handle regex match failure. * Removed `installed()` check from `_dnf()` in favor of just handling the thrown `FileNotFoundError` thrown by subprocess if desired executable is not found.
Looking much, much simpler @NucciTheBoss - thanks! If you could clean up the unresolved conversations when you're done hacking we can take another pass at this and hopefully get it across the line? |
Sure can do @jnsgruk. Here is what I still need to do hacking wise:
|
Notes: * Removed the `purge(...)` and `update(...)` methods. * Add note to fetch about package name needing too exactly match installed package. * Changed `universal_newlines=True` to `text=True` in `_dnf(...)`. * Modified upgrade(...) so that there is not a condition check if no packages are passed. Change since Python is fine iterating over an empty args object.
Notes: * cleantest was removed after concluding discussion on this thread here: canonical#75 (comment). Cleantest can be reconsidered in a later PR, but for now we should just keep the tests to how they are being done now.
Greetings @jnsgruk and @benhoyt - should be ready for the next round of reviews now. Here are the major changes you should be aware of now that I have published the new commits:
Let me know what you thoughts are. We are getting closer! |
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.
Nice. Approving, but just one nit comment!
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.
One final thing: we need to register the lib name and add LIBID / LIBAPI / LIBPATCH before this can be uploaded :)
Working on adding module level documentation for how to use the dnf charm library for Charmhub now. |
This is now published! https://charmhub.io/operator-libs-linux/libraries/dnf Thanks @NucciTheBoss! |
@NucciTheBoss - super! Nice work, and thank you! |
Description
This pull request aims to add a dnf charm library offering to the operator_libs_linux collection of charm libraries. The dnf library will be used for charms that need to support both Ubuntu and RPM-based distributions (CentOS, Alma, etc.), as well as charms just intended to be deployed to just RPM-based Juju units. It comes with the standard bells and whistles needed to interact with dnf from a simple Python interface.
What still needs to be done
Documentation and registering the library on Charmhub. This pull request is mostly focused on just adding the initial code for a dnf charm library; do not want too many themes in the pull request review.
Notes
setup-lxd
GitHub Action to 0.1.0 instead of just using a commit hash. I also set the channel of LXD to 5.9/stableintegration-but-with-cleantest
so that I did not mess with how the current integration tests are done. I added an extra step in the CI job for the new environment.