-
Notifications
You must be signed in to change notification settings - Fork 31
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
Deprecate LinuxAdmin::Rhn #198
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RHN is no longer active, we no longer need this class
Checked commit bdunne@1d7c4f7 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
carbonin
approved these changes
Dec 6, 2017
NickLaMuro
added a commit
to NickLaMuro/manageiq
that referenced
this pull request
Mar 13, 2018
So there is a whole mess of WTF going on here, but I will try and explain as best as possible: To start off, the deprecation warning from `linux_admin` was added here: ManageIQ/linux_admin#198 There was little to go off of for a "why", except that it was, in fact, deprecated. So there is that. Our codebase as well wasn't using `LinuxAdmin::Rhn` anywhere, and was only referenced in the specs. So just change `LinuxAdmin::Rhn` to `LinuxAdmin::SubscriptionManager` right? WRONG! So that causes two issues: First, the `LinuxAdmin::SubscriptionManager` doesn't fail with the same error as `LinuxAdmin::Rhn` did in this test. So as a quick solution, I just made it so that `RegistrationSystem.verify_credentials` now rescues the `AwesomeSpawn::NoSuchFileError` that gets thrown when it calls it's `run!` method. But even with that fix, and changing the stub, there is still a deprecation warning? What gives. Well, that is the second, and much more obnoxious part with the whole ordeal. Thanks to some "totally obvious and not confusing" metaprogramming happening in the base class of SubscriptionManager, the class method version of `.verify_credentials` is actually called via the `LinuxAdmin::RegistrationSystem.method_missing`, which will eventually call on `LinuxAdmin::Rhn.new.registered?` prior to calling that on `LinuxAdmin::SubscriptionManager.new.registered?` What truly heinous about this is not that we are deprecating `Rhn`, but that we are doing so, and providing no way to have the user avoid the deprecation warning in `Rhn.new`, and still favor the old code in inner workings of these public APIs. Which doesn't seem to make much sense since it is deprecated... but who am I to judge... Anyway, for now, the quick fix done here is to sub out the `.new` method for `LinuxAdmin::Rhn` with a double, and have that return `false` for `#registered?`. Really, this should be a change to `LinuxAdmin` to make `SubscriptionManager` the default. With that said, added a "future proof" version check as well in that spec that will make the test break when this klugy-ness is no longer needed.
NickLaMuro
added a commit
to NickLaMuro/manageiq
that referenced
this pull request
Mar 13, 2018
So there is a whole mess of WTF going on here, but I will try and explain as best as possible: To start off, the deprecation warning from `linux_admin` was added here: ManageIQ/linux_admin#198 There was little to go off of for a "why", except that it was, in fact, deprecated. So there is that. Our codebase as well wasn't using `LinuxAdmin::Rhn` anywhere, and was only referenced in the specs. So just change `LinuxAdmin::Rhn` to `LinuxAdmin::SubscriptionManager` right? WRONG! So that causes two issues: First, the `LinuxAdmin::SubscriptionManager` doesn't fail with the same error as `LinuxAdmin::Rhn` did in this test. So as a quick solution, I just made it so that `RegistrationSystem.verify_credentials` now rescues the `AwesomeSpawn::NoSuchFileError` that gets thrown when it calls it's `run!` method. But even with that fix, and changing the stub, there is still a deprecation warning? What gives. Well, that is the second, and much more obnoxious part with the whole ordeal. Thanks to some "totally obvious and not confusing" metaprogramming happening in the base class of SubscriptionManager, the class method version of `.verify_credentials` is actually called via the `LinuxAdmin::RegistrationSystem.method_missing`, which will eventually call on `LinuxAdmin::Rhn.new.registered?` prior to calling that on `LinuxAdmin::SubscriptionManager.new.registered?` What truly heinous about this is not that we are deprecating `Rhn`, but that we are doing so, and providing no way to have the user avoid the deprecation warning in `Rhn.new`, and still favor the old code in inner workings of these public APIs. Which doesn't seem to make much sense since it is deprecated... but who am I to judge... Anyway, for now, the quick fix done here is to stub out the `.new` method for `LinuxAdmin::Rhn` with a double, and have that return `false` for `#registered?`. Really, this should be a change to `LinuxAdmin` to make `SubscriptionManager` the default. With that said, added a "future proof" version check as well in that spec that will make the test break when this klugy-ness is no longer needed.
NickLaMuro
added a commit
to NickLaMuro/linux_admin
that referenced
this pull request
Mar 13, 2018
Now the `LinuxAdmin::Rhn` has been deprecated: ManageIQ#198 1ifd7c4f788ce34200ff09ef56176397306904f85b This means that every instantiation of `LinuxAdmin::Rhn` will then add a deprecation warning to STDOUT. Previously, this would also be triggered even if you used the public class methods on `LinuxAdmin::SubscriptionManager` (the deprecation's suggested replacement), because under the hood it determine which to (`Rhn` or `SubscriptionManager`) by initializing each and calling their `registered?` methods. Furthermore, these means if `Rhn` is registered on the system in addition to the preferred `SubscriptionManager`, it the `LinuxAdmin::SubscriptionManager.validate_credentials` class method would actually end up calling `LinuxAdmin::Rhn.validate_credentials` instead because of the preference. * * * While this favoring should probably be refine to first look at the class the `method_missing` method is being called against, this fix simply favors `SubscriptionManager` over `Rhn` when deciding which class to use.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RHN is no longer active, we no longer need this class.
Example (the raise is because I don't have
subscription-manager
installed):