Merge lp:~jk0/nova/lp697019 into lp:~hudson-openstack/nova/trunk

Proposed by Josh Kearney
Status: Merged
Approved by: Cory Wright
Approved revision: 517
Merged at revision: 516
Proposed branch: lp:~jk0/nova/lp697019
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 54 lines (+14/-1)
2 files modified
nova/db/sqlalchemy/models.py (+2/-1)
nova/service.py (+12/-0)
To merge this branch: bzr merge lp:~jk0/nova/lp697019
Reviewer Review Type Date Requested Status
Cory Wright (community) Approve
Ed Leafe (community) Approve
Review via email: mp+45196@code.launchpad.net

Commit message

Recover from a lost data store connection.

To post a comment you must log in.
Revision history for this message
Ed Leafe (ed-leafe) wrote :

The docstring to register_models() in models.py states that it should never have to be called directly, yet here it's obvious that it must. You should update that docstring to explain the case for when a connection is dropped.

Otherwise, it looks good.

review: Approve
lp:~jk0/nova/lp697019 updated
517. By Josh Kearney

Updated register_models() docstring

Revision history for this message
Cory Wright (corywright) wrote :

test and worked as advertised. lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/db/sqlalchemy/models.py'
--- nova/db/sqlalchemy/models.py 2011-01-03 19:29:39 +0000
+++ nova/db/sqlalchemy/models.py 2011-01-05 22:06:18 +0000
@@ -545,7 +545,8 @@
545 """Register Models and create metadata.545 """Register Models and create metadata.
546546
547 Called from nova.db.sqlalchemy.__init__ as part of loading the driver,547 Called from nova.db.sqlalchemy.__init__ as part of loading the driver,
548 it will never need to be called explicitly elsewhere.548 it will never need to be called explicitly elsewhere unless the
549 connection is lost and needs to be reestablished.
549 """550 """
550 from sqlalchemy import create_engine551 from sqlalchemy import create_engine
551 models = (Service, Instance, InstanceActions,552 models = (Service, Instance, InstanceActions,
552553
=== modified file 'nova/service.py'
--- nova/service.py 2010-12-22 20:59:53 +0000
+++ nova/service.py 2011-01-05 22:06:18 +0000
@@ -24,17 +24,21 @@
24import logging24import logging
25import os25import os
26import sys26import sys
27import time
2728
28from eventlet import event29from eventlet import event
29from eventlet import greenthread30from eventlet import greenthread
30from eventlet import greenpool31from eventlet import greenpool
3132
33from sqlalchemy.exc import OperationalError
34
32from nova import context35from nova import context
33from nova import db36from nova import db
34from nova import exception37from nova import exception
35from nova import flags38from nova import flags
36from nova import rpc39from nova import rpc
37from nova import utils40from nova import utils
41from nova.db.sqlalchemy import models
3842
3943
40FLAGS = flags.FLAGS44FLAGS = flags.FLAGS
@@ -204,6 +208,14 @@
204 self.model_disconnected = True208 self.model_disconnected = True
205 logging.exception(_("model server went away"))209 logging.exception(_("model server went away"))
206210
211 try:
212 models.register_models()
213 except OperationalError:
214 logging.exception(_("Data store is unreachable."
215 " Trying again in %d seconds.") %
216 FLAGS.sql_retry_interval)
217 time.sleep(FLAGS.sql_retry_interval)
218
207219
208def serve(*services):220def serve(*services):
209 argv = FLAGS(sys.argv)221 argv = FLAGS(sys.argv)