Merge branch 'develop' into feature/react-admin

This commit is contained in:
Matthew Penner 2021-01-12 11:47:13 -07:00
commit c40e4bd2c0
12 changed files with 153 additions and 6 deletions

View file

@ -77,10 +77,15 @@ class FindViableNodesService
* are tossed out, as are any nodes marked as non-public, meaning automatic
* deployments should not be done against them.
*
* @return \Pterodactyl\Models\Node[]|\Illuminate\Support\Collection
* @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.
* @return \Illuminate\Support\Collection|\Illuminate\Contracts\Pagination\LengthAwarePaginator
*
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
*/
public function handle()
public function handle(int $page = null)
{
Assert::integer($this->disk, 'Disk space must be an int, got %s');
Assert::integer($this->memory, 'Memory usage must be an int, got %s');
@ -97,9 +102,13 @@ class FindViableNodesService
$results = $query->groupBy('nodes.id')
->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])
->get()
->toBase();
->havingRaw('(IFNULL(SUM(servers.disk), 0) + ?) <= (nodes.disk * (1 + (nodes.disk_overallocate / 100)))', [$this->disk]);
if (! is_null($page)) {
$results = $results->paginate(50, ['*'], 'page', $page);
} else {
$results = $results->get()->toBase();
}
if ($results->isEmpty()) {
throw new NoViableNodeException(trans('exceptions.deployment.no_viable_nodes'));

View file

@ -53,6 +53,10 @@ class EggUpdateService
}
}
// TODO(dane): Once the admin UI is done being reworked and this is exposed
// in said UI, remove this so that you can actually update the denylist.
unset($data['file_denylist']);
$this->repository->withoutFreshModel()->update($egg->id, $data);
}
}

View file

@ -46,6 +46,7 @@ class EggExporterService
'description' => $egg->description,
'features' => $egg->features,
'images' => $egg->docker_images,
'file_denylist' => $egg->inherit_file_denylist,
'startup' => $egg->startup,
'config' => [
'files' => $egg->inherit_config_files,

View file

@ -105,6 +105,7 @@ class EggImporterService
// Maintain backwards compatability for eggs that are still using the old single image
// string format. New eggs can provide an array of Docker images that can be used.
'docker_images' => object_get($parsed, 'images') ?? [object_get($parsed, 'image')],
'file_denylist' => implode(PHP_EOL, object_get($parsed, 'file_denylist') ?? []),
'update_url' => object_get($parsed, 'meta.update_url'),
'config_files' => object_get($parsed, 'config.files'),
'config_startup' => object_get($parsed, 'config.startup'),
@ -118,7 +119,7 @@ class EggImporterService
], true, true);
collect($parsed->variables)->each(function ($variable) use ($egg) {
$this->eggVariableRepository->create(array_merge((array) $variable, [
$this->eggVariableRepository->create(array_merge((array)$variable, [
'egg_id' => $egg->id,
]));
});

View file

@ -91,6 +91,14 @@ class ServerConfigurationStructureService
'read_only' => $mount->read_only,
];
}),
'egg' => [
'id' => $server->egg->uuid,
'file_denylist' => [
'config.yml',
'**/*.json'
]
// 'file_denylist' => explode(PHP_EOL, $server->egg->inherit_file_denylist),
]
];
}

View file

@ -197,6 +197,7 @@ class ServerCreationService
*/
private function configureDeployment(array $data, DeploymentObject $deployment): Allocation
{
/** @var \Illuminate\Support\Collection $nodes */
$nodes = $this->findViableNodesService->setLocations($deployment->getLocations())
->setDisk(Arr::get($data, 'disk'))
->setMemory(Arr::get($data, 'memory'))