public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/dotnet9.0] main: Reduce time to detect hanging builds
@ 2026-07-24 15:33 Omair Majid
0 siblings, 0 replies; only message in thread
From: Omair Majid @ 2026-07-24 15:33 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/dotnet9.0
Branch : main
Commit : 0ced22313116a3917f7f2a5b9af64e3ac4623f32
Author : Omair Majid <omajid@redhat.com>
Date : 2026-07-24T11:32:37-04:00
Stats : +62/-1 in 1 file(s)
URL : https://src.fedoraproject.org/rpms/dotnet9.0/c/0ced22313116a3917f7f2a5b9af64e3ac4623f32?branch=main
Log:
Reduce time to detect hanging builds
Fail the build if it produces no output for a while, instead of a
hardcoded entire-build timeout of 5 hours.
Co-Authored-By: Tom Deseyn <tdeseyn@redhat.com>
---
diff --git a/dotnet9.0.spec b/dotnet9.0.spec
index bb8fdc8..dc3e7a7 100644
--- a/dotnet9.0.spec
+++ b/dotnet9.0.spec
@@ -675,6 +675,8 @@ function retry_until_success {
set +e
while [[ $exit_code != 0 ]] && [[ $tries != 0 ]]; do
(( tries = tries - 1 ))
+ # Clean stale build state so retries start fresh.
+ rm -rf .packages $(find . -name artifacts -type d)
"$@"
exit_code=$?
done
@@ -682,8 +684,67 @@ function retry_until_success {
return $exit_code
}
+# Runs a command and kills it if it produces no output.
+# Use a longer timeout on machines with fewer cores since builds are slower.
+function output_timeout {
+ # 30m on machines with more than 4 cores, 60m on smaller machines where builds are slower.
+ # The aarch64 Neoverse N1 CI machines have 4 cores and need the longer timeout.
+ local nprocs=$(nproc)
+ local idle_timeout=1800
+ if (( nprocs <= 4 )); then
+ idle_timeout=3600
+ fi
+
+ # Create a pipe we'll read the output from for timeout detection.
+ local fifo=$(mktemp -u)
+ mkfifo "$fifo"
+
+ # Create a process group so we can kill every process including children.
+ # And use a long timeout (5h) in (the unlikely) case output timeout detection continues to be triggered.
+ setsid timeout --foreground 5h "$@" &> "$fifo" &
+ local cmd_pid=$!
+
+ # Read lines from the output with a timeout.
+ # Disable tracing to avoid 'set -x' noise from the read loop appearing in the output.
+ local timed_out=false
+ local traceflags=$-
+ set +x
+ while true; do
+ local rc=0
+ IFS= read -t $idle_timeout -r line || rc=$?
+ if (( rc == 0 )); then
+ printf '%s\n' "$line"
+ elif (( rc > 128 )); then
+ echo "output_timeout: no output for ${idle_timeout}s" >&2
+ timed_out=true
+ break
+ else
+ [[ -z $line ]] || printf '%s\n' "$line"
+ break
+ fi
+ done < "$fifo"
+ [[ $traceflags != *x* ]] || set -x
+
+ if $timed_out; then
+ # Hang detected: kill the process group, then collect the exit code.
+ kill -9 -- -$cmd_pid 2>/dev/null || true
+ wait $cmd_pid 2>/dev/null
+ local exit_code=$?
+ else
+ # Normal exit: collect the real exit code, then clean up any orphaned processes.
+ wait $cmd_pid 2>/dev/null
+ local exit_code=$?
+ kill -9 -- -$cmd_pid 2>/dev/null || true
+ fi
+
+ # Cleanup.
+ rm -f "$fifo"
+
+ return $exit_code
+}
+
VERBOSE=1 retry_until_success $max_attempts \
- timeout 5h \
+ output_timeout \
./build.sh \
--source-only \
--release-manifest %{SOURCE5} \
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-24 15:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-24 15:33 [rpms/dotnet9.0] main: Reduce time to detect hanging builds Omair Majid
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox