public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Felix Kaechele <felix@kaechele.ca>
To: git-commits@fedoraproject.org
Subject: [rpms/nginx] f44: Merge branch 'rawhide' into f45
Date: Thu, 26 Nov 2026 04:15:24 GMT	[thread overview]
Message-ID: <179566652493.1.6099366023161021147.rpms-nginx-b1ae56ecdcee@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/nginx
Branch : f44
Commit : b1ae56ecdcee1b73b3730ebddcdc1af472b2fa51
Author : Felix Kaechele <felix@kaechele.ca>
Date   : 2026-11-25T22:53:00-05:00
Stats  : +119/-17 in 3 file(s)
URL    : https://src.fedoraproject.org/rpms/nginx/c/b1ae56ecdcee1b73b3730ebddcdc1af472b2fa51?branch=f44

Log:
Merge branch 'rawhide' into f45

---
diff --git a/nginx-upgrade b/nginx-upgrade
index 8bf987a..fa698bc 100755
--- a/nginx-upgrade
+++ b/nginx-upgrade
@@ -6,22 +6,103 @@
 # master process of each instance, then gracefully stopping the old master.
 # This allows for zero-downtime upgrades of nginx.
 
-# Last updated: 2026-03-08
+# Last updated: 2026-11-24
 
+# Seconds to wait for the old master to rename its PID file, for the old
+# master to exit and for systemd to follow the new master.
 TIMEOUT=10
+# Seconds to wait for the new master to parse its configuration and write its
+# PID file. Failures are detected early, so this only bounds a slow start
+# (e.g. resolving upstream hostnames). Matches systemd's default
+# TimeoutStartSec.
+START_TIMEOUT=90
+
+err() {
+	# Errors go to stderr and to the journal: the RPM file trigger discards
+	# stdout, and a failed upgrade leaves the old binary running.
+	echo "ERROR: $*" >&2
+	echo "$*" | systemd-cat -t nginx-upgrade -p err 2>/dev/null
+}
+
+valid_pid() {
+	# usage: valid_pid <pid> <cgroup>
+	# PID file contents are not trusted: only accept a PID that belongs to
+	# the unit's cgroup, as systemd does for PID files not owned by root.
+	local pid=$1 cgroup=$2
+	[[ $pid =~ ^[0-9]+$ ]] && (( pid > 1 )) &&
+		grep -qxF "0::$cgroup" "/proc/$pid/cgroup" 2>/dev/null
+}
 
 wait_for_file() {
 	# usage: wait_for_file <present|absent> <file> <label>
 	local mode=$1 file=$2 label=$3
 	local i
 
-	for ((i=0; i<TIMEOUT; i++)); do
+	# Poll often: if the new master fails quickly, the old master renames
+	# .oldbin back to the PID file and a slow poll would never see it.
+	for ((i=0; i<TIMEOUT*10; i++)); do
 		[[ $mode == present && -f $file ]] && return 0
 		[[ $mode == absent  && ! -f $file ]] && return 0
-		sleep 1
+		sleep 0.1
+	done
+
+	err "$label - file never ${mode}ed: $file"
+	return 1
+}
+
+wait_for_new_master() {
+	# usage: wait_for_new_master <pid-file> <old-pid-file> <old-pid> <cgroup> <label>
+	# Prints the new master's PID on success.
+	#
+	# The old master renames its PID file to .oldbin before it executes the
+	# new binary, but the new master only writes its PID file after it has
+	# parsed its configuration. The old master must not be stopped before
+	# that: systemd (Type=forking) would find no PID to follow, consider the
+	# unit stopped and kill the new master (rhbz#2582004).
+	local file=$1 old_file=$2 old_pid=$3 cgroup=$4 label=$5
+	local i pid
+
+	for ((i=0; i<START_TIMEOUT*10; i++)); do
+		pid=
+		{ read -r pid < "$file"; } 2>/dev/null
+		if [[ $pid != "$old_pid" ]] && valid_pid "$pid" "$cgroup"; then
+			echo "$pid"
+			return 0
+		fi
+		# If the new master exits (e.g. invalid configuration), the old
+		# master renames .oldbin back to the PID file. It is also removed
+		# if the old master itself exits.
+		if [[ ! -f $old_file ]]; then
+			if kill -0 "$old_pid" 2>/dev/null; then
+				err "$label - upgrade aborted: the new master exited, the old master ($old_pid) keeps running the old binary. Check the configuration and restart the service."
+			else
+				err "$label - upgrade aborted: the old master ($old_pid) exited."
+			fi
+			return 1
+		fi
+		sleep 0.1
+	done
+
+	err "$label - upgrade aborted: no new master PID in $file after ${START_TIMEOUT}s, the old master ($old_pid) keeps running the old binary. Restart the service."
+	return 1
+}
+
+wait_for_main_pid() {
+	# usage: wait_for_main_pid <service-unit> <pid> <label>
+	# Check that systemd follows the new master once the old one is gone.
+	local unit=$1 pid=$2 label=$3
+	local i
+
+	for ((i=0; i<TIMEOUT*10; i++)); do
+		if ! /bin/systemctl is-active -q "$unit"; then
+			err "$label - $unit is no longer active after the upgrade."
+			return 1
+		fi
+		[[ $(/bin/systemctl show -p MainPID --value "$unit") == "$pid" ]] && return 0
+		sleep 0.1
 	done
 
-	echo "ERROR: $label - file never ${mode}ed: $file" >&2
+	err "$label - systemd does not track the new master ($pid) as the main process of $unit."
 	return 1
 }
 
@@ -29,23 +110,38 @@ upgrade_instance() {
 	# usage: upgrade_instance <service-unit> <pid-file>
 	local unit="$1" pid_file="$2"
 	local old_pid_file="${pid_file}.oldbin"
+	local old_pid new_pid cgroup
 
 	if [ ! -f "$pid_file" ]; then
 		echo "[$unit] No PID file at $pid_file - skipping."
 		return 0
 	fi
 
+	# Take the old master's PID from systemd rather than from a PID file.
+	old_pid=$(/bin/systemctl show -p MainPID --value "$unit")
+	cgroup=$(/bin/systemctl show -p ControlGroup --value "$unit")
+	if [[ -z $cgroup ]] || ! valid_pid "$old_pid" "$cgroup"; then
+		err "[$unit] Could not determine the main PID - skipping."
+		return 1
+	fi
+
 	echo "[$unit] Starting new master process..."
 	/bin/systemctl kill --signal=SIGUSR2 --kill-who=main "$unit"
 
-	wait_for_file present "$old_pid_file" "$unit - new master start" || return 1
+	wait_for_file present "$old_pid_file" "[$unit] new master start" || return 1
+
+	new_pid=$(wait_for_new_master "$pid_file" "$old_pid_file" "$old_pid" "$cgroup" "[$unit] new master start") || return 1
 
-	echo "[$unit] New master is up. Gracefully stopping old master..."
-	local old_pid
-	old_pid=$(cat "$old_pid_file" 2>/dev/null)
+	echo "[$unit] New master ($new_pid) is up. Gracefully stopping old master ($old_pid)..."
+	if ! valid_pid "$old_pid" "$cgroup"; then
+		err "[$unit] Old master ($old_pid) is gone before it could be stopped."
+		return 1
+	fi
 	/bin/kill -s QUIT "$old_pid" 2>/dev/null
 
-	wait_for_file absent "$old_pid_file" "$unit - old master stop" || return 1
+	wait_for_file absent "$old_pid_file" "[$unit] old master stop" || return 1
+
+	wait_for_main_pid "$unit" "$new_pid" "[$unit] new master takeover" || return 1
 
 	echo "[$unit] Done."
 	return 0
@@ -54,9 +150,11 @@ upgrade_instance() {
 overall_rc=0
 
 # Discover every active nginx instance via systemctl
-instances=$(systemctl list-units --type=service --state=running --no-legend "nginx*" |
+# Instance names may contain the characters systemd allows in unit names,
+# including "\" from escaping (e.g. nginx@foo\x2dbar.service).
+instances=$(systemctl list-units --type=service --state=running --no-legend --plain "nginx*" |
 	awk '{print $1}' |
-	grep -E '^nginx(@\w+)?\.service$')
+	grep -E '^nginx(@[-[:alnum:]:_.\\]+)?\.service$')
 
 for unit in $instances; do
 	pid_file=$(systemctl show "$unit" -p PIDFile --value)
@@ -73,6 +171,8 @@ done
 
 exit $overall_rc
 
+# Man page source for pod2man (see nginx.spec), never executed.
+# shellcheck disable=SC2317
 : <<'POD'
 =pod
 

diff --git a/nginx.spec b/nginx.spec
index e62bee8..a97fea2 100644
--- a/nginx.spec
+++ b/nginx.spec
@@ -38,7 +38,9 @@
 
 # kTLS requires OpenSSL 3.0 (default in F36+ and EL9+, available in EPEL8)
 %if 0%{?fedora} >= 36 || 0%{?rhel} >= 9 || 0%{?epel} >= 8
-%global with_ktls 1
+%bcond_without ktls
+%else
+%bcond_with ktls
 %endif
 
 # Build against OpenSSL 3 on EL8
@@ -60,7 +62,7 @@
 
 Name:              nginx
 Epoch:             2
-Version:           1.30.7
+Version:           1.30.8
 Release:           %autorelease
 
 Summary:           A high performance web server and reverse proxy server
@@ -357,7 +359,7 @@ if ! ./configure \
     --with-http_xslt_module=dynamic \
     --with-mail=dynamic \
     --with-mail_ssl_module \
-%if 0%{?with_ktls}
+%if %{with ktls}
     --with-openssl-opt=enable-ktls \
 %endif
 %if %{without engine}
@@ -511,7 +513,7 @@ install -m 644 -p %{SOURCE20} %{buildroot}%{_tmpfilesdir}/nginx.conf
 # A reload is not sufficient here: https://blog.nginx.org/blog/nginx-dynamic-modules-how-they-work#upgradeMod
 %transfiletriggerin -- %{_sbindir}/nginx %{nginx_moduleconfdir} %{nginx_moduledir}
 if [ "${1:-0}" -ge 1 ]; then
-    test -f %{_sysconfdir}/nginx/rpm-disable-upgrade || /usr/bin/nginx-upgrade >/dev/null 2>&1 || :
+    test -f %{_sysconfdir}/nginx/rpm-disable-upgrade || /usr/bin/nginx-upgrade >/dev/null || :
 fi
 
 

diff --git a/sources b/sources
index 5680054..a7e6a4a 100644
--- a/sources
+++ b/sources
@@ -1,2 +1,2 @@
-SHA512 (nginx-1.30.7.tar.gz) = c88979d6c4da0942110b2b78a5d1a4c62a3f1d943ec0a430f17df8f5d23c32620af44dc53569aac4f4fdd76a7a019dc97d7f994b87203ec35eafc9af8bc78555
-SHA512 (nginx-1.30.7.tar.gz.asc) = 537b55d5dfa3197d127dbe25866e4ea761ea6fbf715b1c4efbc21522e6e1cd2ecf2896419fbd35a4d15a6653ed7dec434b92a39cff1582b16f69559856a3b948
+SHA512 (nginx-1.30.8.tar.gz) = d5650b0aeb8a9d2d1f5dc3e830a63c51c9777c4aabd22d447bb69fffb6d8cbe2cbbef5b9e4e6650d8ea91601dc394f117bbc05e9eb5f84863a1e9afbf17d4732
+SHA512 (nginx-1.30.8.tar.gz.asc) = e617688b560df14df47514e83f4083454d92e5465f381830a01378bcdb76d94d6080597cbbfd5a06f94d05bfbaf973a0218b800bd72ed4207b892e4ff4542415

             reply	other threads:[~2026-11-26  4:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  4:15 Felix Kaechele [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-11-20 14:31 [rpms/nginx] f44: Merge branch 'rawhide' into f45 Felix Kaechele
2026-10-14 22:54 Felix Kaechele

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179566652493.1.6099366023161021147.rpms-nginx-b1ae56ecdcee@fedoraproject.org \
    --to=felix@kaechele.ca \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox