launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #31824
[Merge] ~tushar5526/launchpad-buildd:wait-for-snap-seeding-to-finish-for-lxd-builds into launchpad-buildd:master
Tushar Gupta has proposed merging ~tushar5526/launchpad-buildd:wait-for-snap-seeding-to-finish-for-lxd-builds into launchpad-buildd:master.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~tushar5526/launchpad-buildd/+git/launchpad-buildd/+merge/476313
Noble by default, comes with a lxd-installer-service which installs LXD snap (if not
installed already) whenever a user runs any lxc command. riscv64 emulated builders
takes upto 2 minutes for snap seeding to complete and in the meantime buildd starts
in the background and begins executing LXD commands which in-turn calls the
lxd-installer-service that also tries to install LXD. This leads to the build crashing
with race condition errors and the build failing with CHROOT errors.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~tushar5526/launchpad-buildd:wait-for-snap-seeding-to-finish-for-lxd-builds into launchpad-buildd:master.
diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py
index 3d66765..b9bba90 100644
--- a/lpbuildd/target/lxd.py
+++ b/lpbuildd/target/lxd.py
@@ -4,6 +4,7 @@
import io
import json
import os
+import platform
import re
import stat
import subprocess
@@ -189,8 +190,22 @@ class LXD(Backend):
if fileptr is not None:
fileptr.close()
+ def _wait_for_snaps_to_seed(self):
+ # It takes around 2 minutes on emulated riscv64 builder machine
+ # for pre-seeded snap to boot up. Non-emulated architectures
+ # (amd64 etc) takes around 10s - 20s.
+ timeout = 180 if platform.machine() == "riscv64" else 40
+ subprocess.check_call(
+ ["sudo", "snap", "wait", "system", "seed.loaded"], timeout=timeout
+ )
+
def _init(self):
"""Configure LXD if necessary."""
+ # LXD is no longer available by default on Noble. We are pre-seeding
+ # the LXD snap in the builder VM images and it takes some time for
+ # seeded snaps to boot up.
+ self._wait_for_snaps_to_seed()
+
# "lxd init" creates a key pair (see
# https://linuxcontainers.org/lxd/docs/master/authentication/), so
# check for that to see whether LXD has already been initialized.
diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py
index 024c900..eb77d18 100644
--- a/lpbuildd/target/tests/test_lxd.py
+++ b/lpbuildd/target/tests/test_lxd.py
@@ -215,6 +215,7 @@ class TestLXD(TestCase):
[proc._args["args"] for proc in processes_fixture.procs],
MatchesListwise(
[
+ Equals(["sudo", "snap", "wait", "system", "seed.loaded"]),
Equals(["sudo", "lxd", "init", "--auto"]),
Equals(["lxc", "list"]),
]
@@ -249,6 +250,7 @@ class TestLXD(TestCase):
[proc._args["args"] for proc in processes_fixture.procs],
MatchesListwise(
[
+ Equals(["sudo", "snap", "wait", "system", "seed.loaded"]),
Equals(["sudo", "lxd", "init", "--auto"]),
Equals(["lxc", "list"]),
]