Skip to content

Commit

Permalink
fix: #174 use root to exec the backup command
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdan-shulha committed Sep 8, 2024
1 parent 061ca3a commit 9b40161
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/Console/Commands/DispatchVolumeBackupTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Node;
use App\Models\NodeTaskGroupType;
use App\Models\NodeTaskType;
use App\Models\Scopes\TeamScope;
use App\Models\Service;
use Exception;
use Illuminate\Console\Command;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function handle(): void
protected function dispatchBackupTask(): void
{
/* @var Service $service */
$service = Service::findOrFail($this->option('service-id'));
$service = Service::withoutGlobalScope(TeamScope::class)->with(['latestDeployment'])->findOrFail($this->option('service-id'));

$deployment = $service->latestDeployment;

Expand All @@ -56,7 +57,7 @@ protected function dispatchBackupTask(): void
throw new Exception("Could not find volume {$this->option('volume')} in process {$process->name}.");
}

$node = Node::findOrFail($deployment->data->placementNodeId);
$node = Node::withoutGlobalScope(TeamScope::class)->findOrFail($deployment->data->placementNodeId);

$taskGroup = $node->taskGroups()->create([
'swarm_id' => $node->swarm_id,
Expand Down Expand Up @@ -87,6 +88,7 @@ protected function dispatchBackupTask(): void
'payload' => [
'ProcessName' => $process->dockerName,
'ExecSpec' => [
'User' => 'root',
'AttachStdout' => true,
'AttachStderr' => true,
'Cmd' => ['sh', '-c', $backupCommand],
Expand Down

0 comments on commit 9b40161

Please sign in to comment.