Skip to content

[Feat] Resume Site Creation#1092

Open
RichardAnderson wants to merge 8 commits into
vitodeploy:4.xfrom
RichardAnderson:feat/resume-site-creation
Open

[Feat] Resume Site Creation#1092
RichardAnderson wants to merge 8 commits into
vitodeploy:4.xfrom
RichardAnderson:feat/resume-site-creation

Conversation

@RichardAnderson
Copy link
Copy Markdown
Member

@RichardAnderson RichardAnderson commented May 16, 2026

This pull request introduces a robust retry mechanism for site installations, improves error handling and reporting for installation failures, and refines the behavior of several background jobs. It also enhances the tracking of installation progress and error details on the Site model, and adds various safety checks to the site setup process.

Site Failed Banner
CleanShot 2026-05-17 at 10 03 38

Retry Mechanism & API Enhancements:

  • Introduced a new RetrySite action, allowing sites in an installation_failed state to be retried. This is exposed via new API and web routes, with appropriate authorization and validation.

Error Handling & Progress Tracking:

  • Enhanced the Site model and resource to include progress_step and last_error fields, enabling more detailed progress tracking and user-friendly error summaries. These fields are set and updated throughout the installation process and surfaced in API responses.
  • Improved error handling in CreateJob by setting a UI-safe error summary on failure, avoiding leaking sensitive or verbose exception messages, and resetting progress fields on success.

Job Dispatching Consistency:

  • Standardized job queue assignment by moving onQueue('ssh') from dispatch calls to the constructors of CreateJob, DeployJob, ExecuteCommandJob, and RollbackJob, simplifying job dispatching throughout the codebase.

Site Installation Safety & Idempotency:

  • Refactored AbstractSiteType to add idempotent checks for user creation, repository cloning, and FPM pool setup, reducing the risk of errors on retries or partial installations. Added helper methods to check for existing users, cloned repositories, and FPM pools.

These changes collectively improve the reliability and user experience of site installations, especially in failure and retry scenarios.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a "resume / retry" capability for failed site installations. Sites can now be retried (web + API), the install pipeline records a named progress step and a UI-safe last_error, and the install steps (user creation, repo clone, FPM pool) are made idempotent so retries skip already-completed work. Job onQueue('ssh') calls are moved into the constructors of CreateJob, DeployJob, ExecuteCommandJob, and RollbackJob.

Changes:

  • New RetrySite action plus web/API routes, OpenAPI docs, banner UI with confirmation dialog, and a feature test.
  • Site gains progress_step and last_error columns; AbstractSiteType::progress() accepts a step label; CreateJob records a sanitized error summary on failure and resets fields on success.
  • AbstractSiteType gets userExists / repositoryAlreadyCloned / fpmPoolExists guards (with new Blade probe scripts); nginx/caddy vhost symlinks switch to ln -sfn and create-path drops rm -rf for mkdir -p.

Reviewed changes

Copilot reviewed 36 out of 37 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
app/Actions/Site/RetrySite.php New action validating state and dispatching CreateJob.
app/Actions/Site/{CreateSite,Deploy,ExecuteCommand,Rollback}.php Drop ->onQueue('ssh') (now in job constructors).
app/Http/Controllers/SiteController.php Adds web sites.retry route.
app/Http/Controllers/API/SiteController.php Adds API retry endpoint.
app/Http/Resources/SiteResource.php Exposes progress_step and last_error.
app/Jobs/Site/CreateJob.php Sets queue in constructor, resets/sets progress fields, adds safeErrorSummary.
app/Jobs/Site/{DeployJob,ExecuteCommandJob,RollbackJob}.php Set queue in constructor.
app/Models/Site.php New progress_step / last_error properties + fillable.
app/SiteTypes/AbstractSiteType.php New idempotency helpers and progress($percent, $step) signature.
app/SiteTypes/{Wordpress,PHPSite,PHPMyAdmin,PHPBlank,NodeJS,MiseNodeJS,MiseBun,LoadBalancer}.php Adopt step labels and cloneRepository().
database/migrations/2026_05_16_155350_add_progress_step_and_last_error_to_sites_table.php Schema migration for new columns.
public/api-docs/openapi/{sites.yaml,schemas/Site.yaml} Documents retry endpoint and new fields.
resources/js/components/site-banners.tsx Adds failed-install banner with retry dialog.
resources/js/pages/servers/components/header.tsx Shows current install step inline and in tooltip.
resources/js/lib/utils.ts New humanizeStep helper.
resources/js/types/site.d.ts Adds typing for new fields.
resources/views/ssh/services/webserver/{nginx,caddy}/create-vhost.blade.php Use ln -sfn with escapeshellarg.
resources/views/ssh/services/webserver/{nginx,caddy}/create-path.blade.php Replace rm -rf + mkdir with mkdir -p.
resources/views/ssh/site/check-*.blade.php New SSH probes for user / repo / FPM pool.
tests/Feature/RetrySiteTest.php Coverage for retry flow, validation, and failure handling.

Comment thread resources/views/ssh/services/webserver/nginx/create-path.blade.php
Comment thread resources/views/ssh/services/webserver/caddy/create-path.blade.php
Comment thread app/SiteTypes/AbstractSiteType.php Outdated
Comment thread app/SiteTypes/AbstractSiteType.php Outdated
Comment thread app/SiteTypes/MiseNodeJS.php Outdated
Comment thread app/Jobs/Site/CreateJob.php
Comment thread resources/js/pages/servers/components/header.tsx
Comment thread resources/js/components/site-banners.tsx Outdated
Comment thread resources/views/ssh/services/webserver/nginx/create-vhost.blade.php Outdated
Comment thread public/api-docs/openapi/sites.yaml
@RichardAnderson
Copy link
Copy Markdown
Member Author

Still draft, needs more testing

@RichardAnderson RichardAnderson marked this pull request as ready for review May 17, 2026 09:23
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