Repository: conjure-up/conjure-up

Issue:
deploying kubernetes-core onto LXD breaks due to nested LXDs
Since adding the placement-sync code, deploying kubernetes-core attempts to put easyrsa onto a LXD container inside the LXD container 0. There's no reason to do this, LXD deploys can be flat.

Discussion:

Patch:
diff --git a/conjureup/controllers/deploy/gui.py b/conjureup/controllers/deploy/gui.py
index 66958e6..54f872c 100644
--- a/conjureup/controllers/deploy/gui.py
+++ b/conjureup/controllers/deploy/gui.py
@@ -24,13 +24,22 @@ class DeployController:
         self.assignments = defaultdict(list)
         self.deployed_juju_machines = {}
         self.maas_machine_map = {}
-        self.sync_with_bundle()
+        self.init_machines_assignments()
 
-    def sync_with_bundle(self):
-        # If no machines are specified, add a machine for each app:
+    def init_machines_assignments(self):
+        """Initialize the controller's machines and assignments.
+
+        If no machines are specified, or we are deploying to a LXD
+        controller, add a top-level machine for each app - assumes
+        that no placement directives exist in the bundle, and logs any
+        it finds.
+
+        Otherwise, syncs assignments from the bundle's applications'
+        placement specs.
+        """
         bundle = app.metadata_controller.bundle
 
-        if len(bundle.machines) == 0:
+        if len(bundle.machines) == 0 or app.current_cloud == "localhost":
             self.generate_juju_machines()
         else:
             self.sync_assignments()
@@ -112,9 +121,16 @@ class DeployController:
         for bundle_application in sorted(bundle.services,
                                          key=attrgetter('service_name')):
             if bundle_application.placement_spec:
-                app.log.warning("Ignoring placement spec because no machines "
-                                "were set in the bundle: {}".format(
-                                    bundle.application.placement_spec))
+                if app.current_cloud == "localhost":
+                    app.log.info("Ignoring placement spec because we are "
+                                 "deploying to LXD: {}".format(
+                                     bundle_application.placement_spec))
+                else:
+                    app.log.warning("Ignoring placement spec because no "
+                                    "machines were set in the "
+                                    "bundle: {}".format(
+                                        bundle_application.placement_spec))
+
             for n in range(bundle_application.num_units):
                 bundle.add_machine(dict(series=bundle.series),
                                    str(midx))


Test patch:
diff --git a/test/test_controllers_deploy_gui.py b/test/test_controllers_deploy_gui.py
index 1b72ad3..eac49e8 100644
--- a/test/test_controllers_deploy_gui.py
+++ b/test/test_controllers_deploy_gui.py
@@ -14,7 +14,7 @@ from conjureup.controllers.deploy.gui import DeployController
 class DeployGUIRenderTestCase(unittest.TestCase):
 
     def setUp(self):
-        with patch.object(DeployController, 'sync_with_bundle'):
+        with patch.object(DeployController, 'init_machines_assignments'):
             self.controller = DeployController()
 
         self.utils_patcher = patch(
@@ -74,7 +74,7 @@ class DeployGUIRenderTestCase(unittest.TestCase):
 class DeployGUIFinishTestCase(unittest.TestCase):
 
     def setUp(self):
-        with patch.object(DeployController, 'sync_with_bundle'):
+        with patch.object(DeployController, 'init_machines_assignments'):
             self.controller = DeployController()
 
         self.controllers_patcher = patch(