Skip to content

Commit 9b40161

Browse files
committed
fix: #174 use root to exec the backup command
1 parent 061ca3a commit 9b40161

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/Console/Commands/DispatchVolumeBackupTask.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Models\Node;
66
use App\Models\NodeTaskGroupType;
77
use App\Models\NodeTaskType;
8+
use App\Models\Scopes\TeamScope;
89
use App\Models\Service;
910
use Exception;
1011
use Illuminate\Console\Command;
@@ -42,7 +43,7 @@ public function handle(): void
4243
protected function dispatchBackupTask(): void
4344
{
4445
/* @var Service $service */
45-
$service = Service::findOrFail($this->option('service-id'));
46+
$service = Service::withoutGlobalScope(TeamScope::class)->with(['latestDeployment'])->findOrFail($this->option('service-id'));
4647

4748
$deployment = $service->latestDeployment;
4849

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

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

6162
$taskGroup = $node->taskGroups()->create([
6263
'swarm_id' => $node->swarm_id,
@@ -87,6 +88,7 @@ protected function dispatchBackupTask(): void
8788
'payload' => [
8889
'ProcessName' => $process->dockerName,
8990
'ExecSpec' => [
91+
'User' => 'root',
9092
'AttachStdout' => true,
9193
'AttachStderr' => true,
9294
'Cmd' => ['sh', '-c', $backupCommand],

0 commit comments

Comments
 (0)