-
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
Prioritize SubscriptionManager over Rhn, and other warning fixes #200
Conversation
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.
0771d66
to
7adf1e5
Compare
Some comments on commits NickLaMuro/linux_admin@ca6ca6e~...7adf1e5 spec/registration_system_spec.rb
|
Checked commits NickLaMuro/linux_admin@ca6ca6e~...7adf1e5 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
An update to the previous commit that makes sure to favor attempting to use the calling class when setting the `registration_type` on any of the subclasses of `LinuxAdmin::RegistrationSystem` instead of whatever comes first. Adds a tiny amount of overhead, but most use cases shouldn't notice it... ever.
Debatable whether this is a good thing, of if we should keep it to remind us to remove it in the future.
When accessing @registration_type for the first time, it would be unassigned cause the following ruby warning to be thrown: lib/linux_admin/registration_system.rb:6: warning: instance variable @registration_type not initialized This prevents it by setting it to `nil` if it isn't set already.
Fixed Hakiri warnings in #201 |
end | ||
|
||
def stub_registered_to_system(*system) | ||
allow_any_instance_of(LinuxAdmin::SubscriptionManager).to receive_messages(:registered? => system.include?(:sm)) |
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.
Can we use something other than allow_any_instance_of
here?
I think allow(LinuxAdmin::SubscriptionManager).to receive(:new).and_return(double("SubscriptionManager", :registered? => system.include?(:sm)))
would do the job as well, right?
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.
Ah, just saw this was only moved, thought this was new.
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.
Yeah... I wasn't a fan of it myself, but I figured changing it now was not a good idea.
@NickLaMuro I think this is going about it the wrong way (and what I say here probably should have just been done with the original deprecation in #198, I acknowledge) "SubscriptionManager is preferred, and uses Rhn under the hood as the only exception to the rule of 'Rhn is deprecated'" creates the need for these weird hacks. SubscriptionManager should be able to stand up on itself and Rhn utilize SubscriptionManager as a deprecated crutch for however long it's needed. That is to say, any logic that we need for SubscriptionManager found within Rhn should be moved to SubscriptionManager. Any methods that are now missing in Rhn from the move should emit a deprecation warning as expected and then depend on SubscriptionManager to do its job. Make sense? Is this a reason this approach wouldn't work better than what's going on in this PR? |
@chrisarcand To be honest, no, and I have reread your statement about 4-5 times to try to maybe get what you are saying (arguably might be a reading comprehension part on my end... but I digress). That said, I will try and answer: So just doing some quick git research, the fe3b39d7#diff-09e060ae786b7916c51fde7ebb8ae488R24 And looks like it was changed to favor With that background known, what it seems like you are suggesting is that we basically re-write this I also feel like I am missing some context as to "why" To me, it seems like Again, that goes above and beyond the original intent of the PR, which was to remove deprecation warnings (and side-car'd in fixing some ruby warnings that I noticed in the process), because libraries should not emit warnings to consumers by just using them, only if they were used improperly. The MIQ case linked in the description is a situation where it was being used correctly, but a warning was still omitted, so I was trying to fix the oversight (which it seemed to be), not re-architect the entire codebase for |
To all: For what it is worth, I don't mind splitting up or omitting pieces of what I wrote here. Fixing the deprecation warning when a user was using |
My comment was largely thinking in more general terms and now I see why in the code itself it's sort of lost. I'm not really understanding how registrations work and why that conditional has to be that way. @bdunne given your experience here do you see how one can decouple |
We could just kill it completely and release v2.0.0 ¯_(ツ)_/¯ |
Now you're talkin'. |
@chrisarcand well, here is the thing: Specifically if there happens to be a system where both So to summarize the first and second commits:
I would argue that the first and second commits should both be merged to fix the bug, but arguably if we didn't want that much change for a patch release, I could see just merging the first commit. That all said, if you peeps want to refactor this and "make it great again", in addition to or in favor of this PR, be my guest and I won't be offended in whichever route is pick. But, I literally forked this yesterday, so if you think you can trick my statement of:
with a counter of:
I ain't falling for that one. Nope. Nope. Nuh-uh. Peace out. |
While this solves the deprecation warning, I'm in favor of deleting it instead if that's something we can do, therefore I prefer #202 |
Now the
LinuxAdmin::Rhn
has been deprecated in #198 , this means that every instantiation ofLinuxAdmin::Rhn
will then add a deprecation warning toSTDOUT
.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 use (Rhn
orSubscriptionManager
) by initializing each and calling theirregistered?
methods.Furthermore, these means if
Rhn
is registered on the system in addition to the preferredSubscriptionManager
, it theLinuxAdmin::SubscriptionManager.validate_credentials
class method would actually end up callingLinuxAdmin::Rhn.validate_credentials
instead because of the preference.The fix
SubscriptionManager
overRhn
"[DEPRECATION] 'LinuxAdmin::Rhn'..."
in theRegistrationSystem
specs (skipped the other case of it for now)@registration_type
without it being defined (can cause warnings in consumers of this gem)Links