Fix server creation without deployment (#1569)

This commit is contained in:
Boy132 2025-08-07 11:16:32 +02:00 committed by GitHub
parent 02e3e43f1e
commit 49e9440e0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,15 +39,7 @@ class ServerCreationService
* as possible given the input data. For example, if an allocation_id is passed with * as possible given the input data. For example, if an allocation_id is passed with
* no node_id the node_is will be picked from the allocation. * no node_id the node_is will be picked from the allocation.
* *
* @param array{ * @param array<mixed, mixed> $data
* node_id?: int,
* oom_killer?: bool,
* oom_disabled?: bool,
* egg_id?: int,
* image?: ?string,
* startup?: ?string,
* start_on_completion?: ?bool,
* } $data
* *
* @throws \Throwable * @throws \Throwable
* @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\DisplayException
@ -94,6 +86,8 @@ class ServerCreationService
if (empty($data['node_id'])) { if (empty($data['node_id'])) {
$data['node_id'] = $nodes->first(); $data['node_id'] = $nodes->first();
} }
} else {
$data['node_id'] = Allocation::find($data['allocation_id'])?->node_id;
} }
Assert::false(empty($data['node_id']), 'Expected a non-empty node_id in server creation data.'); Assert::false(empty($data['node_id']), 'Expected a non-empty node_id in server creation data.');