3.3 KiB
3.3 KiB
id, title, status, assignee, created_date, updated_date, labels, dependencies, priority
id | title | status | assignee | created_date | updated_date | labels | dependencies | priority | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
task-00002 | Fix Docker cleanup irregular scheduling in cloud environment | Done |
|
2025-08-26 12:17 | 2025-08-26 12:26 |
|
high |
Description
Docker cleanup jobs are running at irregular intervals instead of hourly as configured (0 * * * *) in the cloud environment with 2 Horizon workers and thousands of servers. The issue stems from the ServerManagerJob processing servers sequentially with a frozen execution time, causing timing mismatches when evaluating cron expressions for large server counts.
Acceptance Criteria
- #1 Docker cleanup runs consistently at the configured hourly intervals
- #2 All eligible servers receive cleanup jobs when due
- #3 Solution handles thousands of servers efficiently
- #4 Maintains backwards compatibility with existing settings
- #5 Cloud subscription checks are properly enforced
Implementation Plan
-
Add processDockerCleanups() method to ScheduledJobManager
- Implement method to fetch all eligible servers
- Apply frozen execution time for consistent cron evaluation
- Check server functionality and cloud subscription status
- Dispatch DockerCleanupJob for servers where cleanup is due
-
Implement helper methods in ScheduledJobManager
- getServersForCleanup(): Fetch servers with proper cloud/self-hosted filtering
- shouldProcessDockerCleanup(): Validate server eligibility
- Reuse existing shouldRunNow() method with frozen execution time
-
Remove Docker cleanup logic from ServerManagerJob
- Delete lines 136-150 that handle Docker cleanup scheduling
- Keep other server management tasks intact
-
Test the implementation
- Verify hourly execution with test servers
- Check timezone handling
- Validate cloud subscription filtering
- Monitor for duplicate job prevention via WithoutOverlapping middleware
-
Deploy strategy
- First deploy updated ScheduledJobManager
- Monitor logs for successful hourly executions
- Once confirmed, remove cleanup from ServerManagerJob
- No database migrations required
Implementation Notes
Successfully migrated Docker cleanup scheduling from ServerManagerJob to ScheduledJobManager.
Changes Made:
- Added processDockerCleanups() method to ScheduledJobManager that processes all servers with a single frozen execution time
- Implemented getServersForCleanup() to fetch servers with proper cloud/self-hosted filtering
- Implemented shouldProcessDockerCleanup() for server eligibility validation
- Removed Docker cleanup logic from ServerManagerJob (lines 136-150)
Key Improvements:
- All servers now evaluated against the same timestamp, ensuring consistent hourly execution
- Proper cloud subscription checks maintained
- Backwards compatible - no database migrations or settings changes required
- Follows the same proven pattern used for database backups
Files Modified:
- app/Jobs/ScheduledJobManager.php: Added Docker cleanup processing
- app/Jobs/ServerManagerJob.php: Removed Docker cleanup logic
Testing:
- Syntax validation passed
- Code formatting verified with Laravel Pint
- PHPStan analysis completed (existing warnings unrelated to changes)