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

Bug 1170125

Summary: Changing rpc to 'json-rpc' fails with, "Operation Failed: [Internal Engine Error]", due to errors on character encoding
Product: Red Hat Enterprise Virtualization Manager Reporter: Ori Gofen <ogofen>
Component: ovirt-engineAssignee: Piotr Kliczewski <pkliczew>
Status: CLOSED CURRENTRELEASE QA Contact: Jiri Belka <jbelka>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.5.0CC: acanan, bazulay, gklein, juan.hernandez, lsurette, oourfali, pkliczew, rbalakri, Rhev-m-bugs, srevivo, ykaul, ylavi
Target Milestone: ovirt-3.6.0-rcKeywords: ZStream
Target Release: 3.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-backend-3.6.0-0.0.master.20150412172306.git55ba764 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1195030 (view as bug list) Environment:
Last Closed: 2016-04-20 01:34:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1195030    
Attachments:
Description Flags
logs none

Description Ori Gofen 2014-12-03 10:52:12 UTC
Created attachment 964079 [details]
logs

Description of problem:
Changing rpc to 'json-rpc', while host is in 'maintenance' mode fails.
The characters being sent to oVirt's db are null:

2014-12-03 12:15:34,224 ERROR [org.ovirt.engine.core.bll.UpdateVdsCommand] (ajp-/127.0.0.1:8702-10) [2997f842] Command org.ovirt.engine.core.bll.UpdateVdsCommand throw exception: org.springframework.dao.DataIntegrityViolationException: CallableStatementCallback; SQL [{call updatevdsstatic(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}]; ERROR: null value in column "protocol" violates not-null constraint
  Where: SQL statement "UPDATE vds_static SET host_name =  $1 , free_text_comment =  $2 , ip =  $3 ,vds_unique_id =  $4 , port =  $5 , protocol =  $6 , vds_group_id =  $7 ,vds_name =  $8 ,server_SSL_enabled =  $9 , vds_type =  $10 , _update_date = LOCALTIMESTAMP,vds_strength =  $11 , pm_type =  $12 ,pm_user =  $13 ,pm_password =  $14 , pm_port =  $15 ,pm_options =  $16 ,pm_enabled =  $17 , pm_proxy_preferences =  $18 , pm_secondary_ip =  $19 , pm_secondary_type =  $20 , pm_secondary_user =  $21 , pm_secondary_password =  $22 , pm_secondary_port =  $23 , pm_secondary_options =  $24 , pm_secondary_concurrent =  $25 , pm_detect_kdump =  $26 , otp_validity =  $27 , vds_spm_priority =  $28 , sshKeyFingerprint =  $29 , host_provider_id =  $30 , console_address =  $31 , ssh_port =  $32 , ssh_username =  $33 , disable_auto_pm =  $34  WHERE vds_id =  $35 "
PL/pgSQL function "updatevdsstatic" line 4 at SQL statement; nested exception is org.postgresql.util.PSQLException: ERROR: null value in column "protocol" violates not-null constraint
  Where: SQL statement "UPDATE vds_static SET host_name =  $1 , free_text_comment =  $2 , ip =  $3 ,vds_unique_id =  $4 , port =  $5 , protocol =  $6 , vds_group_id =  $7 ,vds_name =  $8 ,server_SSL_enabled =  $9 , vds_type =  $10 , _update_date = LOCALTIMESTAMP,vds_strength =  $11 , pm_type =  $12 ,pm_user =  $13 ,pm_password =  $14 , pm_port =  $15 ,pm_options =  $16 ,pm_enabled =  $17 , pm_proxy_preferences =  $18 , pm_secondary_ip =  $19 , pm_secondary_type =  $20 , pm_secondary_user =  $21 , pm_secondary_password =  $22 , pm_secondary_port =  $23 , pm_secondary_options =  $24 , pm_secondary_concurrent =  $25 , pm_detect_kdump =  $26 , otp_validity =  $27 , vds_spm_priority =  $28 , sshKeyFingerprint =  $29 , host_provider_id =  $30 , console_address =  $31 , ssh_port =  $32 , ssh_username =  $33 , disable_auto_pm =  $34  WHERE vds_id =  $35 "
PL/pgSQL function "updatevdsstatic" line 4 at SQL statement


this leads to several long exceptions:

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) [spring-jdbc.jar:3.1.1.RELEASE]
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1030) [spring-jdbc.jar:3.1.1.RELEASE]
	at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1064) [spring-jdbc.jar:3.1.1.RELEASE]
	at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:388) [spring-jdbc.jar:3.1.1.RELEASE]
	at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:351) [spring-jdbc.jar:3.1.1.RELEASE]
	at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:181) [spring-jdbc.jar:3.1.1.RELEASE]
	at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeImpl(SimpleJdbcCallsHandler.java:141) [dal.jar:]
	at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeImpl(SimpleJdbcCallsHandler.java:136) [dal.jar:]
	at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeModification(SimpleJdbcCallsHandler.java:74) [dal.jar:]
	at org.ovirt.engine.core.dao.VdsStaticDAODbFacadeImpl.update(VdsStaticDAODbFacadeImpl.java:67) [dal.jar:]
	at org.ovirt.engine.core.dao.VdsStaticDAODbFacadeImpl.update(VdsStaticDAODbFacadeImpl.java:21) [dal.jar:]
	at org.ovirt.engine.core.bll.UpdateVdsCommand$1.runInTransaction(UpdateVdsCommand.java:236) [bll.jar:] 

... ...

at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.delegateInterception(Jsr299BindingsInterceptor.java:74) [jboss-as-weld.jar:7.4.0.Final-redhat-19]
	at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:84) [jboss-as-weld.jar:7.4.0.Final-redhat-19]
	at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:97) [jboss-as-weld.jar:7.4.0.Final-redhat-19]
	at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) [jboss-as-ee.jar:7.4.0.Final-redhat-19]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation.jar:1.1.2.Final-redhat-1]
	at org.ovirt.engine.core.bll.interceptors.ThreadLocalSessionCleanerInterceptor.injectWebContextToThreadLocal(ThreadLocalSessionCleanerInterceptor.java:13) [bll.jar:]
	at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) [:1.7.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_65]
	at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_65]
	at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:89) [jboss-as-ee.jar:7.4.0.Final-redhat-19]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) [jboss-as-ee.jar:7.4.0.Final-redhat-19]

... ...

Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "protocol" violates not-null constraint
  Where: SQL statement "UPDATE vds_static SET host_name =  $1 , free_text_comment =  $2 , ip =  $3 ,vds_unique_id =  $4 , port =  $5 , protocol =  $6 , vds_group_id =  $7 ,vds_name =  $8 ,server_SSL_enabled =  $9 , vds_type =  $10 , _update_date = LOCALTIMESTAMP,vds_strength =  $11 , pm_type =  $12 ,pm_user =  $13 ,pm_password =  $14 , pm_port =  $15 ,pm_options =  $16 ,pm_enabled =  $17 , pm_proxy_preferences =  $18 , pm_secondary_ip =  $19 , pm_secondary_type =  $20 , pm_secondary_user =  $21 , pm_secondary_password =  $22 , pm_secondary_port =  $23 , pm_secondary_options =  $24 , pm_secondary_concurrent =  $25 , pm_detect_kdump =  $26 , otp_validity =  $27 , vds_spm_priority =  $28 , sshKeyFingerprint =  $29 , host_provider_id =  $30 , console_address =  $31 , ssh_port =  $32 , ssh_username =  $33 , disable_auto_pm =  $34  WHERE vds_id =  $35 "
PL/pgSQL function "updatevdsstatic" line 4 at SQL statement
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2101)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1834)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:386)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:379)
	at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.execute(CachedPreparedStatement.java:297)
	at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:404)
	at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1066) [spring-jdbc.jar:3.1.1.RELEASE]
	at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1) [spring-jdbc.jar:3.1.1.RELEASE]
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1014) [spring-jdbc.jar:3.1.1.RELEASE]
	... 145 more

2014-12-03 12:15:34,260 ERROR [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (ajp-/127.0.0.1:8702-10) [2997f842] Correlation ID: 2997f842, Call Stack: null, Custom Event ID: -1, Message: Failed to update Host ogofen-1 (User: admin).
2014-12-03 12:15:34,261 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (ajp-/127.0.0.1:8702-10) Operation Failed: [Internal Engine Error]

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

How reproducible:
100%

Steps to Reproduce:
1.change host to use 'json-rpc' while in 'maintainance' mode via rest,py-sdk

>>> o1.set_protocol(protocol='json')                                                           
>>> o1.update()                                                                                
Traceback (most recent call last):                                                             
  File "<input>", line 1, in <module>    
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/brokers.py", line 11300, in up
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 78, in update
    return self.request('PUT', url, body, headers)                                             
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 118, in 
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 146, in __doRequest                                                                                 
  File "/usr/lib/python2.6/site-packages/ovirtsdk/web/connection.py", line 134, in doRequest   
    raise RequestError, response          
RequestError:  
status: 400 
reason: Bad Request                                                                                                                                      
detail: Internal Engine Error       

Actual results:
operation fails

Expected results:
operation should ve successful

Additional in

Comment 1 Juan Hernández 2014-12-03 11:12:54 UTC
The reason for this is that "json" isn't a valid value for "protocol", currently it must be "xml", "stomp" or "amqp".

However this is incorrectly implemented, as the RESTAPI is using directly constants from the backend, which is prone to unexpected backwards compatibility breakages due to changes in the backend. This needs to be fixed, adding to the RESTAPI a new enum type and the associated validations.

Comment 2 Piotr Kliczewski 2014-12-03 11:28:35 UTC
Backend enum values are as Juan stated and having restapi enum and validation is good idea.

Comment 4 Jiri Belka 2015-05-14 12:49:36 UTC
ok, ovirt-engine-backend-3.6.0-0.0.master.20150412172306.git55ba764.el6.noarch


- added a host as xmlrpc, then maintenance, then change to 'json' (failed as expected: "The reason for this is that "json" isn't a valid value for "protocol", currently it must be "xml", "stomp" or "amqp".), then 'stomp' and it worked. host was activated successfully.