-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CLOUDSTACK-9323: Fix cancel host maintenance can… #1454
Conversation
@abhinandanprateek I don't see the Marvin test case in the PR. Have you pushed the latest commit? Also, most of the changes seem to be formatting changes in non-related parts of the class which hides the actual fix. Would it be possible to reverse these formatting changes to reduce the size of the patch to only the change in |
124ab4e
to
ee59d62
Compare
@jsb added the marvin file and reverted to pre-commit formatted code. |
Marvin test output: root@ccp:~/cloudstack(host-maint)# ./host_maint.sh
==== Marvin Init Started ==== === Marvin Parse Config Successful === === Marvin Setting TestData Successful=== ==== Log Folder Path: /tmp//MarvinLogs//Mar_28_2016_11_47_46_LB5B4I. All logs will be available here ==== === Marvin Init Logging Successful=== ==== Marvin Init Successful ==== ===final results are now copied to: /tmp//MarvinLogs/test_host_maintenance_CXM1EL===
|
abc0f7c
to
b4c427f
Compare
@@ -2112,11 +2112,13 @@ private boolean doCancelMaintenance(final long hostId) { | |||
|
|||
/* TODO: move to listener */ | |||
_haMgr.cancelScheduledMigrations(host); | |||
|
|||
boolean vms_migrating = false; | |||
final List<VMInstanceVO> vms = _haMgr.findTakenMigrationWork(); | |||
for (final VMInstanceVO vm : vms) { | |||
if (vm != null && vm.getHostId() != null && vm.getHostId() == hostId) { | |||
s_logger.info("Unable to cancel migration because the vm is being migrated: " + vm); |
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 you turn the if on line 2119 to a method call like isVmMigrating(vm, hostId)? Or even ( if vm can never be null ) vm.isMigrating(hostId)
I think that it will improve the readability of this segment you are working. Also... is there a need to check all VMs ? Once you find one that is migrating do you still need to keep checking if they are migrating? If there is not a need, try changing the loop for a while, or issuing a break.
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.
@alexandrelimassantana
The reason for not breaking from the for loop is to log info about vms that are under migration. Probably the log level should be increased to warn. These log messages would be valuable for trouble shooting.
On readability front yes the code will be improved further.
b4c427f
to
f36e4dd
Compare
Output from marvin test: TMP=/tmp === Marvin Parse Config Successful === === Marvin Setting TestData Successful=== ==== Log Folder Path: /tmp//MarvinLogs//Mar_30_2016_10_02_53_F4MC43. All logs will be available here ==== === Marvin Init Logging Successful=== ==== Marvin Init Successful ==== 2 Hypervisor = 3e270f2d-f054-4cbe-85e1-0fbc30e8a414 ===final results are now copied to: /tmp//MarvinLogs/test_host_maintenance_RF5DFR=== echo Wed Mar 30 10:06:16 IST 2016 Wed Mar 30 10:06:16 IST 2016 |
e1f763e
to
a461fa9
Compare
@abhinandanprateek Looks like jenkins found some problems with your index. I'd suggest rebasing against the current master making all the needed merges and pushing again. |
@abhinandanprateek would you mind rebasing to current master so I can test this in my CI? Thanks... |
a461fa9
to
247182c
Compare
@cristofolini @swill rebased the PR, up for CI now, Thank you. |
247182c
to
388c53a
Compare
CI RESULTSHAS FAILURES, NEEDS WORK! Please address the following issue.
Associated Uploads
Uploads will be available until Comment created by |
@swill In my environment I am using macchinina templates for testing. These are not there by default but are pretty handy in testing due to their small size. This is the reason for the error above. Adding these to CI environment will speed up many such tests. If it is lot of work I will revert to using standard CentOS templates, comments ?
cc @jburwell |
On comparing test execution times with macchinina Vs Centos builtin template I did not find much of a difference. So modifying the test to go with the standard builtin templates. @swill |
388c53a
to
b11ab1c
Compare
Updated marvin test to use the builtin template. @swill |
@abhinandanprateek: Thank you. I will run the whole set of tests against it again tonight. I have to let the current tests finish and run this on its own because I have to change the tests run specifically for this PR. I should have results in the morning. |
@abhinandanprateek slight delay. I am going to blow away my CI setup and reinstall it now to get it running on SSD drives so I can better parallelize my tests. This will delay this test till at least tomorrow evening. |
@swill if it is possible to run integration/component/test_host_maintenance.py first than please do that as it is a new test added for this fix, followed by full marvin suite. |
CI RESULTS84/85 TESTS PASSEDThe test that failed is a test that commonly fails in my environment and has been verified to be an environment issue. Associated Uploads
Uploads will be available until Comment created by |
if (vm != null && vm.getHostId() != null && vm.getHostId() == hostId) { | ||
s_logger.info("Unable to cancel migration because the vm is being migrated: " + vm); | ||
return false; | ||
if (vm.getHostId() != null && vm.getHostId() == hostId) { |
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 this conditional right?
vm.getHostId() != null && vm.getHostId() == hostId
It is looking a little weird to me.
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.
My bad, I was not thinking straight.
The conditional is ok
@abhinandanprateek tests have passed, thanks for the updates. Can you do a @jburwell Does this pass your code review now? I am trying to get two independent LGTM code reviews before merging whenever possible, so if you have reviewed the code, please let me know. |
I have gone through the code, it LGTM |
|
||
if callback is None: | ||
return INVALID_INPUT |
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 function should always return an Array value. If the callback
is None
, why not raise a ValueError
rather than return a incompatible value? Not only is it more idiomatic Python, but it preserves the type semantics of the function.
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.
Due to following two reason I preferred returning an error code instead of an exception.
- Returning a pre-defined error code makes it usage more flexible as raising an exception or continue will be defined by the user of the method.
- "INVALID_INPUT" is a Marvin error code used by other utility methods to signal bad inputs and this maintains that pattern.
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.
@abhinandanprateek while it is permissible Python, it is considered an anti-pattern for a Python function to return different types. In this case, it can return a scalar value or a multi-return. Raising a ValueError
is the idiomatic Python approach to handling an invalid parameter value. In addition to ensuring that the function always returns the same type, raising an error in this manner will cause the test to fail fast without callers having the check the return to properly fail.
@swill just reviewed. @abhinandanprateek I have a few more comments to be addressed on the test cases. |
b11ab1c
to
c09c902
Compare
@abhinandanprateek, I believe you are away this week, but can your address @jburwell's comments when you have a chance. Thanks. |
838385a
to
67f3527
Compare
…celled the host come back to normal state gracefully. Added marvin tests for host maintennace.
67f3527
to
182ab64
Compare
@jburwell can I get your LGTM? I will run CI on this again today because some code has changed since the last run. |
LGTM for code |
Sorry for the delay on this one guys. I think this one is ready now... |
CLOUDSTACK-9323: Fix cancel host maintenance canFix cancel host maintenance so that if maintenance is cancelled the host come back to normal state gracefully. Added marvin tests for host maintennace. * pr/1454: CLOUDSTACK-9323: Fix Cancel maintenance so that if maintenance is cancelled the host come back to normal state gracefully. Added marvin tests for host maintennace. Signed-off-by: Will Stevens <williamstevens@gmail.com>
Fix cancel host maintenance so that if maintenance is cancelled the host come back to normal state gracefully.
Added marvin tests for host maintennace.