feat(cleanup): default to threshold-mode docker cleanup every 10 minutes

This commit is contained in:
rosslh 2026-08-29 09:57:49 -04:00
parent 0842690327
commit d48f91cfc3

View file

@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
// MapleDeploy branding: threshold-based Docker cleanup by default.
//
// Upstream defaults to a forced cleanup once a day (00:00). On a managed
// instance whose only server is the VM itself, a build-heavy app can fill the
// disk between two daily runs (titanreach, 2026-08-29: ~30 deploys of a 2.5 GB
// image in one evening, ENOSPC mid-build, deployment queue stuck). The
// scheduler dispatches on docker_cleanup_frequency regardless of the force
// flag; with force off, the job only prunes when usage exceeds the threshold.
// Checking every 10 minutes and pruning above 75% catches fast fills without
// pruning on servers that do not need it.
return new class extends Migration
{
private const UPSTREAM = ['force' => true, 'frequency' => '0 0 * * *', 'threshold' => 80];
private const MAPLEDEPLOY = ['force' => false, 'frequency' => '*/10 * * * *', 'threshold' => 75];
public function up(): void
{
Schema::table('server_settings', function (Blueprint $table) {
$table->boolean('force_docker_cleanup')->default(self::MAPLEDEPLOY['force'])->change();
$table->string('docker_cleanup_frequency')->default(self::MAPLEDEPLOY['frequency'])->change();
$table->integer('docker_cleanup_threshold')->default(self::MAPLEDEPLOY['threshold'])->change();
});
// Only rows still on the untouched upstream default are moved, so a
// setting an operator chose deliberately is left alone.
DB::table('server_settings')
->where('force_docker_cleanup', self::UPSTREAM['force'])
->where('docker_cleanup_frequency', self::UPSTREAM['frequency'])
->where('docker_cleanup_threshold', self::UPSTREAM['threshold'])
->update([
'force_docker_cleanup' => self::MAPLEDEPLOY['force'],
'docker_cleanup_frequency' => self::MAPLEDEPLOY['frequency'],
'docker_cleanup_threshold' => self::MAPLEDEPLOY['threshold'],
]);
}
public function down(): void
{
Schema::table('server_settings', function (Blueprint $table) {
$table->boolean('force_docker_cleanup')->default(self::UPSTREAM['force'])->change();
$table->string('docker_cleanup_frequency')->default(self::UPSTREAM['frequency'])->change();
$table->integer('docker_cleanup_threshold')->default(self::UPSTREAM['threshold'])->change();
});
}
};