diff --git a/app/Exceptions/Service/Allocation/AllocationDoesNotBelongToServerException.php b/app/Exceptions/Service/Allocation/AllocationDoesNotBelongToServerException.php deleted file mode 100644 index fa47c2f94..000000000 --- a/app/Exceptions/Service/Allocation/AllocationDoesNotBelongToServerException.php +++ /dev/null @@ -1,9 +0,0 @@ - $port])); - } -} diff --git a/app/Exceptions/Service/Allocation/NoAutoAllocationSpaceAvailableException.php b/app/Exceptions/Service/Allocation/NoAutoAllocationSpaceAvailableException.php deleted file mode 100644 index 23570445b..000000000 --- a/app/Exceptions/Service/Allocation/NoAutoAllocationSpaceAvailableException.php +++ /dev/null @@ -1,18 +0,0 @@ -node->allocations->toBase(); - return view('admin.servers.view.build', [ 'server' => $server, - 'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'), - 'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'), ]); } diff --git a/app/Http/Controllers/Api/Application/Servers/ServerController.php b/app/Http/Controllers/Api/Application/Servers/ServerController.php index 230d19794..06e8ccbb4 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerController.php @@ -49,7 +49,6 @@ class ServerController extends ApplicationApiController * @throws \Illuminate\Validation\ValidationException * @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\Model\DataValidationException - * @throws \App\Exceptions\Service\Deployment\NoViableAllocationException */ public function store(StoreServerRequest $request): JsonResponse { diff --git a/app/Models/Node.php b/app/Models/Node.php index 3f4eda6a3..c092c4a8e 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -40,7 +40,6 @@ use Symfony\Component\Yaml\Yaml; * @property \Carbon\Carbon $updated_at * @property \App\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts * @property \App\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers - * @property \App\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations */ class Node extends Model { diff --git a/app/Models/Server.php b/app/Models/Server.php index cbbf32d70..6217a2551 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -41,7 +41,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @property int $cpu * @property string|null $threads * @property bool $oom_killer - * @property int $allocation_id * @property int $egg_id * @property string $startup * @property string $image @@ -53,7 +52,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @property \Illuminate\Support\Carbon|null $installed_at * @property \Illuminate\Database\Eloquent\Collection|\App\Models\ActivityLog[] $activity * @property int|null $activity_count - * @property \App\Models\Allocation|null $allocation * @property \Illuminate\Database\Eloquent\Collection|\App\Models\Allocation[] $allocations * @property int|null $allocations_count * @property \Illuminate\Database\Eloquent\Collection|\App\Models\Backup[] $backups @@ -79,7 +77,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @method static \Illuminate\Database\Eloquent\Builder|Server newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Server newQuery() * @method static \Illuminate\Database\Eloquent\Builder|Server query() - * @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationId($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationLimit($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereBackupLimit($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereCpu($value) @@ -200,7 +197,7 @@ class Server extends Model } /** - * Returns the format for server allocations when communicating with the Daemon. + * Returns the format for server's ports when communicating with the Daemon. */ public function getPortMappings(): array { diff --git a/app/Services/Allocations/FindAssignableAllocationService.php b/app/Services/Allocations/FindAssignableAllocationService.php index a6c885207..dedfc6555 100644 --- a/app/Services/Allocations/FindAssignableAllocationService.php +++ b/app/Services/Allocations/FindAssignableAllocationService.php @@ -6,8 +6,6 @@ use App\Models\Objects\Endpoint; use Illuminate\Support\Collection; use Webmozart\Assert\Assert; use App\Models\Server; -use App\Exceptions\Service\Allocation\AutoAllocationNotEnabledException; -use App\Exceptions\Service\Allocation\NoAutoAllocationSpaceAvailableException; class FindAssignableAllocationService { @@ -15,15 +13,9 @@ class FindAssignableAllocationService { } - /** - * @throws AutoAllocationNotEnabledException - * @throws NoAutoAllocationSpaceAvailableException - */ public function handle(Server $server): int { - if (!config('panel.client_features.allocations.enabled')) { - throw new AutoAllocationNotEnabledException(); - } + abort_unless(config('panel.client_features.allocations.enabled'), 403, 'Auto Allocation is not enabled'); return $this->createNewAllocation($server); } @@ -32,18 +24,12 @@ class FindAssignableAllocationService * Create a new allocation on the server's node with a random port from the defined range * in the settings. If there are no matches in that range, or something is wrong with the * range information provided an exception will be raised. - * - * @throws NoAutoAllocationSpaceAvailableException */ protected function createNewAllocation(Server $server): int { $start = config('panel.client_features.allocations.range_start'); $end = config('panel.client_features.allocations.range_end'); - if (!$start || !$end) { - throw new NoAutoAllocationSpaceAvailableException(); - } - Assert::integerish($start); Assert::integerish($end); diff --git a/app/Services/Deployment/FindViableNodesService.php b/app/Services/Deployment/FindViableNodesService.php index d95c08c64..79dc624be 100644 --- a/app/Services/Deployment/FindViableNodesService.php +++ b/app/Services/Deployment/FindViableNodesService.php @@ -8,8 +8,7 @@ use Illuminate\Support\Collection; class FindViableNodesService { /** - * Returns a collection of nodes that meet the provided requirements and can then - * be passed to the AllocationSelectionService to return a single allocation. + * Returns a collection of nodes that meet the provided requirements * * This functionality is used for automatic deployments of servers and will * attempt to find all nodes in the defined locations that meet the memory, disk