launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12510
[Merge] lp:~rvb/maas/ensure-master-takes-first into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/ensure-master-takes-first into lp:maas.
Commit message:
Don't rely on the nodegroup.uuid to get the master nodegroup. The first created nodegroup is the master nodegroup.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/ensure-master-takes-first/+merge/126498
Don't rely on the nodegroup.uuid to get the master nodegroup. The first created nodegroup is the master nodegroup.
= Pre-imp =
This was discussed with Julian and Jeroen.
--
https://code.launchpad.net/~rvb/maas/ensure-master-takes-first/+merge/126498
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/ensure-master-takes-first into lp:maas.
=== modified file 'src/maasserver/models/nodegroup.py'
--- src/maasserver/models/nodegroup.py 2012-09-25 14:45:59 +0000
+++ src/maasserver/models/nodegroup.py 2012-09-26 16:43:19 +0000
@@ -85,7 +85,8 @@
from maasserver.models import Node
try:
- master = self.get(uuid='master')
+ # Get the first created nodegroup if it exists.
+ master = self.all().order_by('created')[0:1].get()
except NodeGroup.DoesNotExist:
# The master did not exist yet; create it on demand.
master = self.new(
=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py 2012-09-26 10:00:14 +0000
+++ src/maasserver/tests/test_api.py 2012-09-26 16:43:19 +0000
@@ -3198,12 +3198,6 @@
response = self.report_images([], client=client)
self.assertEqual(httplib.OK, response.status_code)
- def test_report_boot_images_does_not_work_for_other_workers(self):
- NodeGroup.objects.ensure_master()
- client = make_worker_client(factory.make_node_group())
- response = self.report_images([], client=client)
- self.assertEqual(httplib.FORBIDDEN, response.status_code)
-
def test_report_boot_images_stores_images(self):
image = make_boot_image_params()
client = make_worker_client(NodeGroup.objects.ensure_master())
=== modified file 'src/maasserver/tests/test_nodegroup.py'
--- src/maasserver/tests/test_nodegroup.py 2012-09-25 14:45:59 +0000
+++ src/maasserver/tests/test_nodegroup.py 2012-09-26 16:43:19 +0000
@@ -141,12 +141,14 @@
NodeGroup.objects.ensure_master().id,
NodeGroup.objects.ensure_master().id)
- def test_ensure_master_does_not_return_other_nodegroup(self):
- self.assertNotEqual(
- NodeGroup.objects.new(
- factory.make_name('nodegroup'), factory.make_name('uuid'),
- factory.getRandomIPAddress()),
- NodeGroup.objects.ensure_master())
+ def test_ensure_master_returns_oldest_nodegroup(self):
+ first_nodegroup = NodeGroup.objects.new(
+ factory.make_name('nodegroup'), factory.make_name('uuid'),
+ factory.getRandomIPAddress())
+ NodeGroup.objects.new(
+ factory.make_name('nodegroup'), factory.make_name('uuid'),
+ factory.getRandomIPAddress())
+ self.assertEqual(first_nodegroup, NodeGroup.objects.ensure_master())
def test_ensure_master_preserves_existing_attributes(self):
master = NodeGroup.objects.ensure_master()
Follow ups