Skip to content

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

Open
pablomh wants to merge 1 commit into
masterfrom
fix/systemd-ordering-cycles
Open

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

Conversation

@pablomh

@pablomh pablomh commented Mar 30, 2026

Copy link
Copy Markdown
Owner

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>
@pablomh
pablomh force-pushed the fix/systemd-ordering-cycles branch from 4dc982e to c4c89ff Compare March 30, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant