slavkap commented on pull request #4826:
URL: https://github.com/apache/cloudstack/pull/4826#issuecomment-925518739


   Hi @sureshanaparti, @rhtyd, sorry for not answering, but I needed a break 
and took a few days off. Unfortunately, I cannot find the problem with the 
test. The stack trace shows a null pointer exception at line 6508:
   
   > 2021-09-17 12:32:31,667 ERROR [c.c.a.ApiAsyncJobDispatcher] 
(API-Job-Executor-105:ctx-2c8348f6 job-2321) (logid:5537f2da) Unexpected 
exception while executing 
org.apache.cloudstack.api.command.admin.vm.MigrateVirtualMachineWithVolumeCmd
   > java.lang.NullPointerException
   >         at 
com.cloud.vm.UserVmManagerImpl.getVolumePoolMappingForMigrateVmWithStorage(UserVmManagerImpl.java:6508)
   >         at 
com.cloud.vm.UserVmManagerImpl.migrateVirtualMachineWithVolume(UserVmManagerImpl.java:6576)
   >         at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   
   but this leads to commented part in the code of method `moveVMToUser` not 
`getVolumePoolMappingForMigrateVmWithStorage` :
   
   ```
     6462           public UserVm moveVMToUser(final AssignVMCmd cmd) throws 
ResourceAllocationException, ConcurrentOperationException, 
ResourceUnavailableException, InsufficientCapacityException {
     6463               // VERIFICATIONS and VALIDATIONS
     6464       
     6465               // VV 1: verify the two users
     6466               Account caller = 
CallContext.current().getCallingAccount();
     6467               if (!_accountMgr.isRootAdmin(caller.getId())
     6468                       && !_accountMgr.isDomainAdmin(caller.getId())) 
{ // only
     6469                   // root
     6470                   // admin
     6471                   // can
     6472                   // assign
     6473                   // VMs
     6474                   throw new InvalidParameterValueException("Only 
domain admins are allowed to assign VMs and not " + caller.getType());
     6475               }
     6476       
     6477               // get and check the valid VM
     6478               final UserVmVO vm = _vmDao.findById(cmd.getVmId());
     6479               if (vm == null) {
     6480                   throw new InvalidParameterValueException("There is 
no vm by that id " + cmd.getVmId());
     6481               } else if (vm.getState() == State.Running) { // VV 3: 
check if vm is
     6482                   // running
     6483                   if (s_logger.isDebugEnabled()) {
     6484                       s_logger.debug("VM is Running, unable to move 
the vm " + vm);
     6485                   }
     6486                   InvalidParameterValueException ex = new 
InvalidParameterValueException("VM is Running, unable to move the vm with 
specified vmId");
     6487                   ex.addProxyObject(vm.getUuid(), "vmId");
     6488                   throw ex;
     6489               }
     6490       
     6491               final Account oldAccount = 
_accountService.getActiveAccountById(vm.getAccountId());
     6492               if (oldAccount == null) {
     6493                   throw new InvalidParameterValueException("Invalid 
account for VM " + vm.getAccountId() + " in domain.");
     6494               }
     6495               final Account newAccount = 
_accountMgr.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId(), 
cmd.getProjectId());
     6496               if (newAccount == null) {
     6497                   throw new InvalidParameterValueException("Invalid 
accountid=" + cmd.getAccountName() + " in domain " + cmd.getDomainId());
     6498               }
     6499       
     6500               if (newAccount.getState() == Account.State.disabled) {
     6501                   throw new InvalidParameterValueException("The new 
account owner " + cmd.getAccountName() + " is disabled.");
     6502               }
     6503       
     6504               if (cmd.getProjectId() != null && cmd.getDomainId() == 
null) {
     6505                   throw new InvalidParameterValueException("Please 
provide a valid domain ID; cannot assign VM to a project if domain ID is 
NULL.");
     6506               }
     6507       
     6508               //check caller has access to both the old and new 
account
     6509               _accountMgr.checkAccess(caller, null, true, oldAccount);
   ```
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to