Skip to content

Commit 1ed4a7c

Browse files
committed
fix: unique name for release command
1 parent 68a1e1a commit 1ed4a7c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Diff for: app/Models/DeploymentData/Worker.php

+12-7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function __construct(
5656

5757
public function asNodeTasks(Deployment $deployment, Process $process, bool $pullImage = true, ?int $desiredReplicas = null, ?Backup $backup = null): array
5858
{
59+
if (! $this->dockerName) {
60+
$this->dockerName = $process->makeResourceName('wkr_'.$this->name);
61+
}
62+
5963
$launchNow = is_null($desiredReplicas) ? $this->replicas > 0 : $desiredReplicas > 0;
6064

6165
if ($launchNow) {
@@ -76,10 +80,6 @@ public function asNodeTasks(Deployment $deployment, Process $process, bool $pull
7680

7781
$tasks = [];
7882

79-
if (! $this->dockerName) {
80-
$this->dockerName = $process->makeResourceName('wkr_'.$this->name);
81-
}
82-
8383
if ($this->launchMode->value === LaunchMode::BackupCreate->value && ! $this->backupCreate->backupVolume) {
8484
$dockerName = dockerize_name($this->dockerName.'_vol_ptah_backup');
8585

@@ -136,7 +136,7 @@ public function asNodeTasks(Deployment $deployment, Process $process, bool $pull
136136
'workerName' => $this->name,
137137
]),
138138
'payload' => [
139-
'ReleaseCommand' => $this->getReleaseCommandPayload($process, $labels),
139+
'ReleaseCommand' => $this->getReleaseCommandPayload($deployment, $labels),
140140
'SecretVars' => $this->getSecretVars($process),
141141
'SwarmServiceSpec' => [
142142
'Name' => $this->dockerName,
@@ -283,7 +283,7 @@ private function getCommandAndArgs(): array
283283
return [['sh'], ['-c', $this->command]];
284284
}
285285

286-
private function getReleaseCommandPayload(Process $process, array $labels): array
286+
private function getReleaseCommandPayload(Deployment $deployment, array $labels): array
287287
{
288288
if (! $this->releaseCommand->command) {
289289
return [
@@ -294,7 +294,7 @@ private function getReleaseCommandPayload(Process $process, array $labels): arra
294294
}
295295

296296
// Always create a new config, as the command may be the same, but the image/entrypoint may be different.
297-
$this->releaseCommand->dockerName = $process->makeResourceName('rel_cmd');
297+
$this->releaseCommand->dockerName = $this->makeResourceName('dpl_'.$deployment->id.'_rel_cmd');
298298

299299
return [
300300
'ConfigName' => $this->releaseCommand->dockerName,
@@ -468,6 +468,11 @@ private function getBackupRestoreTask(Backup $backup, array $labels): array
468468
];
469469
}
470470

471+
private function makeResourceName(string $name): string
472+
{
473+
return dockerize_name($this->dockerName.'_'.$name);
474+
}
475+
471476
public static function make(array $attributes): static
472477
{
473478
$defaults = [

0 commit comments

Comments
 (0)