[lxc-devel] [distrobuilder/master] Fix lxd-agent race condition

stgraber on Github lxc-bot at linuxcontainers.org
Mon Jun 22 19:37:32 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 310 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200622/05bec6c7/attachment.bin>
-------------- next part --------------
From 6100c6662f26c2cd72203b73de0fe078663cf527 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 22 Jun 2020 15:36:50 -0400
Subject: [PATCH 1/2] lxd-agent: Update units
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>
---
 generators/lxd-agent.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/generators/lxd-agent.go b/generators/lxd-agent.go
index 93b47be..1491bd0 100644
--- a/generators/lxd-agent.go
+++ b/generators/lxd-agent.go
@@ -72,7 +72,7 @@ Before=cloud-init.target cloud-init.service cloud-init-local.service
 DefaultDependencies=no
 
 [Service]
-Type=simple
+Type=notify
 WorkingDirectory=/run/lxd_config/9p
 ExecStart=/run/lxd_config/9p/lxd-agent
 Restart=on-failure

From 85ddc5429a47909535921c0407f9cbf391c2bec3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 22 Jun 2020 15:36:57 -0400
Subject: [PATCH 2/2] lxd-agent: Add udev rules
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>
---
 generators/lxd-agent.go | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/generators/lxd-agent.go b/generators/lxd-agent.go
index 1491bd0..251ff05 100644
--- a/generators/lxd-agent.go
+++ b/generators/lxd-agent.go
@@ -85,7 +85,6 @@ WantedBy=multi-user.target
 `
 
 	systemdPath := filepath.Join("/", "lib", "systemd", "system")
-
 	if !lxd.PathExists(filepath.Dir(filepath.Join(sourceDir, systemdPath))) {
 		systemdPath = filepath.Join("/", "usr", "lib", "systemd", "system")
 	}
@@ -129,6 +128,17 @@ WantedBy=multi-user.target
 		return err
 	}
 
+	udevPath := filepath.Join("/", "lib", "udev", "rules.d")
+	if !lxd.PathExists(filepath.Dir(filepath.Join(sourceDir, udevPath))) {
+		udevPath = filepath.Join("/", "usr", "lib", "udev", "rules.d")
+	}
+
+	lxdAgentRules := `ACTION=="add", SYMLINK=="virtio-ports/org.linuxcontainers.lxd", TAG+="systemd", ACTION=="add", RUN+="/bin/systemctl start lxd-agent.service"`
+	err = ioutil.WriteFile(filepath.Join(sourceDir, udevPath, "99-lxd-agent.rules"), []byte(lxdAgentRules), 0400)
+	if err != nil {
+		return err
+	}
+
 	return nil
 }
 


More information about the lxc-devel mailing list