instance($run); if ($instance === null) { return StepResult::fail('no_instance'); } $quota = StorageAllowance::for($instance)->totalGb(); // No allowance recorded: setting "0 GB" would lock the customer out of // their own files, which is a far worse answer than leaving what is // there and letting somebody notice. if ($quota <= 0) { return StepResult::advance(); } $pve = $this->pve->forHost($instance->host); // Idempotent, like every other occ call in this pipeline: writing the // same value again is a no-op and exits 0. $this->guest($pve, $run, NextcloudOcc::command('config:app:set files default_quota --value='.escapeshellarg($quota.' GB'))); // Recorded only AFTER the guest accepted it — guest() throws on a // non-zero exit, so nothing below runs for a call that failed. Without // this line there is no way to tell a machine whose allowance is // enforced from one where the figure has only ever been a row in our // database, which is precisely how every instance built before this step // existed came to have the whole disk. See clupilot:apply-quotas. $instance->update(['quota_applied_gb' => $quota]); return StepResult::advance(); } }