Avoid redundant foreman restart on re-deploy - #793
Open
ehelms wants to merge 1 commit into
Open
Conversation
Refs theforeman#769 Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are you introducing these changes? (Problem description, related links)
Refs #769
On re-deploy, the "Restart foreman" step took ~120s (vs ~26s on a fresh
deploy and ~26s for a manual
systemctl restart foreman).Root cause: foreman was restarted twice, ~0.6s apart. The unconditional
state: restartedonforeman-db-migrate(the "Migrate and seed" task)propagated a restart down to
foreman.serviceviaRequires=, startingforeman (attempt #1). The
Restart foremanhandler then restarted it again(attempt #2), sending SIGTERM to the still-booting attempt #1. Because Puma
runs as container PID 1 and has not yet installed its signal traps that early
in boot, the SIGTERM is ignored until
TimeoutStopSec(default 90s) kills thecontainer — adding ~90s to every re-deploy. The same propagation redundantly
bounced the dynflow-sidekiq instances, and also caused foreman downtime on
otherwise no-change deploys (issue #769).
What are the changes introduced in this pull request?
Requires=foreman-db-migrate.servicetoWants=on the foreman anddynflow-sidekiq quadlets, so restarting
foreman-db-migrateno longerpropagates an extra restart onto foreman/dynflow.
After=foreman-db-migrate.serviceis kept, so migrations still run beforeforeman on boot. Migration failure is still caught by the explicit "Migrate
and seed" task, which fails the play before foreman is restarted. The
Restart foremanhandler is now the single, deterministic restart.Measured impact
Restart foremantask timing on re-deploy:27s now matches a fresh deploy (26.80s) and a manual
systemctl restart foreman(~26s), i.e. all artificial delay is gone and onlyForeman's real boot time remains. End-to-end this cuts ~94s off the re-deploy
(~380s → 286s, ~25% faster).
How to test this pull request
Steps to reproduce:
./foremanctl deploy --foreman-initial-admin-password=changeme --tuning developmentafter, it should be ~27s (a single clean restart).
systemctl status foremanandcurl -k https://localhost/api/v2/ping.state 'stop-sigterm' timed out. Killing.entries appear forforeman.serviceinjournalctl -u foreman.serviceduring the re-deploy.Checklist