]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: fail the script if byte-compile step fails 65373/head
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 3 Sep 2025 17:47:04 +0000 (13:47 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 3 Sep 2025 17:55:29 +0000 (13:55 -0400)
Instead of raising an exception on a failure the compileall.compile_dir
returns a boolean indicating if all files compiled successfully or not.
Fail the build.py script if byte compiling fails as that usually
indicates some sort of syntax error.

Fixes: https://tracker.ceph.com/issues/72850
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/build.py

index 01c91fc16803a3759ab861ac0609d2c316fba949..d86737dfd2a3ee67def167fc282593e701dde8d9 100755 (executable)
@@ -301,13 +301,16 @@ def _ignore_cephadmlib(
 def _compile(dest, tempdir):
     """Compile the zipapp."""
     log.info("Byte-compiling py to pyc")
-    compileall.compile_dir(
+    ok = compileall.compile_dir(
         tempdir,
         maxlevels=16,
         legacy=True,
         quiet=1,
         workers=0,
     )
+    if not ok:
+        log.error("compileall.compile_dir failed (see output for details)")
+        raise ValueError("byte-compile failed")
     # TODO we could explicitly pass a python version here
     log.info("Constructing the zipapp file")
     try: