Skip to content

Use candlepin.service in foreman startup ordering#413

Merged
evgeni merged 1 commit intotheforeman:masterfrom
pablomh:candlepin_dependency
Mar 20, 2026
Merged

Use candlepin.service in foreman startup ordering#413
evgeni merged 1 commit intotheforeman:masterfrom
pablomh:candlepin_dependency

Conversation

@pablomh
Copy link
Copy Markdown
Contributor

@pablomh pablomh commented Mar 19, 2026

foreman.service currently declares After=redis.service postgresql.service, starting it at the same time as candlepin.service. Under load — particularly on systemctl restart foreman.target — all containers race for CPU and disk I/O simultaneously, pushing Rails gem loading past the default TimeoutStartSec (90 s) and causing intermittent failures.

The fix replaces the explicit redis and postgresql dependencies with candlepin, since candlepin.service already declares:

After=redis.service postgresql.service

This gives the transitive ordering:

postgresql --+
             +--> candlepin --> foreman
redis -------+

Foreman now starts after Candlepin has finished its JVM initialisation. By that point the I/O storm from parallel container startups has settled and Rails loads in ~35 s instead of 75–90 s, comfortably within the timeout regardless of system load.

Testing:

Verified with 7 consecutive CI runs across all certificate modes, external DB, fapolicyd, stream9, stream10, and upgrade scenarios.

Comment on lines +129 to +130
Wants=candlepin.service
After=foreman.target candlepin.service
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break in setups that don't have candlepin.
Won't this work too?

Suggested change
Wants=candlepin.service
After=foreman.target candlepin.service
Wants=redis.service postgresql.service candlepin.service
After=foreman.target redis.service postgresql.service candlepin.service

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that we could skip candlepin... Yes, that would work too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't today in foremanctl, but long term we will offer non-Katello deploys which don't need Candlepin.

@evgeni
Copy link
Copy Markdown
Member

evgeni commented Mar 19, 2026

Can you include this in #409 to see if things actually pass then?

@pablomh
Copy link
Copy Markdown
Contributor Author

pablomh commented Mar 19, 2026

Added.

@pablomh pablomh marked this pull request as draft March 19, 2026 15:11
Foreman depends on Candlepin being fully initialised before it can
serve requests reliably. Without this ordering, foreman.service starts
simultaneously with candlepin.service, competing for CPU and disk I/O
during the JVM startup. This pushes Rails loading time close to the
default TimeoutStartSec (90s) and causes intermittent failures on
restart, particularly when the system is under load.

Because candlepin.service already declares:
  After=redis.service postgresql.service

the transitive ordering becomes:

  postgresql --+
               +--> candlepin --> foreman
  redis -------+

redis.service and postgresql.service are kept as explicit dependencies
to preserve correct ordering in future non-Katello deployments that
may not include candlepin.service.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pablomh pablomh force-pushed the candlepin_dependency branch from 4026154 to 3874dee Compare March 19, 2026 15:11
@pablomh pablomh marked this pull request as ready for review March 19, 2026 16:09
@pablomh
Copy link
Copy Markdown
Contributor Author

pablomh commented Mar 19, 2026

Do you want me to drop this in favor of #409?

@evgeni evgeni merged commit f2e162d into theforeman:master Mar 20, 2026
11 checks passed
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.

2 participants