Merge ~bryce/ubuntu/+source/apache2:sru-lp1832182-graceful-groovy into ubuntu/+source/apache2:ubuntu/devel

Proposed by Bryce Harrington on 2020-10-06
Status: Needs review
Proposed branch: ~bryce/ubuntu/+source/apache2:sru-lp1832182-graceful-groovy
Merge into: ubuntu/+source/apache2:ubuntu/devel
Diff against target: 81 lines (+36/-12)
2 files modified
debian/apache2ctl (+27/-12)
debian/changelog (+9/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  2020-10-06 Needs Fixing on 2020-10-06
Ubuntu Server Developers 2020-10-06 Pending
Canonical Server Team 2020-10-06 Pending
Review via email: mp+391856@code.launchpad.net

Description of the change

Fix for a server-next Apache2 bug. The objective is to SRU this to all past LTS releases, so please review with that intent in mind.

The bug description for LP: #1832182 is prepped for the SRU, so I likewise would appreciate a detailed review of that text.

PPA: https://launchpad.net/~bryce/+archive/ubuntu/apache2-sru-lp1832182/

To post a comment you must log in.
Christian Ehrhardt  (paelzer) wrote :

SRU Template - LGTM
Changelog - LGTM

Actual change:
- ack to move the systemd check to a function

I needed some time for "APACHE_STARTED_BY_SYSTEMD".
That is set in the environment by the .service files.
So I assume if APACHE_STARTED_BY_SYSTEMD isn't set we probe (the new function).
But if it is set, then we exit 1 which means "no need for systemd"

is that
a) to unbreak loops where we start this from systemd, starting systemd, starting systemd, ...
   Then it makes sense but I wanted to ask ito be sure
b) wrong and should actually "exit 0" if APACHE_STARTED_BY_SYSTEMD is set?

Further in the change there is some whitespace damage with the "exit" calls not using spaces but tabs.

If you could fix the latter and explain the former then this should be fine to go.

review: Needs Fixing
Christian Ehrhardt  (paelzer) wrote :

Any updates on that ? it clutters my "active reviews" page :-P

Bryce Harrington (bryce) wrote :

Sorry, yeah I realized from your review that my original implementation was totally borked so have recoded it entirely. I noticed another corner case where the service state could get forgotten, so thought I should do some broader testing before reproposing the MP. Unfortunately, the past couple weeks were heavily side-tracked with other higher urgencies, but this (and php-parser) are back at the top of the stack so hope to have the MP up tomorrow or Monday.

Unmerged commits

3b72a92... by Bryce Harrington on 2020-10-05

changelog

523b007... by Bryce Harrington on 2020-10-05

  * d/apache2ctl: Also use systemd for graceful if it is in use. This
    extends an earlier fix for the start command to behave similarly for
    restart / graceful. Fixes service failures on unattended upgrade.
    (LP: #1832182)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/apache2ctl b/debian/apache2ctl
2index 404b9f9..17a9582 100755
3--- a/debian/apache2ctl
4+++ b/debian/apache2ctl
5@@ -143,6 +143,21 @@ mkdir_chown () {
6 fi
7 }
8
9+need_systemd () {
10+ # Detect if systemd is in use and should be used for managing
11+ # the Apache2 httpd service.
12+ if [ -z "$APACHE_STARTED_BY_SYSTEMD" ] ; then
13+ case "$(readlink -f /proc/1/exe)" in
14+ *systemd*)
15+ exit 0
16+ ;;
17+ *)
18+ exit 1
19+ ;;
20+ esac
21+ fi
22+ exit 1
23+}
24
25 [ ! -d ${APACHE_RUN_DIR:-/var/run/apache2} ] && mkdir -p ${APACHE_RUN_DIR:-/var/run/apache2}
26 [ ! -d ${APACHE_LOCK_DIR:-/var/lock/apache2} ] && mkdir_chown ${APACHE_RUN_USER:-www-data} ${APACHE_LOCK_DIR:-/var/lock/apache2}
27@@ -153,17 +168,7 @@ start)
28 # (this is bad if there are several apache2 instances running)
29 rm -f ${APACHE_RUN_DIR:-/var/run/apache2}/*ssl_scache*
30
31- need_systemd=false
32- if [ -z "$APACHE_STARTED_BY_SYSTEMD" ] ; then
33- case "$(readlink -f /proc/1/exe)" in
34- *systemd*)
35- need_systemd=true
36- ;;
37- *)
38- ;;
39- esac
40- fi
41- if $need_systemd ; then
42+ if $(need_systemd); then
43 # If running on systemd we should not start httpd without systemd
44 # or systemd will get confused about the status of httpd.
45 echo "Invoking 'systemctl start $APACHE_SYSTEMD_SERVICE'."
46@@ -182,7 +187,17 @@ stop|graceful-stop)
47 ;;
48 restart|graceful)
49 if $HTTPD ${APACHE_ARGUMENTS} -t 2> /dev/null ; then
50- $HTTPD ${APACHE_ARGUMENTS} -k "$ARGV"
51+ if $(need_systemd); then
52+ # If running on systemd we should not directly restart httpd since
53+ # systemd would be confused about httpd's status.
54+ # (See LP: #1832182)
55+ echo "Invoking 'systemctl reload $APACHE_SYSTEMD_SERVICE'."
56+ echo "Use 'systemctl status $APACHE_SYSTEMD_SERVICE' for more info."
57+ systemctl reload "$APACHE_SYSTEMD_SERVICE"
58+ else
59+ unset APACHE_STARTED_BY_SYSTEMD
60+ $HTTPD ${APACHE_ARGUMENTS} -k "$ARGV"
61+ fi
62 else
63 $HTTPD ${APACHE_ARGUMENTS} -t
64 fi
65diff --git a/debian/changelog b/debian/changelog
66index 6295e4e..d9354dc 100644
67--- a/debian/changelog
68+++ b/debian/changelog
69@@ -1,3 +1,12 @@
70+apache2 (2.4.46-1ubuntu2) groovy; urgency=medium
71+
72+ * d/apache2ctl: Also use systemd for graceful if it is in use. This
73+ extends an earlier fix for the start command to behave similarly for
74+ restart / graceful. Fixes service failures on unattended upgrade.
75+ (LP: #1832182)
76+
77+ -- Bryce Harrington <bryce@canonical.com> Mon, 05 Oct 2020 16:06:32 -0700
78+
79 apache2 (2.4.46-1ubuntu1) groovy; urgency=medium
80
81 * Merge with Debian unstable. Remaining changes:

Subscribers

People subscribed via source and target branches