Merge lp:~itohm/nova/lp735974 into lp:~hudson-openstack/nova/trunk

Proposed by Masanori Itoh
Status: Merged
Approved by: Vish Ishaya
Approved revision: 924
Merged at revision: 931
Proposed branch: lp:~itohm/nova/lp735974
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 12 lines (+3/-1)
1 file modified
nova/db/sqlalchemy/api.py (+3/-1)
To merge this branch: bzr merge lp:~itohm/nova/lp735974
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Jay Pipes (community) Approve
Review via email: mp+55698@code.launchpad.net

Description of the change

Added synchronize_session parameter to a query in fixed_ip_disassociate_all_by_timeout() and fix #735974.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

Hi!

The synchronize_session parameter is good, thanks!

However, it looks like that update should also be setting the updated_at column as well, no?

So, could you add it, like so:

update('instance_id': None,
       'leased': 0,
       'updated_at', datetime.datetime.utcnow()}, synchronize_session='fetch')

When running update() form a Query object in SQLalchemy, the normal before_update() hooks that would normally set updated_at automatically are not fired, which is why I believe the manual setting of updated_at is necessary.

Cheers!
jay

review: Needs Fixing
lp:~itohm/nova/lp735974 updated
922. By Masanori Itoh

Rebased to trunk 726.

923. By Masanori Itoh

Rebased to trunk 930.

924. By Masanori Itoh

Added updated_at field to update statement according to Jay's comment.

Revision history for this message
Masanori Itoh (itohm) wrote :

Hi Jay,

Thanks a lot!
I added 'updated_at' field to the update statement, checked nova-network log and did run_tests.sh. Also rebased to trunk rev 930.
Hope this looks good for people. :)

-Masanori

> Hi!
>
> The synchronize_session parameter is good, thanks!
>
> However, it looks like that update should also be setting the updated_at
> column as well, no?
>
> So, could you add it, like so:
>
> update('instance_id': None,
> 'leased': 0,
> 'updated_at', datetime.datetime.utcnow()}, synchronize_session='fetch')
>
> When running update() form a Query object in SQLalchemy, the normal
> before_update() hooks that would normally set updated_at automatically are not
> fired, which is why I believe the manual setting of updated_at is necessary.
>
> Cheers!
> jay

Revision history for this message
Jay Pipes (jaypipes) wrote :

awesome :) thanks for that fix! lgtm now

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

LGTM. I can't actually reproduce the random error message, but this fix seems fine regardless.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/db/sqlalchemy/api.py'
2--- nova/db/sqlalchemy/api.py 2011-03-25 14:21:03 +0000
3+++ nova/db/sqlalchemy/api.py 2011-04-01 15:43:30 +0000
4@@ -660,7 +660,9 @@
5 filter(models.FixedIp.instance_id != None).\
6 filter_by(allocated=0).\
7 update({'instance_id': None,
8- 'leased': 0})
9+ 'leased': 0,
10+ 'updated_at': datetime.datetime.utcnow()},
11+ synchronize_session='fetch')
12 return result
13
14