mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 14:16:52 +01:00 
			
		
		
		
	Remove exception
This commit is contained in:
		
							parent
							
								
									2808a3dd35
								
							
						
					
					
						commit
						da698a3666
					
				| @ -1,9 +0,0 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Exceptions\Service\Deployment; | ||||
| 
 | ||||
| use App\Exceptions\DisplayException; | ||||
| 
 | ||||
| class NoViableNodeException extends DisplayException | ||||
| { | ||||
| } | ||||
| @ -53,7 +53,6 @@ class CreateServerController extends Controller | ||||
|      * @throws \Illuminate\Validation\ValidationException | ||||
|      * @throws \App\Exceptions\DisplayException | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableAllocationException | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableNodeException | ||||
|      * @throws \Throwable | ||||
|      */ | ||||
|     public function store(ServerFormRequest $request): RedirectResponse | ||||
|  | ||||
| @ -21,8 +21,6 @@ class NodeDeploymentController extends ApplicationApiController | ||||
|      * Finds any nodes that are available using the given deployment criteria. This works | ||||
|      * similarly to the server creation process, but allows you to pass the deployment object | ||||
|      * to this endpoint and get back a list of all Nodes satisfying the requirements. | ||||
|      * | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableNodeException | ||||
|      */ | ||||
|     public function __invoke(GetDeployableNodesRequest $request): array | ||||
|     { | ||||
|  | ||||
| @ -50,7 +50,6 @@ class ServerController extends ApplicationApiController | ||||
|      * @throws \App\Exceptions\DisplayException | ||||
|      * @throws \App\Exceptions\Model\DataValidationException | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableAllocationException | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableNodeException | ||||
|      */ | ||||
|     public function store(StoreServerRequest $request): JsonResponse | ||||
|     { | ||||
|  | ||||
| @ -5,8 +5,6 @@ namespace App\Services\Deployment; | ||||
| use App\Models\Node; | ||||
| use Webmozart\Assert\Assert; | ||||
| use Illuminate\Support\Collection; | ||||
| use Illuminate\Contracts\Pagination\LengthAwarePaginator; | ||||
| use App\Exceptions\Service\Deployment\NoViableNodeException; | ||||
| 
 | ||||
| class FindViableNodesService | ||||
| { | ||||
| @ -37,7 +35,7 @@ class FindViableNodesService | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns an array of nodes that meet the provided requirements and can then | ||||
|      * Returns a collection of nodes that meet the provided requirements and can then | ||||
|      * be passed to the AllocationSelectionService to return a single allocation. | ||||
|      * | ||||
|      * This functionality is used for automatic deployments of servers and will | ||||
| @ -45,15 +43,8 @@ class FindViableNodesService | ||||
|      * memory availability requirements. Any nodes not meeting those requirements | ||||
|      * are tossed out, as are any nodes marked as non-public, meaning automatic | ||||
|      * deployments should not be done against them. | ||||
|      * | ||||
|      * @param int|null $page If provided the results will be paginated by returning | ||||
|      *                       up to 50 nodes at a time starting at the provided page. | ||||
|      *                       If "null" is provided as the value no pagination will | ||||
|      *                       be used. | ||||
|      * | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableNodeException | ||||
|      */ | ||||
|     public function handle(int $perPage = null, int $page = null): LengthAwarePaginator|Collection | ||||
|     public function handle(int $disk = null, int $memory = null, int $cpu = null): Collection | ||||
|     { | ||||
|         Assert::integer($this->disk, 'Disk space must be an int, got %s'); | ||||
|         Assert::integer($this->memory, 'Memory usage must be an int, got %s'); | ||||
| @ -68,16 +59,6 @@ class FindViableNodesService | ||||
|             ->havingRaw('(IFNULL(SUM(servers.memory), 0) + ?) <= (nodes.memory * (1 + (nodes.memory_overallocate / 100)))', [$this->memory]) | ||||
|             ->havingRaw('(IFNULL(SUM(servers.disk), 0) + ?) <= (nodes.disk * (1 + (nodes.disk_overallocate / 100)))', [$this->disk]); | ||||
| 
 | ||||
|         if (!is_null($page)) { | ||||
|             $results = $results->paginate($perPage ?? 50, ['*'], 'page', $page); | ||||
|         } else { | ||||
|             $results = $results->get()->toBase(); | ||||
|         } | ||||
| 
 | ||||
|         if ($results->isEmpty()) { | ||||
|             throw new NoViableNodeException(trans('exceptions.deployment.no_viable_nodes')); | ||||
|         } | ||||
| 
 | ||||
|         return $results; | ||||
|         return $results->get(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -42,7 +42,6 @@ class ServerCreationService | ||||
|      * @throws \Throwable | ||||
|      * @throws \App\Exceptions\DisplayException | ||||
|      * @throws \Illuminate\Validation\ValidationException | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableNodeException | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableAllocationException | ||||
|      */ | ||||
|     public function handle(array $data, DeploymentObject $deployment = null): Server | ||||
| @ -105,7 +104,6 @@ class ServerCreationService | ||||
|      * | ||||
|      * @throws \App\Exceptions\DisplayException | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableAllocationException | ||||
|      * @throws \App\Exceptions\Service\Deployment\NoViableNodeException | ||||
|      */ | ||||
|     private function configureDeployment(array $data, DeploymentObject $deployment): Allocation | ||||
|     { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Lance Pioch
						Lance Pioch