Comment 16 for bug 1832182

Revision history for this message
RedScourge (redscourge) wrote : Re: [Bug 1832182] Please test proposed package

Cool, glad to hear that an issue I uncovered has been fixed...a little
confused as to why an official fix took 18 months to deploy though,
considering it took me about 18 minutes.

On Fri, Nov 27, 2020 at 8:42 AM Timo Aaltonen <email address hidden>
wrote:

> Hello RedScourge, or anyone else affected,
>
> Accepted apache2 into focal-proposed. The package will build now and be
> available at
> https://launchpad.net/ubuntu/+source/apache2/2.4.41-4ubuntu3.2 in a few
> hours, and then in the -proposed repository.
>
> Please help us by testing this new package. See
> https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how
> to enable and use -proposed. Your feedback will aid us getting this
> update out to other Ubuntu users.
>
> If this package fixes the bug for you, please add a comment to this bug,
> mentioning the version of the package you tested, what testing has been
> performed on the package and change the tag from verification-needed-
> focal to verification-done-focal. If it does not fix the bug for you,
> please add a comment stating that, and change the tag to verification-
> failed-focal. In either case, without details of your testing we will
> not be able to proceed.
>
> Further information regarding the verification process can be found at
> https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in
> advance for helping!
>
> N.B. The updated package will be released to -updates after the bug(s)
> fixed by this package have been verified and the package has been in
> -proposed for a minimum of 7 days.
>
> ** Tags added: verification-needed-bionic
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1832182
>
> Title:
> systemd unable to detect running apache if invoked via "apache2ctl
> graceful"
>
> Status in apache2 package in Ubuntu:
> Fix Committed
> Status in apache2 source package in Xenial:
> Fix Committed
> Status in apache2 source package in Bionic:
> Fix Committed
> Status in apache2 source package in Focal:
> Fix Committed
> Status in apache2 source package in Groovy:
> Fix Committed
> Status in apache2 source package in Hirsute:
> Fix Committed
> Status in apache2 package in Debian:
> New
>
> Bug description:
> [Impact]
>
> Unattended upgrade will attempt to gracefully reload the Apache2 httpd
> service, but it reloads apache directly, not via systemd, so systemctl
> will mis-report the true status. This can cause unexpected and
> unnecessary server outages when e.g. upgrading from one LTS to
> another.
>
>
> [Test Case]
>
> root@server:/usr/local/sbin# apache2ctl stop
> root@server:/usr/local/sbin# apache2ctl graceful
> httpd not running, trying to start
> root@server:/usr/local/sbin# systemctl status apache2.service
> ? apache2.service - The Apache HTTP Server
> Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor
> preset: enabled)
> Drop-In: /lib/systemd/system/apache2.service.d
> +-apache2-systemd.conf
> Active: inactive (dead) since Mon 2019-06-10 01:04:13 MDT; 17s ago
> Process: 27370 ExecStop=/usr/sbin/apachectl stop (code=exited,
> status=0/SUCCESS)
> Process: 11462 ExecReload=/usr/sbin/apachectl graceful (code=exited,
> status=0/SUCCESS)
> Main PID: 1849 (code=exited, status=0/SUCCESS)
>
> Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot
> [/srv/apache2/www/...
> Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot
> [/srv/apache2/www/...
> Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot
> [/srv/apache2/www/...
> Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot
> [/srv/apache2/www/...
> Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot
> [/srv/apache2/www/...
> Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot
> [/srv/apache2/www/...
> Jun 08 19:11:24 server systemd[1]: Started The Apache HTTP Server.
> Jun 09 06:25:04 server systemd[1]: Reloading The Apache HTTP Server.
> Jun 09 06:25:04 server systemd[1]: Reloaded The Apache HTTP Server.
> Jun 10 01:04:13 server apachectl[27370]: httpd (no pid file) not running
>
> Output after customizing the apache2ctl script and restarting it:
>
> root@server:/usr/local/sbin# apache2ctl_custom graceful
> Invoking 'systemctl start apache2'.
> Use 'systemctl status apache2' for more info.
> root@server:/usr/local/sbin# systemctl status apache2.service
> ? apache2.service - The Apache HTTP Server
> Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor
> preset: enabled)
> Drop-In: /lib/systemd/system/apache2.service.d
> +-apache2-systemd.conf
> Active: active (running) since Mon 2019-06-10 01:04:50 MDT; 4s ago
> Process: 27370 ExecStop=/usr/sbin/apachectl stop (code=exited,
> status=0/SUCCESS)
> Process: 11462 ExecReload=/usr/sbin/apachectl graceful (code=exited,
> status=0/SUCCESS)
> Process: 27432 ExecStart=/usr/sbin/apachectl start (code=exited,
> status=0/SUCCESS)
> Main PID: 27444 (apache2)
> Tasks: 6 (limit: 2318)
> CGroup: /system.slice/apache2.service
> +-27444 /usr/sbin/apache2 -k start
> +-27448 /usr/sbin/apache2 -k start
> +-27449 /usr/sbin/apache2 -k start
> +-27451 /usr/sbin/apache2 -k start
> +-27454 /usr/sbin/apache2 -k start
> +-27455 /usr/sbin/apache2 -k start
>
> Jun 10 01:04:50 server systemd[1]: Starting The Apache HTTP Server...
> Jun 10 01:04:50 server systemd[1]: Started The Apache HTTP Server.
>
> [Fix]
>
> The fix is made somewhat obvious due to the fact that the issue was
> fixed for "apache2ctl start" in 18.04 LTS by replacing the regular
> call (which resolves to "/usr/sbin/apache2 -k start") with a check for
> presence of systemd, followed by an invocation of "systemctl start
> apache2.service" if that check is affirmative, or falling back to the
> old start command if that check is negative.
>
> Attached to this bug report is a diff of the file before and after I
> copied the fixed invocation from the "start" subsection to the
> "graceful" subsection in 18.04 LTS. A fix for 16.04 LTS would require
> copying that block both into the "start" and "graceful" subsections.
>
>
> [Regression Potential]
>
> This alters the behavior of Debian's apache2ctl script for managing
> the service state. No other Apache2 code is modified. Thus things to
> watch for new regressions would deal with the apache service's state
> itself, not crashes or behavioral changes.
>
> With a manual sysadmin-supervised service restart, if there are
> problems the sysadmin can intervene. The real risk of regression here
> would be for unsupervised or automated service updates.
>
>
> [Original Report]
>
> When starting or restarting Apache via the /usr/sbin/apache2ctl
> script, systemd becomes unaware of the state of Apache, causing
> "systemctl status apache2.service" to report "Active: inactive
> (dead)". Below I describe the issue and a fix; attached is the output
> of the diff command after I fixed it on my own 18.04 LTS system.
>
> Despite this issue, Apache itself generally runs fine, so this is not
> an absolutely critical issue, however as both "systemctl status
> apache2.service" and "service apache2 status" become unable to detect
> its running state, and as some people may be scripting Apache service
> checks using those commands, they may experience server outages when
> they migrate from 14.04 LTS to 16.04 LTS or 18.04 LTS, so this could
> potentially have serious consequences. I suspect this caused or at
> least contributed to at least one outage of a web server I am
> responsible for, as the web file backup script was unable to restart
> the apache process after stopping it.
>
> This issue affects Ubuntu 16.04 LTS when using "apache2ctl start" or
> "apache2ctl graceful", and Ubuntu 18.04 LTS just when using
> "apache2ctl graceful".
>
>
> [Additional information]
>
> lsb_release -rd :
>
> Description: Ubuntu 18.04.2 LTS
> Release: 18.04
>
> apt-cache policy apache2:
>
> apache2:
> Installed: 2.4.29-1ubuntu4.6
> Candidate: 2.4.29-1ubuntu4.6
>
> To manage notifications about this bug go to:
>
> https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1832182/+subscriptions
>