[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-7839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14196092#comment-14196092
 ] 

Joris van Lieshout commented on CLOUDSTACK-7839:
------------------------------------------------

Additional information:

The public boolean "storagePoolHasEnoughSpace" in StorageManagerImpl.java has a 
loop that goes through all volumes. The second if statement in the loop is 
where the NP exception is thrown because _templateDao.findById returns no 
templates

       for (Volume volume : volumes) {
            if (volume.getTemplateId() != null) {
                VMTemplateVO tmpl = 
_templateDao.findById(volume.getTemplateId());
                if (tmpl.getFormat() != ImageFormat.ISO) {
                    allocatedSizeWithtemplate = 
_capacityMgr.getAllocatedPoolCapacity(poolVO, tmpl);
                }
            }
            if (volume.getState() != Volume.State.Ready) {
                totalAskingSize = totalAskingSize + 
getVolumeSizeIncludingHvSsReserve(volume, pool);
            }
        }

This SQL statement will show that the removed field of vm_template is not null 
causeing findById to return nothing.
select vm_template.name, vm_template.removed from vm_instance join vm_template 
on vm_instance.vm_template_id=vm_template.id where vm_instance.name like 
'%testinstancefromtmpl1%';

vm_template.name, vm_template.removed
'testinstancetmp','2014-11-04 09:21:34'

> Unable to live migrate an instance to another host in a cluster from which 
> the template has been deleted
> --------------------------------------------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-7839
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-7839
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: Template
>    Affects Versions: Future, 4.3.0, 4.4.0, 4.5.0, 4.3.1, 4.4.1, 4.6.0
>            Reporter: Joris van Lieshout
>            Priority: Critical
>
> ACS throws an null pointer exception when you try to live migrate an instance 
> to another host in a cluster and the template of that instance has been 
> deleted.
> I have pasted the exception below.
> Steps to reproduce the issue:
> 1. create an instance from iso
> 2. stop the instance
> 3. create a template from the root volume
> 4. create a new instance from that template
> 5. leave the instance running
> 6. delete the template
> 7. try the live migrate the instance to another host in the cluster
> The migrate button in the web interface will not respond.
> The exception below can be found in the management-server log 
> 2014-11-04 14:08:45,509 ERROR [cloud.api.ApiServer] 
> (TP-Processor49:ctx-35286d62 ctx-3de77f98) unhandled exception executing api 
> command: findHostsForMigration
> java.lang.NullPointerException
>         at 
> com.cloud.storage.StorageManagerImpl.storagePoolHasEnoughSpace(StorageManagerImpl.java:1561)
>         at 
> org.apache.cloudstack.storage.allocator.AbstractStoragePoolAllocator.filter(AbstractStoragePoolAllocator.java:199)
>         at 
> org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator.select(ClusterScopeStoragePoolAllocator.java:110)
>         at 
> org.apache.cloudstack.storage.allocator.AbstractStoragePoolAllocator.allocateToPool(AbstractStoragePoolAllocator.java:109)
>         at 
> com.cloud.server.ManagementServerImpl.findSuitablePoolsForVolumes(ManagementServerImpl.java:1250)
>         at 
> com.cloud.server.ManagementServerImpl.listHostsForMigrationOfVM(ManagementServerImpl.java:1150)
>         at sun.reflect.GeneratedMethodAccessor643.invoke(Unknown Source)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:622)
>         at 
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
>         at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
>         at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
>         at 
> org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
>         at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>         at 
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
>         at com.sun.proxy.$Proxy193.listHostsForMigrationOfVM(Unknown Source)
>         at 
> org.apache.cloudstack.api.command.admin.host.FindHostsForMigrationCmd.execute(FindHostsForMigrationCmd.java:75)
>         at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:161)
>         at com.cloud.api.ApiServer.queueCommand(ApiServer.java:531)
>         at com.cloud.api.ApiServer.handleRequest(ApiServer.java:374)
>         at 
> com.cloud.api.ApiServlet.processRequestInContext(ApiServlet.java:323)
>         at com.cloud.api.ApiServlet.access$000(ApiServlet.java:53)
>         at com.cloud.api.ApiServlet$1.run(ApiServlet.java:115)
>         at 
> org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
>         at 
> org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
>         at 
> org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
>         at com.cloud.api.ApiServlet.processRequest(ApiServlet.java:112)
>         at com.cloud.api.ApiServlet.doGet(ApiServlet.java:74)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>         at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>         at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>         at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>         at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>         at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>         at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>         at 
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
>         at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>         at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>         at 
> org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
>         at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
>         at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
>         at 
> org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
>         at 
> org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
>         at 
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
>         at java.lang.Thread.run(Thread.java:701)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to