Add NULL check during restoreVM operation when host is removed - #13779
Open
nvazquez wants to merge 2 commits into
Open
Add NULL check during restoreVM operation when host is removed#13779nvazquez wants to merge 2 commits into
nvazquez wants to merge 2 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)
Damans227
reviewed
Aug 4, 2026
| // 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)", |
Collaborator
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.
Damans227
reviewed
Aug 4, 2026
| // 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)", |
Collaborator
There was a problem hiding this comment.
Use {} placeholders here to match the branch below, instead of String.format.
Damans227
reviewed
Aug 4, 2026
| import org.apache.cloudstack.acl.SecurityChecker; | ||
| import org.apache.cloudstack.api.ApiCommandResourceType; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import com.cloud.host.Status; |
Collaborator
There was a problem hiding this comment.
com.cloud.host.Status is out of place here, mixed into the org.apache.cloudstack.* block.
Damans227
reviewed
Aug 4, 2026
| } | ||
|
|
||
| @Test | ||
| public void testRestoreVirtualMachineWhenHostRemoved() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { |
Collaborator
There was a problem hiding this comment.
Should we also add a test for the host-row-missing case, not just Removed?
This file contains hidden or 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
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.
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?