-
Notifications
You must be signed in to change notification settings - Fork 192
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
Modularisation Part1 #1954
Modularisation Part1 #1954
Conversation
18646cb
to
8efbf86
Compare
8efbf86
to
c8cbafa
Compare
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 have been deploying this patch and running some tests on a local environment, everything good so far! 👍
java/code/src/com/suse/manager/webui/services/impl/SystemQuery.java
Outdated
Show resolved
Hide resolved
java/code/src/com/suse/manager/webui/services/impl/SystemQuery.java
Outdated
Show resolved
Hide resolved
java/code/src/com/suse/manager/webui/services/SaltServerActionService.java
Outdated
Show resolved
Hide resolved
java/code/src/com/suse/manager/webui/services/impl/SystemQuery.java
Outdated
Show resolved
Hide resolved
java/code/src/com/suse/manager/webui/services/impl/SystemQuery.java
Outdated
Show resolved
Hide resolved
java/code/src/com/suse/manager/webui/services/impl/SystemQuery.java
Outdated
Show resolved
Hide resolved
79dc74a
to
fb7a408
Compare
e2c368a
to
b1922b2
Compare
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 @lucidd for the effort. I like the direction we are going in. I have just left some small nitpicks, the rest looks good.
java/code/src/com/redhat/rhn/common/messaging/MessageQueue.java
Outdated
Show resolved
Hide resolved
java/code/src/com/redhat/rhn/common/messaging/MessageQueue.java
Outdated
Show resolved
Hide resolved
java/code/src/com/redhat/rhn/frontend/xmlrpc/HandlerFactory.java
Outdated
Show resolved
Hide resolved
java/code/src/com/redhat/rhn/frontend/xmlrpc/api/ApiHandler.java
Outdated
Show resolved
Hide resolved
java/code/src/com/suse/manager/reactor/messaging/MinionStartEventMessageAction.java
Outdated
Show resolved
Hide resolved
java/code/src/com/suse/manager/reactor/messaging/RegisterMinionEventMessageAction.java
Outdated
Show resolved
Hide resolved
7318c81
to
4b1f634
Compare
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.
Hey @lucidd, thanks for all the work here, I think it goes towards the right direction.
I left the bulk of comments inline, many are just nitpicks.
Final notes here: please review this PR's description, it seems like some sections were just marked DONE with no changes in the text (eg. "Test coverage" - I do not really see new Cucumber tests). In particular:
- what is the intention when it comes to backporting this to downstream branches, is there any?
- is there an intention to run the Cucumber testsuite against this branch before merging?
Look forward to see this merged soon.
* HandlerFactory prepopulated with unit test handlers. | ||
* @return HandlerFactory for unit tests. | ||
*/ | ||
public static HandlerFactory mockHandlers() { |
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.
Nitpicks:
- method name: as this returns a Factory (rather than a Collection of Handlers), shouldn't these be named something like
getTestHandlerFactory
/getDefaultHandlerFactory
instead ofmockHandlers
/defaultHandlers
? - shouldn't
mockHandlers
ideally live in unit test code only? Are there cons with that?
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'm not really happy with the naming overall here after the refactoring but i did not want to make too many changes in this PR. I adopted the names you suggest for now but i guess a follow up PR can just focus on finding more fitting names for those classes.
Also moved the mocking to a test utils class.
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java
Show resolved
Hide resolved
public BaseHandler getHandler(String handlerName) { | ||
return (BaseHandler)factory.getObject(handlerName); | ||
public Optional<BaseHandler> getHandler(String handlerName) { | ||
return Optional.ofNullable(handlers.get(handlerName)); |
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 wonder if returning Optional
is the right choice here, as I see that basically all call sites immediately use get()
on the result.
How about instead throwing an unchecked, descriptive Exception here that will result in something like "handlerName not found" in logs, instead of NPE, whenever handlers.get
yields null
- thereby avoiding the Optional
wrapping?
What do you think, what would be pros and cons?
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.
looking at the invocations there is really only 1 place that looks up a handler by user input. I added a orElseThrow
there with a descriptive message. All the other invocations are either in tests or by using only values from getKeys
. Optimally we should probably change this method to return a Set<Tuple2<String, BaseHandler>>
so there is no need for an unsafe get
.
@@ -330,6 +330,6 @@ else if (toolsChannel == null) { | |||
* @param saltServiceIn The SaltService | |||
*/ | |||
public void setSaltService(SaltService saltServiceIn) { |
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 seems to be dead code now (as it should be!)
Consider removing.
} | ||
|
||
/** | ||
* {@inheritDoc} |
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.
Nitpick: I'd suggest to either have this tag on all public methods or just remove it everywhere.
558a7b6
to
55681dd
Compare
…necies to handlers
Co-Authored-By: Abid Mehmood <amehmood@suse.de>
Co-Authored-By: Abid Mehmood <amehmood@suse.de>
55681dd
to
0f8f85a
Compare
@lucidd is there any plan to downstream this to 4.1? |
@moio its already backported to 4.0 https://github.com/SUSE/spacewalk/pull/11009 is there anything else to be done for 4.1? |
Oops, my bad, I wrote 4.1 but meant 4.0. Good that's already backported, I had missed that PR. Thanks. |
What does this PR change?
This PR contains the first batch of changes for modernizing our codebase better. This PR contains:
introducing an interface for all salt (non ssh) operations.
removing some low level salt calls with higher level methods.
marking future methods to be refined as deprecated.
first batch of salt dependent classes changed to have non static method and take dependencies though constructor.
pushing instantiation of of components to the entry points (xml rpc, router, salt reactor).
no logic should have been changed during this.
TODO: double check synchronized methods since multiple instances will change behavior here.
GUI diff
No difference.
Documentation
No documentation needed: no user visible changes
DONE
Test coverage
No tests: covered by existing tests
DONE
Links
Fixes #
Tracks # add downstream PR, if any
Changelogs
If you don't need a changelog check, please mark this checkbox:
If you uncheck the checkbox after the PR is created, you will need to re-run
changelog_test
(see below)Re-run a test
If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run: