diff mbox series

[3/3] builders: avoid shell pipeline for disk space check

Message ID 20260611061330.733392-4-anders.heimer@est.tech
State New
Headers show
Series Avoid shell use | expand

Commit Message

Anders Heimer June 11, 2026, 6:13 a.m. UTC
The disk space probe used a shell pipeline to run findmnt and awk.
Ask findmnt for the available-byte field directly and pass the
command as argv, avoiding shell interpretation.

AI-Generated: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Anders Heimer <anders.heimer@est.tech>
---
 builders.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/builders.py b/builders.py
index 418ef1b..1b65e55 100644
--- a/builders.py
+++ b/builders.py
@@ -81,7 +81,9 @@  def canStartBuild(builder, wfb, request):
 
         bytes_in_gb = 1024 * 1024 * 1024
 
-        cmd = yield shell("findmnt -T %s --df -n --bytes | awk '{print $5}'" % mountpoint, wfb.worker, builder)
+        cmd = yield shell(["findmnt", "-T", mountpoint, "--df", "-n", "--bytes",
+                           "-o", "AVAIL"],
+                          wfb.worker, builder)
         space = int(cmd.stdout.strip())
         if space < threshold * bytes_in_gb:
             log.msg("Detected {0} GB of space available on {1}, less than threshold of {2} GB. Can't start build".format(space / bytes_in_gb, name, threshold))