Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1419364

Summary: Fail to register an unregistered Template through REST due to an NPE when calling updateMaxMemorySize
Product: [oVirt] ovirt-engine Reporter: Maor <mlipchuk>
Component: Backend.CoreAssignee: Maor <mlipchuk>
Status: CLOSED CURRENTRELEASE QA Contact: sefi litmanovich <slitmano>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.1.0CC: bugs, eshenitz, tnisan
Target Milestone: ovirt-4.1.1Flags: rule-engine: ovirt-4.1+
Target Release: 4.1.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-04-21 09:44:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1393257    

Description Maor 2017-02-05 23:38:28 UTC
Description of problem:
Registering a Template will cause an NPE since the init function of ImportVmTemplateFromConfigurationCommand executes updateMaxMemorySize which uses getVmTemplate().
Since unregistered entities does not exist in the vm_static table getVmTemplate() returns null.

This is probably related to the change introduced in https://gerrit.ovirt.org/#/c/67747/

2017-02-05 15:51:26,601+02 ERROR [org.ovirt.engine.core.bll.CommandsFactory] (default task-46) [d1ab8f8b-98d0-4d5f-8282-ec88677fcb32] An exception has occurred while trying to create a comma
nd object for command 'ImportVmTemplateFromConfiguration' with parameters 'ImportVmTemplateParameters:{commandId='824772de-3d01-45ae-b530-5c5c6fa0e8b1', user='null', commandType='Unknown'}':
 WELD-000049: Unable to invoke protected final void org.ovirt.engine.core.bll.CommandBase.postConstruct() on org.ovirt.engine.core.bll.exportimport.ImportVmTemplateFromConfigurationCommand@2
b8292ad
2017-02-05 15:51:26,611+02 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-46) [] Operation Failed: java.lang.NullPointerException
2017-02-05 15:51:26,611+02 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-46) [] Exception: javax.ejb.EJBException: java.lang.NullPointerException
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInNoTx(CMTTxInterceptor.java:213) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInNoTx(CMTTxInterceptor.java:265) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.supports(CMTTxInterceptor.java:374) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:243) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.F
inal]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67) [wildfly-ejb3-10.1.0.Final.jar:10.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)

Version-Release number of selected component (if applicable):

How reproducible:
100%

Steps to Reproduce:
Make sure you have an active DC with multiple storage domains.
1. Create a VM with one disk on a storage domain
2. Create a Template from that VM
3. Move the Storage Domain to maintenance and detach it from the DC
4. Attach the Storage Domain back again and activate it
5. Try to register the Template to the engine using the following REST command:

POST /api/storagedomains/xxxxxxx-xxxx-xxxx-xxxxxx/templates/xxxxxxx-xxxx-xxxx-xxxxxx/register HTTP/1.1
Accept: application/xml
Content-type: application/xml

<action>
    <cluster id='bf5a9e9e-5b52-4b0d-aeba-4ee4493f1072'></cluster>
</action>

Actual results:

NPE

<action>
    <allow_partial_import>true</allow_partial_import>
    <cluster id="a205d3ea-e61c-4d0e-ad55-daaf4ab7f782"/>
    <fault>
        <detail>java.lang.NullPointerException</detail>
        <reason>Operation Failed</reason>
    </fault>
    <status>failed</status>
</action>


Expected results:
The registration should succeed

Additional info:

Comment 1 Tal Nisan 2017-02-06 09:41:30 UTC
*** Bug 1419470 has been marked as a duplicate of this bug. ***

Comment 2 sefi litmanovich 2017-02-14 13:31:10 UTC
Verified on rhevm-4.1.1-0.1.el7.noarch according to the steps in description. Template was imported/registered as expected.