Merge lp:~rvb/maas/migr-bug-1302156-1.5 into lp:maas/1.5

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 2231
Proposed branch: lp:~rvb/maas/migr-bug-1302156-1.5
Merge into: lp:maas/1.5
Diff against target: 40 lines (+16/-7)
1 file modified
src/maasserver/migrations/0072_remove_ipmi_autodetect.py (+16/-7)
To merge this branch: bzr merge lp:~rvb/maas/migr-bug-1302156-1.5
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+214732@code.launchpad.net

Commit message

Backport revision 2244: A 'damage control' branch: if 0072_remove_ipmi_autodetect fails, do not take the whole package down with it.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Simple backport: self-approving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/migrations/0072_remove_ipmi_autodetect.py'
2--- src/maasserver/migrations/0072_remove_ipmi_autodetect.py 2014-03-27 04:15:45 +0000
3+++ src/maasserver/migrations/0072_remove_ipmi_autodetect.py 2014-04-08 12:14:52 +0000
4@@ -1,9 +1,8 @@
5-from django.db import models
6 from provisioningserver.power_schema import IPMI_DRIVER
7-from south.db import db
8 # -*- coding: utf-8 -*-
9-from south.utils import datetime_utils as datetime
10 from south.v2 import DataMigration
11+from django.db.utils import ProgrammingError
12+from maasserver import logger
13
14
15 class Migration(DataMigration):
16@@ -12,10 +11,20 @@
17 """Change IPMI nodes with default power_driver to LAN 2.0."""
18 ipmi_nodes = orm['maasserver.Node'].objects.filter(power_type=u'ipmi')
19 for node in ipmi_nodes:
20- if node.power_parameters.get('power_driver') != '':
21- continue
22- node.power_parameters['power_driver'] = IPMI_DRIVER.LAN_2_0
23- node.save()
24+ if node.power_parameters.get('power_driver') == IPMI_DRIVER.DEFAULT:
25+ node.power_parameters['power_driver'] = IPMI_DRIVER.LAN_2_0
26+ try:
27+ node.save()
28+ except ProgrammingError:
29+ # We catch django.db.utils.ProgrammingError here because of
30+ # the failure described on bug 1302156. Although we didn't
31+ # manage to recreate the failure in a controlled environment,
32+ # this try/except statement will prevent the migration from
33+ # crashing if the failure reappears.
34+ logger.exception(
35+ "Failed to apply migration 0072_remove_ipmi_autodetect. "
36+ "See bug 1302156 "
37+ "(https://bugs.launchpad.net/maas/+bug/1302156).")
38
39 def backwards(self, orm):
40 """LAN 2.0 is valid either way, no need for backwards migration."""

Subscribers

People subscribed via source and target branches

to all changes: