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

Proposed by Josh Kearney
Status: Merged
Approved by: Vish Ishaya
Approved revision: 514
Merged at revision: 515
Proposed branch: lp:~jk0/nova/lp688545
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 85 lines (+33/-10)
4 files modified
nova/compute/manager.py (+1/-0)
nova/db/sqlalchemy/__init__.py (+20/-1)
nova/flags.py (+2/-0)
nova/tests/test_xenapi.py (+10/-9)
To merge this branch: bzr merge lp:~jk0/nova/lp688545
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Todd Willey (community) Approve
Review via email: mp+45080@code.launchpad.net

Commit message

Fixes LP688545.

Description of the change

Check for a running data store instance upon startup once every 10 seconds, up to 12 times (for a duration of two minutes). Also includes some minor PEP8 cleanup and a prior merge conflict fix.

To post a comment you must log in.
Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm. Might be nice to have an exponential falloff. Do we have another bug for recovering from a failed connection?

Revision history for this message
Josh Kearney (jk0) wrote :

> lgtm. Might be nice to have an exponential falloff. Do we have another bug
> for recovering from a failed connection?

I *thought* I saw another bug related to that. I'll go back and make a new bug if there isn't.

Revision history for this message
Josh Kearney (jk0) wrote :

> lgtm. Might be nice to have an exponential falloff. Do we have another bug
> for recovering from a failed connection?

Turns out I was thinking of the XenAPI session. I've opened bug #697019. I'll address it there tomorrow.

Revision history for this message
Todd Willey (xtoddx) wrote :

lgtm

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

ok looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/compute/manager.py'
2--- nova/compute/manager.py 2010-12-30 22:06:48 +0000
3+++ nova/compute/manager.py 2011-01-03 22:16:09 +0000
4@@ -327,6 +327,7 @@
5 instance_ref["internal_id"])
6 return self.driver.get_diagnostics(instance_ref)
7
8+ @exception.wrap_exception
9 def suspend_instance(self, context, instance_id):
10 """suspend the instance with instance_id"""
11 context = context.elevated()
12
13=== modified file 'nova/db/sqlalchemy/__init__.py'
14--- nova/db/sqlalchemy/__init__.py 2010-08-31 23:48:41 +0000
15+++ nova/db/sqlalchemy/__init__.py 2011-01-03 22:16:09 +0000
16@@ -19,6 +19,25 @@
17 """
18 SQLAlchemy database backend
19 """
20+import logging
21+import time
22+
23+from sqlalchemy.exc import OperationalError
24+
25+from nova import flags
26 from nova.db.sqlalchemy import models
27
28-models.register_models()
29+
30+FLAGS = flags.FLAGS
31+
32+
33+for i in xrange(FLAGS.sql_max_retries):
34+ if i > 0:
35+ time.sleep(FLAGS.sql_retry_interval)
36+
37+ try:
38+ models.register_models()
39+ break
40+ except OperationalError:
41+ logging.exception(_("Data store is unreachable."
42+ " Trying again in %d seconds.") % FLAGS.sql_retry_interval)
43
44=== modified file 'nova/flags.py'
45--- nova/flags.py 2011-01-03 19:49:45 +0000
46+++ nova/flags.py 2011-01-03 22:16:09 +0000
47@@ -266,6 +266,8 @@
48 DEFINE_string('sql_idle_timeout',
49 '3600',
50 'timeout for idle sql database connections')
51+DEFINE_integer('sql_max_retries', 12, 'sql connection attempts')
52+DEFINE_integer('sql_retry_interval', 10, 'sql connection retry interval')
53
54 DEFINE_string('compute_manager', 'nova.compute.manager.ComputeManager',
55 'Manager for compute')
56
57=== modified file 'nova/tests/test_xenapi.py'
58--- nova/tests/test_xenapi.py 2010-12-31 01:07:20 +0000
59+++ nova/tests/test_xenapi.py 2011-01-03 22:16:09 +0000
60@@ -250,15 +250,16 @@
61
62 def _create_instance(self):
63 """Creates and spawns a test instance"""
64- values = {'name': 1, 'id': 1,
65- 'project_id': self.project.id,
66- 'user_id': self.user.id,
67- 'image_id': 1,
68- 'kernel_id': 2,
69- 'ramdisk_id': 3,
70- 'instance_type': 'm1.large',
71- 'mac_address': 'aa:bb:cc:dd:ee:ff'
72- }
73+ values = {
74+ 'name': 1,
75+ 'id': 1,
76+ 'project_id': self.project.id,
77+ 'user_id': self.user.id,
78+ 'image_id': 1,
79+ 'kernel_id': 2,
80+ 'ramdisk_id': 3,
81+ 'instance_type': 'm1.large',
82+ 'mac_address': 'aa:bb:cc:dd:ee:ff'}
83 instance = db.instance_create(values)
84 self.conn.spawn(instance)
85 return instance