Upgrading from 1.9.0~alpha2+bzr4287-0ubuntu1~wily1 to 1.9.0~alpha2+bzr4293-0ubuntu1~wily1. The latest change sin trunk break the image import.
2015-09-22 17:20:59 [-] Exception in thread Thread-8:
2015-09-22 17:20:59 [-] Traceback (most recent call last):
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
2015-09-22 17:20:59 [-] self.run()
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/threading.py", line 763, in run
2015-09-22 17:20:59 [-] Exception in thread Thread-7:
2015-09-22 17:20:59 [-] self.__target(*self.__args, **self.__kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 481, in call_within_transaction
2015-09-22 17:20:59 [-] return func_outside_txn(*args, **kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 308, in retrier
2015-09-22 17:20:59 [-] return func(*args, **kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/django16/django/db/transaction.py", line 371, in inner
2015-09-22 17:20:59 [-] return func(*args, **kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/dist-packages/maasserver/bootresources.py", line 698, in write_content_thread
2015-09-22 17:20:59 [-] rfile = BootResourceFile.objects.get(id=rid)
2015-09-22 17:20:59 [-] File "/usr/lib/django16/django/db/models/manager.py", line 151, in get
2015-09-22 17:20:59 [-] return self.get_queryset().get(*args, **kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/django16/django/db/models/query.py", line 310, in get
2015-09-22 17:20:59 [-] self.model._meta.object_name)
2015-09-22 17:20:59 [-] DoesNotExist: BootResourceFile matching query does not exist.
2015-09-22 17:20:59 [-]
2015-09-22 17:20:59 [-] Traceback (most recent call last):
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
2015-09-22 17:20:59 [-] self.run()
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/threading.py", line 763, in run
2015-09-22 17:20:59 [-] self.__target(*self.__args, **self.__kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 481, in call_within_transaction
2015-09-22 17:20:59 [-] return func_outside_txn(*args, **kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 308, in retrier
2015-09-22 17:20:59 [-] return func(*args, **kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/django16/django/db/transaction.py", line 371, in inner
2015-09-22 17:20:59 [-] return func(*args, **kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/python2.7/dist-packages/maasserver/bootresources.py", line 698, in write_content_thread
2015-09-22 17:20:59 [-] rfile = BootResourceFile.objects.get(id=rid)
2015-09-22 17:20:59 [-] File "/usr/lib/django16/django/db/models/manager.py", line 151, in get
2015-09-22 17:20:59 [-] return self.get_queryset().get(*args, **kwargs)
2015-09-22 17:20:59 [-] File "/usr/lib/django16/django/db/models/query.py", line 310, in get
2015-09-22 17:20:59 [-] self.model._meta.object_name)
2015-09-22 17:20:59 [-] DoesNotExist: BootResourceFile matching query does not exist.
FWIW, deferToDatabase() ensures that the function it calls is wrapped in a transaction. However, _import_resources() explicitly manages its own transactions, and it breaks if it is called within a transaction. Unfortunately there was no test, no assertion, and no documentation stating this.