fix(admin): don't flag scheduled-backoff runs as stale; edit-datacenter country validation from config
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>feat/portal-design
parent
8304f2e7dc
commit
2b73a895c9
|
|
@ -20,11 +20,8 @@ class EditDatacenter extends ModalComponent
|
|||
#[Validate('required|string|max:255')]
|
||||
public string $name = '';
|
||||
|
||||
#[Validate('nullable|string|max:2|in:'.self::COUNTRY_KEYS)]
|
||||
public string $location = '';
|
||||
|
||||
private const COUNTRY_KEYS = 'DE,AT,CH,FI,SE,NO,DK,NL,BE,LU,FR,GB,IE,ES,PT,IT,PL,CZ,SK,HU,SI,HR,RO,BG,GR,EE,LV,LT,US,CA';
|
||||
|
||||
public function mount(string $uuid): void
|
||||
{
|
||||
$dc = Datacenter::query()->where('uuid', $uuid)->firstOrFail();
|
||||
|
|
@ -37,7 +34,11 @@ class EditDatacenter extends ModalComponent
|
|||
public function save()
|
||||
{
|
||||
$this->authorize('datacenters.manage');
|
||||
$data = $this->validate();
|
||||
// Validate the country against the configured list so add + edit stay in sync.
|
||||
$data = $this->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'location' => 'nullable|in:'.implode(',', array_keys((array) config('countries'))),
|
||||
]);
|
||||
|
||||
Datacenter::query()->where('uuid', $this->uuid)->update([
|
||||
'name' => $data['name'],
|
||||
|
|
|
|||
|
|
@ -60,12 +60,21 @@ class Provisioning extends Component
|
|||
$this->dispatch('notify', message: __('admin.run_retried'));
|
||||
}
|
||||
|
||||
/** A run that claims to be in progress but hasn't advanced in a while looks stuck. */
|
||||
/**
|
||||
* A run that claims to be in progress but hasn't advanced in a while looks
|
||||
* stuck — unless it is in a legitimate scheduled backoff (next_attempt_at in
|
||||
* the future, e.g. RunRunner's retry delay of up to 300 s).
|
||||
*/
|
||||
private function isStale(ProvisioningRun $run): bool
|
||||
{
|
||||
return in_array($run->status, ['running', 'waiting'], true)
|
||||
&& $run->updated_at !== null
|
||||
&& $run->updated_at->lt(now()->subMinutes(2));
|
||||
if (! in_array($run->status, ['running', 'waiting'], true)) {
|
||||
return false;
|
||||
}
|
||||
if ($run->next_attempt_at !== null && $run->next_attempt_at->isFuture()) {
|
||||
return false; // waiting out a scheduled retry/poll — not stuck
|
||||
}
|
||||
|
||||
return $run->updated_at !== null && $run->updated_at->lt(now()->subMinutes(2));
|
||||
}
|
||||
|
||||
private function subjectLabel(ProvisioningRun $run): string
|
||||
|
|
|
|||
Loading…
Reference in New Issue