Trove - service_statuses updated_at Not Being Set

Bug #1199518 reported by Auston McReynolds
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack DBaaS (Trove)
Fix Released
Low
Auston McReynolds

Bug Description

```
mysql> select * from service_statuses where instance_id='bf39fa53-58eb-439d-bd33-f631c512a412';
+--------------------------------------+--------------------------------------+-----------+--------------------+------------+
| id | instance_id | status_id | status_description | updated_at |
+--------------------------------------+--------------------------------------+-----------+--------------------+------------+
| ceee1296-5e6b-4810-995d-80257c090b1a | bf39fa53-58eb-439d-bd33-f631c512a412 | 1 | running | NULL |
+--------------------------------------+--------------------------------------+-----------+--------------------+------------+
```

`updated_at` should not be NULL, because the status flipped multiple times (from new, to building, to running).

What's happening?

```
2013-06-25 21:52:41.204 15910 DEBUG trove.db.models [req-02b4bc65-d97e-4c69-ac26-b3a4f471a316 radmin 89f6c273df2142e8abf4fcd36df3cbdf] Saving DBInstance: {u'updated': datetime.datetime(2013, 6, 25, 21, 52, 41, 204734), '_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x443bd90>, u'name': u'DBaaSBox', u'task_id': 5, u'created': datetime.datetime(2013, 6, 25, 21, 52, 41, 204383), u'deleted': False, u'tenant_id': u'89f6c273df2142e8abf4fcd36df3cbdf', u'task_description': 'The instance is building.', u'volume_size': 5, 'errors': {}, u'flavor_id': u'6', u'id': 'bf39fa53-58eb-439d-bd33-f631c512a412'} save /opt/stack/trove/trove/db/models.py:59
2013-06-25 21:52:41.233 15910 DEBUG trove.instance.models [req-02b4bc65-d97e-4c69-ac26-b3a4f471a316 radmin 89f6c273df2142e8abf4fcd36df3cbdf] Tenant 89f6c273df2142e8abf4fcd36df3cbdf created new Trove instance bf39fa53-58eb-439d-bd33-f631c512a412... _create_resources /opt/stack/trove/trove/instance/models.py:455
2013-06-25 21:52:41.233 15910 DEBUG trove.db.models [req-02b4bc65-d97e-4c69-ac26-b3a4f471a316 radmin 89f6c273df2142e8abf4fcd36df3cbdf] Saving InstanceServiceStatus: {'updated': datetime.datetime(2013, 6, 25, 21, 52, 41, 233914), '_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x4439290>, u'status_id': 23, 'created': datetime.datetime(2013, 6, 25, 21, 52, 41, 233766), u'instance_id': 'bf39fa53-58eb-439d-bd33-f631c512a412', 'errors': {}, u'status_description': 'new', u'id': 'ceee1296-5e6b-4810-995d-80257c090b1a'} save /opt/stack/trove/trove/db/models.py:59
```
Note how the name for the field in InstanceServiceStatus is 'updated', much like it's sister table DBInstance.

DBInstance (aka instances) has a column named 'updated':

```
mysql> select * from instances where id='bf39fa53-58eb-439d-bd33-f631c512a412' \G;
*************************** 1. row ***************************
                 id: bf39fa53-58eb-439d-bd33-f631c512a412
            created: 2013-06-25 21:52:41
            updated: 2013-06-25 21:52:44
```

but from above, `service_statuses` does not; it's named `updated_at`, not `updated`.

That isn't quite the problem though.

https://github.com/openstack/trove/blob/7ab80b554dde5f1f1e61b6a8c45492c5ac27ed6b/trove/instance/models.py#L713

Note that the data_fields does not include `updated_at`:

    _data_fields = ['instance_id', 'status_id', 'status_description']

Also note the lack of an overridden `save()` method.

I think this, in conjunction with the Guest changing the state: https://github.com/openstack/trove/blob/b0834124e8bc917cbb6ed2881234ff4b33826f44/trove/guestagent/manager/mysql_service.py#L204

Means that it needs to override `save()` for InstanceServiceStatus and do something like `self['updated_at'] = utils.utcnow()`, much like is done in other places:

(i.e. https://github.com/openstack/trove/blob/7ab80b554dde5f1f1e61b6a8c45492c5ac27ed6b/trove/db/models.py#L54 and https://github.com/openstack/trove/blob/7ab80b554dde5f1f1e61b6a8c45492c5ac27ed6b/trove/guestagent/models.py#L54 )

Changed in trove:
importance: Undecided → Low
Changed in trove:
assignee: nobody → amcrn (amcrn)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to trove (master)

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to trove (master)

Reviewed: https://review.openstack.org/45146
Committed: http://github.com/openstack/trove/commit/10b1801ac98a6d38641eac29b75c851b0361e76d
Submitter: Jenkins
Branch: master

commit 10b1801ac98a6d38641eac29b75c851b0361e76d
Author: amcrn <email address hidden>
Date: Wed Sep 4 17:35:22 2013 -0700

    service_statuses updated_at Field Not Set

    The service_statuses updated_at value is never set due to
    inconsistent column naming ('updated' is automatically set in the
    base model). The result is the value remains NULL throughout the
    instance creation lifecycle, despite multiple row updates.

    Fix: override save() and set updated_at (following the pattern
    established in agent_heartbeats)

    Change-Id: I71fea5001fa1868d221f50c34605022e6a1022bd
    Closes-Bug: #1199518

Changed in trove:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in trove:
milestone: none → icehouse-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in trove:
milestone: icehouse-1 → 2014.1
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.