Colin Watson has proposed merging ~cjwatson/launchpad-buildd:avoid-snap-cdn-harder into launchpad-buildd:master.
Commit message: Set SNAPPY_STORE_NO_CDN=1 in more places when using a builder proxy Requested reviews: Launchpad code reviewers (launchpad-reviewers) Related bugs: Bug #1945712 in launchpad-buildd: "Try harder to avoid CDNs in snap downloads from builders" https://bugs.launchpad.net/launchpad-buildd/+bug/1945712 For more details, see: https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/409664 We already set this in snapd's environment, but there are other places where snaps might be downloaded (manual `snap download`, `stage-snaps` in `snapcraft.yaml`, etc.). This avoids having to keep track of CDN networks in builder proxy configuration. -- Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:avoid-snap-cdn-harder into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog index 23a279d..002f4ba 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ launchpad-buildd (203) UNRELEASED; urgency=medium * Remove some more "slave" terminology from tests. + * Add SNAPPY_STORE_NO_CDN=1 to the environment in more places when using a + builder proxy (LP: #1945712). -- Colin Watson <[email protected]> Fri, 01 Oct 2021 13:43:31 +0100 diff --git a/lpbuildd/target/build_charm.py b/lpbuildd/target/build_charm.py index f37c638..d5ade71 100644 --- a/lpbuildd/target/build_charm.py +++ b/lpbuildd/target/build_charm.py @@ -119,11 +119,7 @@ class BuildCharm(BuilderProxyOperationMixin, VCSOperationMixin, self.args.name, self.args.build_path) check_path_escape(self.buildd_path, build_context_path) - env = OrderedDict() - if self.args.proxy_url: - env["http_proxy"] = self.args.proxy_url - env["https_proxy"] = self.args.proxy_url - env["GIT_PROXY_COMMAND"] = "/usr/local/bin/lpbuildd-git-proxy" + env = self.build_proxy_environment(proxy_url=self.args.proxy_url) args = ["charmcraft", "pack", "-v", "--destructive-mode"] self.run_build_command(args, env=env, cwd=build_context_path) diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py index bdbc760..7ec133b 100644 --- a/lpbuildd/target/build_snap.py +++ b/lpbuildd/target/build_snap.py @@ -179,17 +179,13 @@ class BuildSnap(BuilderProxyOperationMixin, VCSOperationMixin, def pull(self): """Run pull phase.""" logger.info("Running pull phase...") - env = OrderedDict() + env = self.build_proxy_environment(proxy_url=self.args.proxy_url) env["SNAPCRAFT_LOCAL_SOURCES"] = "1" env["SNAPCRAFT_SETUP_CORE"] = "1" if not self.args.private: env["SNAPCRAFT_BUILD_INFO"] = "1" env["SNAPCRAFT_IMAGE_INFO"] = self.image_info env["SNAPCRAFT_BUILD_ENVIRONMENT"] = "host" - if self.args.proxy_url: - env["http_proxy"] = self.args.proxy_url - env["https_proxy"] = self.args.proxy_url - env["GIT_PROXY_COMMAND"] = "/usr/local/bin/lpbuildd-git-proxy" self.run_build_command( ["snapcraft", "pull"], cwd=os.path.join("/build", self.args.name), @@ -205,15 +201,11 @@ class BuildSnap(BuilderProxyOperationMixin, VCSOperationMixin, def build(self): """Run all build, stage and snap phases.""" logger.info("Running build phase...") - env = OrderedDict() + env = self.build_proxy_environment(proxy_url=self.args.proxy_url) if not self.args.private: env["SNAPCRAFT_BUILD_INFO"] = "1" env["SNAPCRAFT_IMAGE_INFO"] = self.image_info env["SNAPCRAFT_BUILD_ENVIRONMENT"] = "host" - if self.args.proxy_url: - env["http_proxy"] = self.args.proxy_url - env["https_proxy"] = self.args.proxy_url - env["GIT_PROXY_COMMAND"] = "/usr/local/bin/lpbuildd-git-proxy" self.run_build_command( ["snapcraft"], cwd=os.path.join("/build", self.args.name), diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py index 6ddd1d0..d9ce31f 100644 --- a/lpbuildd/target/lxd.py +++ b/lpbuildd/target/lxd.py @@ -193,9 +193,11 @@ class LXD(Backend): """Configure LXD if necessary.""" if not os.path.exists("/var/lib/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: - subprocess.call(["lxc", "list"], stdout=devnull) + # Generate a LXD client certificate for the buildd user. (By way of + # socket activation, this also serves the purpose of starting + # lxd.service back up if it has crashed.) + with open("/dev/null", "w") as devnull: + subprocess.call(["lxc", "list"], stdout=devnull) def create(self, image_path, image_type): """See `Backend`.""" diff --git a/lpbuildd/target/proxy.py b/lpbuildd/target/proxy.py index 4834e46..4835c78 100644 --- a/lpbuildd/target/proxy.py +++ b/lpbuildd/target/proxy.py @@ -38,4 +38,7 @@ class BuilderProxyOperationMixin: full_env["http_proxy"] = self.args.proxy_url full_env["https_proxy"] = self.args.proxy_url full_env["GIT_PROXY_COMMAND"] = "/usr/local/bin/lpbuildd-git-proxy" + # Avoid needing to keep track of snap store CDNs in proxy + # configuration. + full_env["SNAPPY_STORE_NO_CDN"] = "1" return full_env diff --git a/lpbuildd/target/tests/test_build_charm.py b/lpbuildd/target/tests/test_build_charm.py index d695a37..a095f8b 100644 --- a/lpbuildd/target/tests/test_build_charm.py +++ b/lpbuildd/target/tests/test_build_charm.py @@ -330,6 +330,7 @@ class TestBuildCharm(TestCase): "http_proxy": "http://proxy.example:3128/", "https_proxy": "http://proxy.example:3128/", "GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy", + "SNAPPY_STORE_NO_CDN": "1", } self.assertThat(build_charm.backend.run.calls, MatchesListwise([ RanBuildCommand( @@ -391,6 +392,7 @@ class TestBuildCharm(TestCase): "http_proxy": "http://proxy.example:3128/", "https_proxy": "http://proxy.example:3128/", "GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy", + "SNAPPY_STORE_NO_CDN": "1", } self.assertThat(build_charm.backend.run.calls, MatchesListwise([ RanBuildCommand( diff --git a/lpbuildd/target/tests/test_build_oci.py b/lpbuildd/target/tests/test_build_oci.py index bdbc2ab..3a9a12e 100644 --- a/lpbuildd/target/tests/test_build_oci.py +++ b/lpbuildd/target/tests/test_build_oci.py @@ -281,6 +281,7 @@ class TestBuildOCI(TestCase): "http_proxy": "http://proxy.example:3128/", "https_proxy": "http://proxy.example:3128/", "GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy", + "SNAPPY_STORE_NO_CDN": "1", } self.assertThat(build_oci.backend.run.calls, MatchesListwise([ RanBuildCommand( diff --git a/lpbuildd/target/tests/test_build_snap.py b/lpbuildd/target/tests/test_build_snap.py index 1a529ea..52b1867 100644 --- a/lpbuildd/target/tests/test_build_snap.py +++ b/lpbuildd/target/tests/test_build_snap.py @@ -334,6 +334,7 @@ class TestBuildSnap(TestCase): "http_proxy": "http://proxy.example:3128/", "https_proxy": "http://proxy.example:3128/", "GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy", + "SNAPPY_STORE_NO_CDN": "1", } self.assertThat(build_snap.backend.run.calls, MatchesListwise([ RanBuildCommand( @@ -390,6 +391,7 @@ class TestBuildSnap(TestCase): "http_proxy": "http://proxy.example:3128/", "https_proxy": "http://proxy.example:3128/", "GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy", + "SNAPPY_STORE_NO_CDN": "1", } self.assertThat(build_snap.backend.run.calls, MatchesListwise([ RanBuildCommand( @@ -474,6 +476,7 @@ class TestBuildSnap(TestCase): "http_proxy": "http://proxy.example:3128/", "https_proxy": "http://proxy.example:3128/", "GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy", + "SNAPPY_STORE_NO_CDN": "1", } self.assertThat(build_snap.backend.run.calls, MatchesListwise([ RanBuildCommand(["snapcraft"], cwd="/build/test-snap", **env),
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : [email protected] Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp

