Merge lp:~allenap/maas/clear-installation-script-set-on-release into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 5673
Proposed branch: lp:~allenap/maas/clear-installation-script-set-on-release
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 31 lines (+1/-13)
2 files modified
src/maasserver/models/node.py (+1/-0)
src/metadataserver/fixtures/initial_data.yaml (+0/-13)
To merge this branch: bzr merge lp:~allenap/maas/clear-installation-script-set-on-release
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+315656@code.launchpad.net

Commit message

Clear a node's current_installation_script_set when releasing.

Also remove the remaining Django database fixtures. None of the tests rely upon the objects created.

Description of the change

An error when landing https://code.launchpad.net/~allenap/maas/only-ignore-conf-in-run/+merge/315648 led me to this fix. I was able to reproduce it locally, though not reliably. I don't understand the interaction particularly well, but this change made it impossible for me to reproduce.

This branch also eliminates the use of Django database fixtures. The landing failure from the aforementioned branch also has exceptions relating to the application of these fixtures, but none of the tests need them any more, so getting rid of them seems fairly uncontroversial.

The primary test error this branch is intended to fix:

ERROR: maasserver.models.tests.test_node.TestNode.test_release_clears_installation_results
----------------------------------------------------------------------
testtools.testresult.real._StringException: Empty attachments:
  Twisted logs

Traceback (most recent call last):
  File ".../src/maastesting/runtest.py", line 134, in _run_user
    result = function(*args, **kwargs)
  File ".../testtools-2.2.0-py3.5.egg/testtools/testcase.py", line 719, in _run_test_method
    return self._get_test_method()()
  File ".../src/maasserver/models/tests/test_node.py", line 1899, in test_release_clears_installation_results
    node.release()
  File ".../src/maasserver/models/node.py", line 2394, in release
    self._release(user)
  File ".../src/maasserver/models/node.py", line 2465, in _release
    self._finalize_release()
  File ".../src/maasserver/utils/orm.py", line 669, in call_within_transaction
    return func_within_txn(*args, **kwargs)
  File "/usr/lib/python3.5/contextlib.py", line 30, in inner
    return func(*args, **kwds)
  File ".../src/maasserver/models/node.py", line 2483, in _finalize_release
    self.save()
  File ".../src/maasserver/models/node.py", line 1522, in save
    super(Node, self).save(*args, **kwargs)
  File ".../src/maasserver/models/cleansave.py", line 28, in save
    self.full_clean()
  File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 1171, in full_clean
    raise ValidationError(errors)
django.core.exceptions.ValidationError: {'current_installation_script_set': ['script set instance with id 103 does not exist.']}

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Ah, I suppose it might be recreated as a new object on save()? Weird that it wouldn't happen every time then, though...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'src/maasserver/fixtures'
2=== modified file 'src/maasserver/models/node.py'
3--- src/maasserver/models/node.py 2017-01-25 15:33:49 +0000
4+++ src/maasserver/models/node.py 2017-01-26 09:36:45 +0000
5@@ -2453,6 +2453,7 @@
6 # Clear installation results
7 if self.current_installation_script_set is not None:
8 self.current_installation_script_set.delete()
9+ self.current_installation_script_set = None
10
11 # Clear the nodes acquired filesystems.
12 self._clear_acquired_filesystems()
13
14=== removed directory 'src/metadataserver/fixtures'
15=== removed file 'src/metadataserver/fixtures/initial_data.yaml'
16--- src/metadataserver/fixtures/initial_data.yaml 2012-02-22 15:51:15 +0000
17+++ src/metadataserver/fixtures/initial_data.yaml 1970-01-01 00:00:00 +0000
18@@ -1,13 +0,0 @@
19-- model: auth.user
20- pk: 1
21- fields:
22- username: 'maas-init-node'
23- first_name: 'Node initializer'
24- last_name: 'Special user'
25- email: ''
26- password: '!'
27- is_staff: false
28- is_active: false
29- is_superuser: false
30- last_login: 2012-02-16
31- date_joined: 2012-02-16