launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #31163
[Merge] ~pelpsi/launchpad-buildd:restart-snapd into launchpad-buildd:master
Simone Pelosi has proposed merging ~pelpsi/launchpad-buildd:restart-snapd into launchpad-buildd:master.
Commit message:
Restart snapd after certificate and proxy installation
This is required to pick up the correct certificate and to have
every thing updated in the snapd config.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/467348
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pelpsi/launchpad-buildd:restart-snapd into launchpad-buildd:master.
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index d36c69c..266cd9b 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -147,9 +147,11 @@ class BuildSnap(
local_ca_cert.write(decoded_certificate)
os.fchmod(local_ca_cert.fileno(), 0o644)
self.backend.run(["update-ca-certificates"])
- # XXX jugmac00 2024-04-17: We might need to restart snapd
- # so the new certificate will be used
- # snapd folks are unsure, so we need to try ourselves
+
+ def restart_snapd(self):
+ # This is required to pick up the certificate
+ self.backend.run(["systemctl", "restart", "snapd", "snapd.socket"])
+ self.backend.run(["systemctl", "daemon-reload"])
def install_svn_servers(self):
proxy = urlparse(self.args.proxy_url)
@@ -227,6 +229,7 @@ class BuildSnap(
if self.args.use_fetch_service:
self.install_mitm_certificate()
self.install_snapd_proxy(proxy_url=self.args.proxy_url)
+ self.restart_snapd()
def repo(self):
"""Collect git or bzr branch."""
diff --git a/lpbuildd/target/tests/test_build_snap.py b/lpbuildd/target/tests/test_build_snap.py
index 00b00c7..f9ae29b 100644
--- a/lpbuildd/target/tests/test_build_snap.py
+++ b/lpbuildd/target/tests/test_build_snap.py
@@ -244,6 +244,20 @@ class TestBuildSnap(TestCase):
"proxy.https=http://proxy.example:3128/",
]
),
+ RanCommand(
+ [
+ "systemctl",
+ "restart",
+ "snapd",
+ "snapd.socket",
+ ]
+ ),
+ RanCommand(
+ [
+ "systemctl",
+ "daemon-reload",
+ ]
+ ),
]
),
)
@@ -320,6 +334,20 @@ class TestBuildSnap(TestCase):
"proxy.https=http://proxy.example:3128/",
]
),
+ RanCommand(
+ [
+ "systemctl",
+ "restart",
+ "snapd",
+ "snapd.socket",
+ ]
+ ),
+ RanCommand(
+ [
+ "systemctl",
+ "daemon-reload",
+ ]
+ ),
]
),
)