From 76231d0dbdead3102af1e66af560351172c9ca42 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Mon, 3 Jun 2024 10:43:02 -0500 Subject: [PATCH] feat(remote): disable cleanup with envvar Setting SNAPCRAFT_REMOTE_BUILD_DISABLE_CLEANUP will prevent snapcraft from cleaning up logs in Launchpad. Signed-off-by: Callahan Kovacs --- snapcraft/commands/remote.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/snapcraft/commands/remote.py b/snapcraft/commands/remote.py index cfbaf19d2a..3150208544 100644 --- a/snapcraft/commands/remote.py +++ b/snapcraft/commands/remote.py @@ -237,13 +237,11 @@ def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: ) except RemoteBuildError: emit.progress("Starting build failed.", permanent=True) - emit.progress("Cleaning up") - builder.cleanup() + self._cleanup() raise except lazr.restfulclient.errors.Conflict: emit.progress("Remote repository already exists.", permanent=True) - emit.progress("Cleaning up") - builder.cleanup() + self._cleanup() return 75 try: @@ -254,10 +252,16 @@ def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: builder.cancel_builds() returncode = 0 if returncode != 75: # TimeoutError - emit.progress("Cleaning up") - builder.cleanup() + self._cleanup() return returncode + def _cleanup(self) -> None: + if os.getenv("SNAPCRAFT_REMOTE_BUILD_DISABLE_CLEANUP"): + emit.progress("Not cleaning up remote build.") + else: + emit.progress("Cleaning up") + self._services.remote_build.cleanup() + def _monitor_and_complete( self, build_id: str | None, builds: Collection[Build] ) -> int: