Skip to content

fix(applications): exclude health-check-excluded containers from restart limit - #11032

Open
nikrabaev wants to merge 2 commits into
coollabsio:nextfrom
nikrabaev:fix/exclude-containers-from-restart-limit
Open

fix(applications): exclude health-check-excluded containers from restart limit#11032
nikrabaev wants to merge 2 commits into
coollabsio:nextfrom
nikrabaev:fix/exclude-containers-from-restart-limit

Conversation

@nikrabaev

Copy link
Copy Markdown

Changes

The crash restart-limit feature (default 10) counted Docker's lifetime RestartCount across every container of an application — including containers that are excluded from health checks via exclude_from_hc or restart: no. Status aggregation already skips those containers, so the two code paths disagreed.

Because of this, a scheduled or one-shot sidecar that legitimately starts and stops (an Ofelia scheduler, or any restart:no cron/job container) inflated the count, hit the limit, and Coolify stopped the whole application with a "10x restarts" warning.

This change excludes the same health-check-excluded containers from the restart-count calculation, so restart counting matches status aggregation:

  • A one-shot job with restart:no is excluded automatically.
  • A long-running scheduler sidecar can be opted out by adding exclude_from_hc.
  • Genuine single-container crash loops are unaffected and still stop at the limit.

No configuration, schema, UI, or default-behaviour changes.

Issues

Category

  • Bug fix
  • Improvement
  • New feature
  • Adding new one click service
  • Fixing or updating existing one click service

AI Assistance

  • AI was NOT used to create this PR
  • AI was used (please describe below)

If AI was used:

  • Tools used: Claude Code, human reviewed.
  • How extensively: root-cause analysis, the fix, and the added unit tests.

Testing

Added tests/Unit/RestartLimitExcludesExcludedContainersTest.php covering: excluded containers dropped from the max restart count, non-excluded crash loops still counted, legacy behaviour when nothing is excluded, and restart:no / exclude_from_hc resolved through the real trait helper. Ran the new suite plus the existing RestartCountTrackingTest — 10 passed. Pint clean on the changed files.

Contributor Agreement

Important

  • I have read and understood the contributor guidelines. If I have failed to follow any guideline, I understand that this PR may be closed without review.
  • I have searched existing issues and pull requests (including closed ones) to ensure this isn't a duplicate.
  • I have tested all the changes thoroughly with a local development instance of Coolify and I am confident that they will work as expected when a maintainer tests them.

@nikrabaev
nikrabaev force-pushed the fix/exclude-containers-from-restart-limit branch 2 times, most recently from 71be0a7 to d67d057 Compare July 24, 2026 13:23
nikrabaev and others added 2 commits July 24, 2026 16:28
…art limit

The crash restart limit counted Docker RestartCount across all app
containers, including ones excluded from health checks (exclude_from_hc
or restart: no). Scheduled or one-shot sidecars like Ofelia jobs thus
tripped the limit and stopped the whole app. Exclude them from the
count too, matching status aggregation.

Fixes coollabsio#10624

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a DB-backed test driving GetContainersStatus::handle() with synthetic
docker-inspect payloads: an excluded (restart:no / exclude_from_hc) container
with a high RestartCount does not trip the limit, while a monitored container
does and dispatches StopApplication.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nikrabaev
nikrabaev force-pushed the fix/exclude-containers-from-restart-limit branch from d67d057 to 446508e Compare July 24, 2026 13:28
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