feat(applications): add configurable restart loop limit#9231
feat(applications): add configurable restart loop limit#9231ShadowArcanist wants to merge 2 commits intocoollabsio:nextfrom
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis PR introduces a maximum restart count feature for applications. A new database column I'll be back—to make sure your self-hosted applications don't restart themselves into a gluten-free taco dust storm. 🌮 ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/Notifications/Application/RestartLimitReached.php`:
- Line 43: Replace the manual URL assembly in RestartLimitReached (the
assignment to $this->resource_url) with a call to the Application model's link()
method (use $this->resource->link()) and fall back to the current base_url()
construction if link() returns null; specifically update the assignment in
RestartLimitReached.php to prefer $this->resource->link() and only build
base_url()."/project/{$this->project_uuid}/environment/{$this->environment_uuid}/application/{$this->resource->uuid}"
(or use {$this->environment_name} if your fallback should mirror the example)
when link() is null so route changes are centralized in Application::link().
In
`@database/migrations/2026_03_27_000000_add_max_restart_count_to_applications_and_databases.php`:
- Around line 1-22: The migration filename indicates it should modify both
applications and databases but the migration class only alters the applications
table (methods up()/down() add/drop max_restart_count on 'applications'); either
rename the file to match its actual behavior (e.g., remove "_and_databases" so
it becomes add_max_restart_count_to_applications) or update the migration logic
to also add and drop the max_restart_count integer column (default 10, after
'restart_count') on the 'databases' table in both up() and down() so the
filename accurately reflects the changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f8400913-9e85-4a2f-a72a-a5df8ed4e56a
📒 Files selected for processing (7)
app/Actions/Docker/GetContainersStatus.phpapp/Livewire/Project/Application/Advanced.phpapp/Models/Application.phpapp/Notifications/Application/RestartLimitReached.phpdatabase/migrations/2026_03_27_000000_add_max_restart_count_to_applications_and_databases.phpresources/views/emails/application-restart-limit-reached.blade.phpresources/views/livewire/project/application/advanced.blade.php
| if (str($this->fqdn)->explode(',')->count() > 1) { | ||
| $this->fqdn = str($this->fqdn)->explode(',')->first(); | ||
| } | ||
| $this->resource_url = base_url()."/project/{$this->project_uuid}/environment/{$this->environment_uuid}/application/{$this->resource->uuid}"; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
I'll be back... with a refactoring suggestion for URL construction.
The URL is manually constructed here, but the Application model already has a link() method (line 452-463 in Application.php) that uses Laravel's named routes. Using the existing method would be more maintainable and DRY:
- $this->resource_url = base_url()."/project/{$this->project_uuid}/environment/{$this->environment_uuid}/application/{$this->resource->uuid}";
+ $this->resource_url = $this->resource->link();If the link() method can return null, you'd need a fallback:
$this->resource_url = $this->resource->link() ?? base_url()."/project/{$this->project_uuid}/{$this->environment_name}/application/{$this->resource->uuid}";This way, if routes ever change, you only need to update one place. Like a good self-hosted infrastructure - single source of truth!
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@app/Notifications/Application/RestartLimitReached.php` at line 43, Replace
the manual URL assembly in RestartLimitReached (the assignment to
$this->resource_url) with a call to the Application model's link() method (use
$this->resource->link()) and fall back to the current base_url() construction if
link() returns null; specifically update the assignment in
RestartLimitReached.php to prefer $this->resource->link() and only build
base_url()."/project/{$this->project_uuid}/environment/{$this->environment_uuid}/application/{$this->resource->uuid}"
(or use {$this->environment_name} if your fallback should mirror the example)
when link() is null so route changes are centralized in Application::link().
Changes
Note
Issues
Category
Preview
UI
Notification:
AI Assistance
If AI was used:
Testing
Deployed crash loop example application and set the restart limit to 2, Coolify automatically stopped the application after it restarted 2 times. Also tested setting higher restart limit and it worked. Also tested restarting and redeploying the application to see if it triggers this restart limit feature and it didn't triggered it.
Contributor Agreement
Important