← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/cluster-delete into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/cluster-delete into lp:maas.

Commit message:
Fix cluster delete method.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/cluster-delete/+merge/128481

This branch fixes a small problem when deleting a cluster with nodes in it.

Drive-by fix 1: add a note on the cluster delete page to say explicitly that the nodes in the deleted cluster will be deleted.

Drive-by fix 2: remove an unused form (copy/paste error?)
-- 
https://code.launchpad.net/~rvb/maas/cluster-delete/+merge/128481
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/cluster-delete into lp:maas.
=== modified file 'src/maasserver/dns_connect.py'
--- src/maasserver/dns_connect.py	2012-09-18 16:36:51 +0000
+++ src/maasserver/dns_connect.py	2012-10-08 12:53:34 +0000
@@ -60,8 +60,14 @@
 @receiver(post_delete, sender=Node)
 def dns_post_delete_Node(sender, instance, **kwargs):
     """When a Node is deleted, update the Node's zone file."""
-    from maasserver.dns import change_dns_zones
-    change_dns_zones(instance.nodegroup)
+    try:
+        from maasserver.dns import change_dns_zones
+        change_dns_zones(instance.nodegroup)
+    except NodeGroup.DoesNotExist:
+        # If this Node is being deleted because the whole NodeGroup
+        # has been deleted, no need to update the zone file because
+        # this Node got removed.
+        pass
 
 
 def dns_post_edit_hostname_Node(instance, old_field):

=== modified file 'src/maasserver/templates/maasserver/nodegroup_confirm_delete.html'
--- src/maasserver/templates/maasserver/nodegroup_confirm_delete.html	2012-10-03 07:54:16 +0000
+++ src/maasserver/templates/maasserver/nodegroup_confirm_delete.html	2012-10-08 12:53:34 +0000
@@ -8,7 +8,8 @@
     <div class="block auto-width">
         <h2>
           Are you sure you want to delete the cluster controller
-          "{{ cluster_to_delete.cluster_name }}"?
+          "{{ cluster_to_delete.cluster_name }}"?  This action
+          will also delete all the nodes inside this cluster controller.
         </h2>
         <p>This action is permanent and can not be undone.</p>
         <p>

=== modified file 'src/maasserver/templates/maasserver/nodegroup_edit.html'
--- src/maasserver/templates/maasserver/nodegroup_edit.html	2012-10-03 07:54:16 +0000
+++ src/maasserver/templates/maasserver/nodegroup_edit.html	2012-10-08 12:53:34 +0000
@@ -48,12 +48,6 @@
                href="{% url 'cluster-interface-delete' cluster.uuid interface.interface %}">
                <img src="{{ STATIC_URL }}img/delete.png" alt="delete" />
             </a>
-            <form method="POST"
-                  action="{% url 'settings' %}">
-              {% csrf_token %}
-              <input type="hidden" name="uuid"
-                     value="{{ interface.interface }}" />
-            </form>
           </td>
         </tr>
         {% endfor %}

=== modified file 'src/maasserver/tests/test_nodegroup.py'
--- src/maasserver/tests/test_nodegroup.py	2012-10-04 07:55:27 +0000
+++ src/maasserver/tests/test_nodegroup.py	2012-10-08 12:53:34 +0000
@@ -256,6 +256,13 @@
         ('celery', FixtureResource(CeleryFixture())),
         )
 
+    def test_delete_cluster_with_nodes(self):
+        nodegroup = factory.make_node_group()
+        factory.make_node(nodegroup=nodegroup)
+        nodegroup.delete()
+        self.assertEqual(nodegroup.uuid, nodegroup.work_queue)
+        self.assertFalse(NodeGroup.objects.filter(id=nodegroup.id).exists())
+
     def test_work_queue_returns_uuid(self):
         nodegroup = factory.make_node_group()
         self.assertEqual(nodegroup.uuid, nodegroup.work_queue)