Skip to content

Remove After=foreman.target to fix systemd ordering cycles#432

Closed
pablomh wants to merge 1 commit intotheforeman:masterfrom
pablomh:fix/systemd-ordering-cycles
Closed

Remove After=foreman.target to fix systemd ordering cycles#432
pablomh wants to merge 1 commit intotheforeman:masterfrom
pablomh:fix/systemd-ordering-cycles

Conversation

@pablomh
Copy link
Copy Markdown
Contributor

@pablomh pablomh commented Mar 30, 2026

Summary

  • Removes After=foreman.target dependencies that were causing systemd ordering cycles during service startup

Test plan

  • Deploy foremanctl and verify services start without systemd ordering cycle warnings
  • Check systemctl status for all affected services (candlepin, foreman, foreman_proxy, postgresql, pulp, redis)
  • Verify no regression in service startup order

🤖 Generated with Claude Code

After=foreman.target was added in 805217d to ensure systemctl stop
foreman.target blocks until all constituent services fully stop, preventing
a rapid stop+start race. However, every service is also WantedBy=foreman.target,
making After=foreman.target inherently circular: foreman.target cannot finish
starting until its Wants are satisfied, but those services cannot start until
foreman.target has started.

This caused both start and stop ordering cycles, which systemd resolved by
dropping jobs — leading to unclean postgresql shutdowns, stale postmaster.pid
files, and the very race condition the original fix was trying to prevent.

Remove After=foreman.target from all services. Stop ordering is preserved
through inter-service After= relationships: all application services are
After=redis.service postgresql.service (reversed: redis/postgresql stop after
all application services). PartOf=foreman.target ensures services stop when
foreman.target stops, and systemctl stop foreman.target waits for the full
PartOf-propagated transaction to complete.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant