Add NULL check during restoreVM operation when host is removed - #13779
Add NULL check during restoreVM operation when host is removed#13779nvazquez wants to merge 3 commits into
Conversation
…e#571) * Add NULL check during restore VM operation when host is not available/removed * fix line ending pre commit failure * update logging with details of removed host and vm --------- Co-authored-by: Sachin R Doddaguni <s_rudrappadoddagu@apple.com> (cherry picked from commit 1dbda12ccdca1aaf86ef8f9b185986c9d22b567e)
| // host row may have been hard-deleted from DB, treat like removed | ||
| if (host == null) { | ||
| logger.warn("Host {} not found", hostId); | ||
| s_logger.warn(String.format("Host with id %s not found in DB for VM %s (%s)", |
There was a problem hiding this comment.
s_logger doesn't exist in this class. It only has logger (see the line right below this one). This won't compile.
| // host row may have been hard-deleted from DB, treat like removed | ||
| if (host == null) { | ||
| logger.warn("Host {} not found", hostId); | ||
| s_logger.warn(String.format("Host with id %s not found in DB for VM %s (%s)", |
There was a problem hiding this comment.
Use {} placeholders here to match the branch below, instead of String.format.
| import org.apache.cloudstack.acl.SecurityChecker; | ||
| import org.apache.cloudstack.api.ApiCommandResourceType; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import com.cloud.host.Status; |
There was a problem hiding this comment.
com.cloud.host.Status is out of place here, mixed into the org.apache.cloudstack.* block.
| } | ||
|
|
||
| @Test | ||
| public void testRestoreVirtualMachineWhenHostRemoved() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { |
There was a problem hiding this comment.
Should we also add a test for the host-row-missing case, not just Removed?
|
@blueorangutan package |
|
@vladimirpetrov a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 18790 |
|
@blueorangutan package |
|
@vladimirpetrov a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 18791 |
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #13779 +/- ##
=============================================
- Coverage 17.69% 3.69% -14.01%
=============================================
Files 5925 449 -5476
Lines 533539 38176 -495363
Branches 65274 7072 -58202
=============================================
- Hits 94427 1409 -93018
+ Misses 428435 36580 -391855
+ Partials 10677 187 -10490
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 18792 |
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 18794 |
|
@blueorangutan package |
|
@vladimirpetrov a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 18795 |
Description
This PR addresses a fix for the following use case:
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?