Merge lp:~julian-edwards/maas/1.6-savepoints-migration into lp:maas/1.6

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 2551
Proposed branch: lp:~julian-edwards/maas/1.6-savepoints-migration
Merge into: lp:maas/1.6
Diff against target: 24 lines (+4/-1)
1 file modified
src/maasserver/migrations/0088_z_backport_trunk_0099.py (+4/-1)
To merge this branch: bzr merge lp:~julian-edwards/maas/1.6-savepoints-migration
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+232025@code.launchpad.net

Commit message

Fix the 0088_z_backport_trunk_0099 migration which gave a transaction error if matching Network records already existed.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

Selfie. Already discussed with rvb, and I've tested it by re-running the same migration on a 1.6.1 installed Trusty machine.

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/0088_z_backport_trunk_0099.py'
2--- src/maasserver/migrations/0088_z_backport_trunk_0099.py 2014-08-21 06:06:14 +0000
3+++ src/maasserver/migrations/0088_z_backport_trunk_0099.py 2014-08-25 01:49:08 +0000
4@@ -1,5 +1,5 @@
5 from django.core.exceptions import ValidationError
6-from django.db import models
7+from django.db import models, transaction
8 from django.db.utils import IntegrityError
9 from netaddr import IPNetwork
10 from south.db import db
11@@ -44,10 +44,13 @@
12 "Auto created when creating interface %s on cluster "
13 "%s" % (interface.interface, interface.nodegroup.name)),
14 )
15+ sid = transaction.savepoint()
16 try:
17 network.save()
18+ transaction.savepoint_commit(sid)
19 except (ValidationError, IntegrityError):
20 # It probably already exists, keep calm and carry on.
21+ transaction.savepoint_rollback(sid)
22 continue
23
24 def backwards(self, orm):

Subscribers

People subscribed via source and target branches

to all changes: