Skip to content

Enforce per-node allocation limit when finding available nodes - #1358

Open
KroZen-Dev wants to merge 3 commits into
Ctrlpanel-gg:developmentfrom
KroZen-Dev:fix/allocation-limit-per-node
Open

Enforce per-node allocation limit when finding available nodes#1358
KroZen-Dev wants to merge 3 commits into
Ctrlpanel-gg:developmentfrom
KroZen-Dev:fix/allocation-limit-per-node

Conversation

@KroZen-Dev

@KroZen-Dev KroZen-Dev commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Description

Enforce the per-node allocation limit when selecting an available node for
server provisioning. Previously, findAvailableNode() only rejected nodes
that lacked resources or had no free allocations, and
findAvailableNodeWithAllocation() only checked resources — neither checked
whether a node had already reached its per-node allocation limit. As a result,
nodes at their allocation limit could still be treated as available and only
fail later when trying to grab an allocation.

This adds an early guard in both methods: if
nodeHasReachedAllocationLimit($node, $node->allocation_limit) is true, the
node is rejected before any free-allocation lookup, making node selection more
accurate and avoiding wasted calls.

Type of Change

  • Bug fix

Testing

  • Verified findAvailableNode() rejects a node once its per-node allocation
    limit is reached.
  • Verified findAvailableNodeWithAllocation() skips nodes at their allocation
    limit and falls through to the next available node.
  • Confirmed existing resource and free-allocation checks still behave as before.

Checklist

  • My PR targets the development branch
  • Commit messages follow Conventional Commits
  • Code follows PSR-12
  • I have reviewed my own code
  • I have tested all affected functionality
  • No new warnings or errors introduced

Ensure nodes that have reached their per-node allocation limit are
excluded before attempting to assign a free allocation, preventing
selection of nodes that cannot host new servers.
@MrWeez MrWeez linked an issue Jul 28, 2026 that may be closed by this pull request
2 tasks
@MrWeez MrWeez added the Medium Priority Needs attention, not urgent label Jul 28, 2026
Comment thread app/Classes/PterodactylClient.php Outdated
Comment thread app/Classes/PterodactylClient.php Outdated
Comment thread app/Classes/PterodactylClient.php Outdated
@KroZen-Dev
KroZen-Dev requested a review from MrWeez July 28, 2026 09:56
Comment thread app/Classes/PterodactylClient.php Outdated
Comment on lines 580 to 584
try {
$freeAllocations = $this->pterodactyl->getFreeAllocations($node);
} catch (\Exception $e) {
return true;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we wrapped $response inside getFreeAllocations() (see review comment for that function) you don't need to wrap call site here

Comment thread app/Services/ServerCreationService.php Outdated
Comment thread app/Classes/PterodactylClient.php Outdated
- wrap getAllocations in try/catch inside getFreeAllocations and nodeHasReachedAllocationLimit
- remove redundant try/catch from callers in ServerController and ServerCreationService
- simplify nodeHasReachedAllocationLimit to read allocation_limit directly from node
@KroZen-Dev
KroZen-Dev requested a review from MrWeez July 29, 2026 15:38
@MrWeez

MrWeez commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Medium Priority Needs attention, not urgent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allocation Limit works per-location instead of per-node

2 participants