mirror of
https://github.com/pelican-dev/panel.git
synced 2025-06-10 19:09:00 +02:00
Remove final refs
This commit is contained in:
parent
8ea57bc46b
commit
44e0dd3e09
@ -10,6 +10,7 @@ use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
@ -103,6 +104,16 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereUuid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereuuid_short($value)
|
||||
*
|
||||
* @property array|null $docker_labels
|
||||
* @property Collection<Endpoint>|null $ports
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\EggVariable> $eggVariables
|
||||
* @property-read int|null $egg_variables_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ServerVariable> $serverVariables
|
||||
* @property-read int|null $server_variables_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereDockerLabels($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereInstalledAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server wherePorts($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereUuidShort($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Server extends Model
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Services\Allocations;
|
||||
|
||||
use App\Models\Objects\Endpoint;
|
||||
use Illuminate\Support\Collection;
|
||||
use Webmozart\Assert\Assert;
|
||||
use App\Models\Server;
|
||||
use App\Exceptions\Service\Allocation\AutoAllocationNotEnabledException;
|
||||
@ -45,11 +47,10 @@ class FindAssignableAllocationService
|
||||
Assert::integerish($start);
|
||||
Assert::integerish($end);
|
||||
|
||||
// Get all the currently allocated ports for the node so that we can figure out which port might be available.
|
||||
$ports = $server->node->allocations()
|
||||
->where('ip', $server->allocation->ip)
|
||||
->whereBetween('port', [$start, $end])
|
||||
->pluck('port');
|
||||
$ports = $server->node->servers
|
||||
->reduce(fn (Collection $result, $value) => $result->merge($value), collect())
|
||||
->map(fn (Endpoint $endpoint) => $endpoint->port)
|
||||
->filter(fn (int $port): bool => $port >= $start && $port <= $end);
|
||||
|
||||
// Compute the difference of the range and the currently created ports, finding
|
||||
// any port that does not already exist in the database. We will then use this
|
||||
@ -57,7 +58,6 @@ class FindAssignableAllocationService
|
||||
$available = array_diff(range($start, $end), $ports->toArray());
|
||||
|
||||
// Pick a random port out of the remaining available ports.
|
||||
/** @var int $port */
|
||||
return $available[array_rand($available)];
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ class ServerConfigurationStructureService
|
||||
'allocations' => [
|
||||
'force_outgoing_ip' => $server->egg->force_outgoing_ip,
|
||||
'default' => [
|
||||
'ip' => $server->allocation->ip,
|
||||
'port' => $server->allocation->port,
|
||||
'ip' => $server->getPrimaryEndpoint()->ip,
|
||||
'port' => $server->getPrimaryEndpoint()->port,
|
||||
],
|
||||
'mappings' => $server->getPortMappings(),
|
||||
],
|
||||
|
@ -77,8 +77,6 @@ class ServerDeletionService
|
||||
}
|
||||
}
|
||||
|
||||
$server->allocations()->update(['server_id' => null]);
|
||||
|
||||
$server->delete();
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user