The type/value for Model's deleted field should be boolean

Bug #1114485 reported by Wenhao Xu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Unassigned

Bug Description

branch: master
database: postgresql

I have met the following exceptions in nova-conductor:

2013-02-04 01:31:55,291.291 11525 TRACE nova.servicegroup.drivers.db ProgrammingError: (ProgrammingError) operator does not exist: boolean = integer
2013-02-04 01:31:55,291.291 11525 TRACE nova.servicegroup.drivers.db LINE 5: ...vice_id = anon_1.services_id AND compute_nodes_1.deleted = 0
2013-02-04 01:31:55,291.291 11525 TRACE nova.servicegroup.drivers.db ^
2013-02-04 01:31:55,291.291 11525 TRACE nova.servicegroup.drivers.db HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

Cause:
postgresql has a native boolean type which doesn't allow the integer (0/1) value.

Extra:
The model's deleted type is boolean defined in db migration, but in nova/db/sqlalchemy/models.py, it is defined as an integer.

class NovaBase(object):
    """Base class for Nova Models."""
    __table_initialized__ = False
    created_at = Column(DateTime, default=timeutils.utcnow)
    updated_at = Column(DateTime, onupdate=timeutils.utcnow)
    deleted_at = Column(DateTime)
    deleted = Column(Integer, default=0)
    metadata = None

deleted should be a boolean.

And query filter on it should be sth like ".deleted=False", not ".deleted=0"

Wenhao Xu (wenhao-x)
Changed in nova:
assignee: nobody → Wenhao Xu (wenhao-x)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Revision history for this message
Boris Pavlovic (boris-42) wrote :

servicegroup?

I couldn't find this table in models.py

Revision history for this message
Wenhao Xu (wenhao-x) wrote :

Exception is raised in servicegroup db driver. But the table is actually the service table.

This is my mistake. I forgot to sync my db after merging the latest code. So there is a mismatch between model and db tables.

I am closing this bug.

Changed in nova:
status: In Progress → Invalid
assignee: Wenhao Xu (wenhao-x) → nobody
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.