Closed smlx closed 4 months ago
This also happens locally (with pygmy) when running docker-compose down
, the cli always takes the longest to quit. I never considered it to be an image issue, so it would be great to fix it.
Stop building Lagoon php-8.x-cli images on upstream php-fpm, and instead build them on upstream php-cli which uses the default STOPSIGNAL SIGTERM.
What would be the advantage of that? The docs make it sound like there's nothing special that isn't included in the php-fpm
image, and the php-fpm
includes everything that php-cli
does. Wouldn't we just be copy/pasting most of what's in our fpm Dockerfile anyway?
Add STOPSIGNAL SIGTERM to Lagoon's php-8.x-cli Dockerfiles.
That sounds like the easiest and best choice to me.
Lagoon
php-8.x-cli
images currently do not shut down gracefully in Kubernetes. Instead on deletion they ignore the graceful stop signal and are forcefully killed after 30 seconds. This means that it takes far longer than necessary to delete a cli pod, which has several impacts such as increasing Lagoon build rollout time.The graceful shutdown signal is ignored because the Lagoon
php-8.x-cli
images are built on top of the upstreamphp-fpm
image (via Lagoon'sphp-8.x-fpm
). PHP's FPM usesSIGQUIT
as a special signal to mean "graceful shutdown", so the upstreamphp-fpm
image is configured withSTOPSIGNAL SIGQUIT
. Container runtimes generally respect theSTOPSIGNAL
metadata, so Kubernetes usesSIGQUIT
too. Since we build the Lagoonphp-8.x-cli
on Lagoon'sphp-8.x-fpm
, which is built on upstreamphp-fpm
, the Lagoonphp-8.x-cli
image inheritsSTOPSIGNAL SIGQUIT
. Unfortunately thedocker-sleep
script used in the CLI pod ignores the non-standardSIGQUIT
.You can see the scenario described above in the image metadata. Note that upstream
php-cli
doesn't specify aSTOPSIGNAL
, so falls back to the defaultSIGTERM
:From what I can see there are a couple of options to fix this:
php-8.x-cli
images on upstreamphp-fpm
, and instead build them on upstreamphp-cli
which uses the defaultSTOPSIGNAL SIGTERM
.STOPSIGNAL SIGTERM
to Lagoon'sphp-8.x-cli
Dockerfiles.Here's the ~98% pod termination speedup observed when adding
STOPSIGNAL SIGTERM
to a Lagoonphp-8.x-cli
image (option 2):