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
1=== modified file 'nova/db/sqlalchemy/models.py'
2--- nova/db/sqlalchemy/models.py 2011-01-03 19:29:39 +0000
3+++ nova/db/sqlalchemy/models.py 2011-01-05 22:06:18 +0000
4@@ -545,7 +545,8 @@
5 """Register Models and create metadata.
6
7 Called from nova.db.sqlalchemy.__init__ as part of loading the driver,
8- it will never need to be called explicitly elsewhere.
9+ it will never need to be called explicitly elsewhere unless the
10+ connection is lost and needs to be reestablished.
11 """
12 from sqlalchemy import create_engine
13 models = (Service, Instance, InstanceActions,
14
15=== modified file 'nova/service.py'
16--- nova/service.py 2010-12-22 20:59:53 +0000
17+++ nova/service.py 2011-01-05 22:06:18 +0000
18@@ -24,17 +24,21 @@
19 import logging
20 import os
21 import sys
22+import time
23
24 from eventlet import event
25 from eventlet import greenthread
26 from eventlet import greenpool
27
28+from sqlalchemy.exc import OperationalError
29+
30 from nova import context
31 from nova import db
32 from nova import exception
33 from nova import flags
34 from nova import rpc
35 from nova import utils
36+from nova.db.sqlalchemy import models
37
38
39 FLAGS = flags.FLAGS
40@@ -204,6 +208,14 @@
41 self.model_disconnected = True
42 logging.exception(_("model server went away"))
43
44+ try:
45+ models.register_models()
46+ except OperationalError:
47+ logging.exception(_("Data store is unreachable."
48+ " Trying again in %d seconds.") %
49+ FLAGS.sql_retry_interval)
50+ time.sleep(FLAGS.sql_retry_interval)
51+
52
53 def serve(*services):
54 argv = FLAGS(sys.argv)