Skip to content

Commit

Permalink
Merge pull request #316 from pelican-dev/issue/node-update
Browse files Browse the repository at this point in the history
Fix Node Updating
  • Loading branch information
notAreYouScared authored Jun 7, 2024
2 parents 93bfe92 + 7ee52af commit 9ce262b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/Services/Nodes/NodeUpdateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public function __construct(
*/
public function handle(Node $node, array $data, bool $resetToken = false): Node
{
$data['id'] = $node->id;

if ($resetToken) {
$data['daemon_token'] = Str::random(Node::DAEMON_TOKEN_LENGTH);
$data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);
Expand All @@ -35,15 +37,9 @@ public function handle(Node $node, array $data, bool $resetToken = false): Node
[$updated, $exception] = $this->connection->transaction(function () use ($data, $node) {
/** @var \App\Models\Node $updated */
$updated = $node->replicate();
$updated->exists = true;
$updated->forceFill($data)->save();
try {
// If we're changing the FQDN for the node, use the newly provided FQDN for the connection
// address. This should alleviate issues where the node gets pointed to a "valid" FQDN that
// isn't actually running the daemon software, and therefore you can't actually change it
// back.
//
// This makes more sense anyways, because only the Panel uses the FQDN for connecting, the
// node doesn't actually care about this.
$node->fqdn = $updated->fqdn;

$this->configurationRepository->setNode($node)->update($updated);
Expand Down

0 comments on commit 9ce262b

Please sign in to comment.