← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:snap-lxd-server-key-path into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:snap-lxd-server-key-path into launchpad-buildd:master.

Commit message:
Check the appropriate server.key path for the LXD snap

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/436252

Now that we require the LXD snap, we should use its `server.key` path when checking if LXD has been initialized.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:snap-lxd-server-key-path into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 8329ab4..178d32c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+launchpad-buildd (227) UNRELEASED; urgency=medium
+
+  * Check the appropriate server.key path for the LXD snap.
+
+ -- Colin Watson <cjwatson@xxxxxxxxxx>  Tue, 24 Jan 2023 13:28:47 +0000
+
 launchpad-buildd (226) focal; urgency=medium
 
   * Remove unused "distribution" argument from the binarypackage manager.
diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py
index d585911..7ea8332 100644
--- a/lpbuildd/target/lxd.py
+++ b/lpbuildd/target/lxd.py
@@ -208,7 +208,7 @@ class LXD(Backend):
 
     def _init(self):
         """Configure LXD if necessary."""
-        if not os.path.exists("/var/lib/lxd/server.key"):
+        if not os.path.exists("/var/snap/lxd/common/lxd/server.key"):
             subprocess.check_call(["sudo", "lxd", "init", "--auto"])
             # Generate a LXD client certificate for the buildd user.
             with open("/dev/null", "w") as devnull:
diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py
index edb687a..dea7ad8 100644
--- a/lpbuildd/target/tests/test_lxd.py
+++ b/lpbuildd/target/tests/test_lxd.py
@@ -189,7 +189,7 @@ class TestLXD(TestCase):
 
     def test_create_from_chroot(self):
         fs_fixture = self.useFixture(FakeFilesystem())
-        fs_fixture.add("/var/lib/lxd")
+        fs_fixture.add("/var/snap/lxd/common/lxd")
         processes_fixture = self.useFixture(FakeProcesses())
         processes_fixture.add(lambda _: {}, name="sudo")
         processes_fixture.add(lambda _: {}, name="lxc")
@@ -219,7 +219,7 @@ class TestLXD(TestCase):
 
     def test_create_from_lxd(self):
         fs_fixture = self.useFixture(FakeFilesystem())
-        fs_fixture.add("/var/lib/lxd")
+        fs_fixture.add("/var/snap/lxd/common/lxd")
         processes_fixture = self.useFixture(FakeProcesses())
         processes_fixture.add(lambda _: {}, name="sudo")
         processes_fixture.add(lambda _: {}, name="lxc")
@@ -249,9 +249,9 @@ class TestLXD(TestCase):
 
     def test_create_with_already_initialized_lxd(self):
         fs_fixture = self.useFixture(FakeFilesystem())
-        fs_fixture.add("/var/lib/lxd")
-        os.makedirs("/var/lib/lxd")
-        with open("/var/lib/lxd/server.key", "w"):
+        fs_fixture.add("/var/snap/lxd/common/lxd")
+        os.makedirs("/var/snap/lxd/common/lxd")
+        with open("/var/snap/lxd/common/lxd/server.key", "w"):
             pass
         processes_fixture = self.useFixture(FakeProcesses())
         tmp = self.useFixture(TempDir()).path

Follow ups