Skip to content

[DO NOT MERGE - TEST] Revert "Rollback of changes with errors during the VM assign" #10851

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/vm/UserVmService.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ VirtualMachine migrateVirtualMachine(Long vmId, Host destinationHost) throws Res
VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinationHost, Map<String, String> volumeToPool) throws ResourceUnavailableException,
ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;

UserVm moveVmToUser(AssignVMCmd moveUserVMCmd) throws ResourceAllocationException, ConcurrentOperationException, ResourceUnavailableException,
UserVm moveVMToUser(AssignVMCmd moveUserVMCmd) throws ResourceAllocationException, ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException;

VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,27 @@
@Override
public void execute() {
try {
UserVm userVm = _userVmService.moveVmToUser(this);
UserVm userVm = _userVmService.moveVMToUser(this);

Check warning on line 123 in api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java#L123

Added line #L123 was not covered by tests
if (userVm == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm");

Check warning on line 125 in api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java#L125

Added line #L125 was not covered by tests
}
UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", userVm).get(0);
response.setResponseName(getCommandName());
setResponseObject(response);
} catch (InvalidParameterValueException e){
e.printStackTrace();
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());

Check warning on line 132 in api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java#L130-L132

Added lines #L130 - L132 were not covered by tests
} catch (Exception e) {
ApiErrorCode errorCode = e instanceof InvalidParameterValueException ? ApiErrorCode.PARAM_ERROR : ApiErrorCode.INTERNAL_ERROR;
String msg = String.format("Failed to move VM [%s].", getVmId());
logger.error(msg, e);
throw new ServerApiException(errorCode, msg);
logger.error("Failed to move vm due to: " + e.getStackTrace());

Check warning on line 134 in api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java#L134

Added line #L134 was not covered by tests
if (e.getMessage() != null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm due to " + e.getMessage());

Check warning on line 136 in api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java#L136

Added line #L136 was not covered by tests
} else if (e.getCause() != null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm due to " + e.getCause());

Check warning on line 138 in api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java#L138

Added line #L138 was not covered by tests
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm");

Check warning on line 140 in api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java#L140

Added line #L140 was not covered by tests
}
}

}

@Override
Expand Down
Loading
Loading