[lxc-devel] [lxd/master] Fixes for cloud VM images

stgraber on Github lxc-bot at linuxcontainers.org
Mon Apr 20 22:43:03 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200420/ed949b9e/attachment.bin>
-------------- next part --------------
From 3c6415b71795c64cba48210f954a1208c436fe3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 20 Apr 2020 17:03:35 -0400
Subject: [PATCH 1/2] lxd/instances: Export type to templates
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/instance/drivers/driver_lxc.go  | 1 +
 lxd/instance/drivers/driver_qemu.go | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go
index 9dfa2d9dc3..5c7b72d378 100644
--- a/lxd/instance/drivers/driver_lxc.go
+++ b/lxd/instance/drivers/driver_lxc.go
@@ -5060,6 +5060,7 @@ func (c *lxc) templateApplyNow(trigger string) error {
 	// Generate the container metadata
 	containerMeta := make(map[string]string)
 	containerMeta["name"] = c.name
+	containerMeta["type"] = "container"
 	containerMeta["architecture"] = arch
 
 	if c.ephemeral {
diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index 99e41f78ce..35ee186f78 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -1417,6 +1417,7 @@ func (vm *qemu) templateApplyNow(trigger string, path string) error {
 	// Generate the container metadata.
 	instanceMeta := make(map[string]string)
 	instanceMeta["name"] = vm.name
+	instanceMeta["type"] = "virtual-machine"
 	instanceMeta["architecture"] = arch
 
 	if vm.ephemeral {

From 76e19d2eaac67be4448b9a79ce3a52ac0fed4bca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 20 Apr 2020 18:41:04 -0400
Subject: [PATCH 2/2] lxd-agent: Reboot after cloud-init seed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Getting systemd to properly order units showing up halfway through the
boot appears to be near impossible. So until we get some kind of
improved integration with cloud-init which doesn't require us seeding it
through text files, we'll just reboot to have it do its job like on a
clean boot.

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd-agent/main_agent.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd-agent/main_agent.go b/lxd-agent/main_agent.go
index b285d95c16..7f64ccd163 100644
--- a/lxd-agent/main_agent.go
+++ b/lxd-agent/main_agent.go
@@ -85,6 +85,8 @@ func (c *cmdAgent) Run(cmd *cobra.Command, args []string) error {
 
 	// Run cloud-init.
 	if shared.PathExists("/etc/cloud") && shared.StringInSlice("/var/lib/cloud/seed/nocloud-net/meta-data", files) {
+		logger.Info("Seeding cloud-init")
+
 		cloudInitPath := "/run/cloud-init"
 		if shared.PathExists(cloudInitPath) {
 			logger.Info(fmt.Sprintf("Removing %q", cloudInitPath))
@@ -94,9 +96,7 @@ func (c *cmdAgent) Run(cmd *cobra.Command, args []string) error {
 			}
 		}
 
-		logger.Info("Starting cloud-init")
-		shared.RunCommand("systemctl", "daemon-reload")
-		shared.RunCommand("systemctl", "start", "cloud-init.target")
+		shared.RunCommand("systemctl", "reboot")
 	}
 
 	// Mount shares from host.


More information about the lxc-devel mailing list