Physical Resource plugin doesn't work with PostgreSQL

Bug #1299122 reported by Pablo Andres Fuente
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Blazar
Won't Fix
Low
Unassigned

Bug Description

If you try to create a host using PostgreSQL as DB, the creation fails due to a DB error.

This is the offending line: https://github.com/stackforge/climate/blob/master/climate/plugins/oshosts/nova_inventory.py#L61

IMO, there are two options, to solve this:
 * Really ugly one: convert to string the hypervisor.id
 * Good one: Add a DB migration to set the ComputeHosts id column with the same type of hypervisor.id

/opt/stack/climate$ climate --debug host-create my_host
Starting new HTTP connection (1): 10.218.74.65
Starting new HTTP connection (1): 10.218.74.65
ERROR: Internal Server Error
Traceback (most recent call last):
  File "/opt/stack/python-climateclient/climateclient/shell.py", line 331, in run_subcommand
    return run_command(cmd, cmd_parser, sub_argv)
  File "/opt/stack/python-climateclient/climateclient/shell.py", line 67, in run_command
    return cmd.run(known_args)
  File "/opt/stack/python-climateclient/climateclient/command.py", line 38, in run
    return super(OpenStackCommand, self).run(parsed_args)
  File "/opt/stack/cliff/cliff/display.py", line 80, in run
    column_names, data = self.take_action(parsed_args)
  File "/opt/stack/python-climateclient/climateclient/command.py", line 44, in take_action
    return self.get_data(parsed_args)
  File "/opt/stack/python-climateclient/climateclient/command.py", line 129, in get_data
    data = resource_manager.create(**body)
  File "/opt/stack/python-climateclient/climateclient/v1/hosts.py", line 28, in create
    return self._create('/os-hosts', values, response_key='host')
  File "/opt/stack/python-climateclient/climateclient/base.py", line 67, in _create
    resp, body = self.request(url, 'POST', body=body)
  File "/opt/stack/python-climateclient/climateclient/base.py", line 134, in request
    raise exception.ClimateClientException(body, code=resp.status_code)
ClimateClientException: ERROR: Internal Server Error

2014-03-28 12:01:40.982 13397 INFO oslo.messaging._drivers.impl_rabbit [-] Connected to AMQP server on localhost:5672
2014-03-28 12:01:40.982 13397 ERROR oslo.messaging._drivers.common [-] Returning exception (ProgrammingError) operator does not exist: character varying = integer
LINE 4: WHERE computehosts.id = 1
                              ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
 'SELECT anon_1.computehosts_created_at AS anon_1_computehosts_created_at, anon_1.computehosts_updated_at AS anon_1_computehosts_updated_at, anon_1.computehosts_id AS anon_1_computehosts_id, anon_1.computehosts_vcpus AS anon_1_computehosts_vcpus, anon_1.computehosts_cpu_info AS anon_1_computehosts_cpu_info, anon_1.computehosts_hypervisor_type AS anon_1_computehosts_hypervisor_type, anon_1.computehosts_hypervisor_version AS anon_1_computehosts_hypervisor_version, anon_1.computehosts_hypervisor_hostname AS anon_1_computehosts_hypervisor_hostname, anon_1.computehosts_memory_mb AS anon_1_computehosts_memory_mb, anon_1.computehosts_local_gb AS anon_1_computehosts_local_gb, anon_1.computehosts_status AS anon_1_computehosts_status, anon_1.computehosts_trust_id AS anon_1_computehosts_trust_id, computehost_extra_capabilities_1.created_at AS computehost_extra_capabilities_1_created_at, computehost_extra_capabilities_1.updated_at AS computehost_extra_capabilities_1_updated_at, computehost_extra_capabilities_1.id AS computehost_extra_capabilities_1_id, computehost_extra_capabilities_1.computehost_id AS computehost_extra_capabilities_1_computehost_id, computehost_extra_capabilities_1.capability_name AS computehost_extra_capabilities_1_capability_name, computehost_extra_capabilities_1.capability_value AS computehost_extra_capabilities_1_capability_value \nFROM (SELECT computehosts.created_at AS computehosts_created_at, computehosts.updated_at AS computehosts_updated_at, computehosts.id AS computehosts_id, computehosts.vcpus AS computehosts_vcpus, computehosts.cpu_info AS computehosts_cpu_info, computehosts.hypervisor_type AS computehosts_hypervisor_type, computehosts.hypervisor_version AS computehosts_hypervisor_version, computehosts.hypervisor_hostname AS computehosts_hypervisor_hostname, computehosts.memory_mb AS computehosts_memory_mb, computehosts.local_gb AS computehosts_local_gb, computehosts.status AS computehosts_status, computehosts.trust_id AS computehosts_trust_id \nFROM computehosts \nWHERE computehosts.id = %(id_1)s \n LIMIT %(param_1)s) AS anon_1 LEFT OUTER JOIN computehost_extra_capabilities AS computehost_extra_capabilities_1 ON anon_1.computehosts_id = computehost_extra_capabilities_1.computehost_id' {'id_1': 1, 'param_1': 1} to caller
2014-03-28 12:01:40.982 13397 ERROR oslo.messaging._drivers.common [-] ['Traceback (most recent call last):\n', ' File "/opt/stack/oslo.messaging/oslo/messaging/rpc/dispatcher.py", line 133, in _dispatch_and_reply\n incoming.message))\n', ' File "/opt/stack/oslo.messaging/oslo/messaging/rpc/dispatcher.py", line 176, in _dispatch\n return self._do_dispatch(endpoint, method, ctxt, args)\n', ' File "/opt/stack/oslo.messaging/oslo/messaging/rpc/dispatcher.py", line 122, in _do_dispatch\n result = getattr(endpoint, method)(ctxt, **new_args)\n', ' File "/opt/stack/climate/climate/utils/service.py", line 77, in run_method\n return method(**kwargs)\n', ' File "/opt/stack/climate/climate/plugins/oshosts/host_plugin.py", line 251, in create_computehost\n host = db_api.host_create(host_details)\n', ' File "/opt/stack/climate/climate/db/api.py", line 304, in host_create\n return IMPL.host_create(values)\n', ' File "/opt/stack/climate/climate/db/sqlalchemy/api.py", line 639, in host_create\n return host_get(host.id)\n', ' File "/opt/stack/climate/climate/db/sqlalchemy/api.py", line 540, in host_get\n return _host_get(get_session(), host_id)\n', ' File "/opt/stack/climate/climate/db/sqlalchemy/api.py", line 531, in _host_get\n return query.filter_by(id=host_id).first()\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2156, in first\n ret = list(self[0:1])\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2023, in __getitem__\n return list(res)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2227, in __iter__\n return self._execute_and_instances(context)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2242, in _execute_and_instances\n result = conn.execute(querycontext.statement, self._params)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1449, in execute\n params)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1584, in _execute_clauseelement\n compiled_sql, distilled_params\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1698, in _execute_context\n context)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context\n context)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 331, in do_execute\n cursor.execute(statement, parameters)\n', "ProgrammingError: (ProgrammingError) operator does not exist: character varying = integer\nLINE 4: WHERE computehosts.id = 1 \n ^\nHINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.\n 'SELECT anon_1.computehosts_created_at AS anon_1_computehosts_created_at, anon_1.computehosts_updated_at AS anon_1_computehosts_updated_at, anon_1.computehosts_id AS anon_1_computehosts_id, anon_1.computehosts_vcpus AS anon_1_computehosts_vcpus, anon_1.computehosts_cpu_info AS anon_1_computehosts_cpu_info, anon_1.computehosts_hypervisor_type AS anon_1_computehosts_hypervisor_type, anon_1.computehosts_hypervisor_version AS anon_1_computehosts_hypervisor_version, anon_1.computehosts_hypervisor_hostname AS anon_1_computehosts_hypervisor_hostname, anon_1.computehosts_memory_mb AS anon_1_computehosts_memory_mb, anon_1.computehosts_local_gb AS anon_1_computehosts_local_gb, anon_1.computehosts_status AS anon_1_computehosts_status, anon_1.computehosts_trust_id AS anon_1_computehosts_trust_id, computehost_extra_capabilities_1.created_at AS computehost_extra_capabilities_1_created_at, computehost_extra_capabilities_1.updated_at AS computehost_extra_capabilities_1_updated_at, computehost_extra_capabilities_1.id AS computehost_extra_capabilities_1_id, computehost_extra_capabilities_1.computehost_id AS computehost_extra_capabilities_1_computehost_id, computehost_extra_capabilities_1.capability_name AS computehost_extra_capabilities_1_capability_name, computehost_extra_capabilities_1.capability_value AS computehost_extra_capabilities_1_capability_value \\nFROM (SELECT computehosts.created_at AS computehosts_created_at, computehosts.updated_at AS computehosts_updated_at, computehosts.id AS computehosts_id, computehosts.vcpus AS computehosts_vcpus, computehosts.cpu_info AS computehosts_cpu_info, computehosts.hypervisor_type AS computehosts_hypervisor_type, computehosts.hypervisor_version AS computehosts_hypervisor_version, computehosts.hypervisor_hostname AS computehosts_hypervisor_hostname, computehosts.memory_mb AS computehosts_memory_mb, computehosts.local_gb AS computehosts_local_gb, computehosts.status AS computehosts_status, computehosts.trust_id AS computehosts_trust_id \\nFROM computehosts \\nWHERE computehosts.id = %(id_1)s \\n LIMIT %(param_1)s) AS anon_1 LEFT OUTER JOIN computehost_extra_capabilities AS computehost_extra_capabilities_1 ON anon_1.computehosts_id = computehost_extra_capabilities_1.computehost_id' {'id_1': 1, 'param_1': 1}\n"]

Dina Belova (dbelova)
Changed in climate:
importance: Undecided → Medium
Revision history for this message
Pablo Andres Fuente (pablo-a-fuente) wrote :

Any opinion about the two choices? In other words, Is the 'Good one' really 'Good one'?

Revision history for this message
Dina Belova (dbelova) wrote :

well, first one is safe and reliable, the second one should be written not to cause problems in future.

Revision history for this message
Pablo Andres Fuente (pablo-a-fuente) wrote :

Do you think that the ugly patch should land ASAP, and then fill a new bug for the "Good one"?

Revision history for this message
Swann Croiset (swann-w) wrote :

I think I've figured out the issue.

The issue come from the reusing of the same id returned by nova_inventory at creation. It's fail when retrieving the freshly row inserted ..

we should simply let the ORM generate his own id (uuid).

see the simple patch coming..

Changed in climate:
assignee: nobody → Swann Croiset (swann-w)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to climate (master)

Fix proposed to branch: master
Review: https://review.openstack.org/87266

Changed in climate:
status: New → In Progress
Revision history for this message
Swann Croiset (swann-w) wrote :

ok .. so it's not so simple.

My prefered way is to migrate the ID field into a Integer .. so the solution 2 proposed.

I Unassigned myself to the bug .. if Pablo wants to fixe it go ahead, If not I can provide the patch.

Changed in climate:
assignee: Swann Croiset (swann-w) → nobody
Revision history for this message
Masahito Muroi (muroi-masahito) wrote :

no activity more than three years and MySQL support is first class now. If PostgreSQL support is needed by users, the priority becomes higher again.

https://governance.openstack.org/tc/resolutions/20170613-postgresql-status.html

Changed in blazar:
status: In Progress → Triaged
importance: Medium → Low
Pierre Riteau (priteau)
Changed in blazar:
status: Triaged → Won't Fix
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on blazar (master)

Change abandoned by Pierre Riteau (<email address hidden>) on branch: master
Review: https://review.openstack.org/97286
Reason: We have deprecated the v2 API, so we won't merge this patch.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.