16
16
use App \Rules \Crontab ;
17
17
use App \Util \ResourceId ;
18
18
use Exception ;
19
- use Illuminate \Support \Str ;
20
19
use Spatie \LaravelData \Attributes \Validation \Enum ;
21
20
use Spatie \LaravelData \Attributes \Validation \Min ;
22
21
use Spatie \LaravelData \Attributes \Validation \ProhibitedUnless ;
@@ -81,10 +80,10 @@ public function asNodeTasks(Deployment $deployment, Process $process, bool $buil
81
80
$ hostname = $ this ->getHostname ($ deployment , $ process );
82
81
83
82
if ($ this ->launchMode ->value === LaunchMode::BackupCreate->value && ! $ this ->backupCreate ->backupVolume ) {
84
- $ dockerName = dockerize_name ($ this ->dockerName .'_vol_ptah_backup ' );
83
+ $ dockerName = dockerize_name ($ this ->getDockerName ( $ process ) .'_vol_ptah_backup ' );
85
84
86
85
$ this ->backupCreate ->backupVolume = Volume::validateAndCreate ([
87
- 'id ' => ' volume- ' .Str:: random ( 11 ),
86
+ 'id ' => ResourceId:: make ( ' volume ' ),
88
87
'name ' => $ dockerName ,
89
88
'dockerName ' => $ dockerName ,
90
89
'path ' => '/ptah/backup/create ' ,
@@ -97,10 +96,10 @@ public function asNodeTasks(Deployment $deployment, Process $process, bool $buil
97
96
}
98
97
99
98
if (! $ this ->backupRestore ->restoreVolume ) {
100
- $ dockerName = dockerize_name ($ this ->dockerName .'_vol_ptah_restore ' );
99
+ $ dockerName = dockerize_name ($ this ->getDockerName ( $ process ) .'_vol_ptah_restore ' );
101
100
102
101
$ this ->backupRestore ->restoreVolume = Volume::validateAndCreate ([
103
- 'id ' => ' volume- ' .Str:: random ( 11 ),
102
+ 'id ' => ResourceId:: make ( ' volume ' ),
104
103
'name ' => $ dockerName ,
105
104
'dockerName ' => $ dockerName ,
106
105
'path ' => '/ptah/backup/restore ' ,
@@ -113,7 +112,7 @@ public function asNodeTasks(Deployment $deployment, Process $process, bool $buil
113
112
'kind ' => 'worker ' ,
114
113
// Cookie is used to filter out stale tasks for the same Docker Service on the Docker Engine's side
115
114
// and avoid transferring loads of data between Ptah.sh Agent and Docker Engine.
116
- 'cookie ' => Str:: random ( 32 ),
115
+ 'cookie ' => WorkerCookie:: make ( ),
117
116
'worker.name ' => $ this ->name ,
118
117
]);
119
118
@@ -136,15 +135,15 @@ public function asNodeTasks(Deployment $deployment, Process $process, bool $buil
136
135
'deploymentId ' => $ deployment ->id ,
137
136
'serviceId ' => $ deployment ->service_id ,
138
137
'serviceName ' => $ deployment ->service ->name ,
139
- 'dockerName ' => $ this ->dockerName ,
138
+ 'dockerName ' => $ this ->getDockerName ( $ process ) ,
140
139
'processName ' => $ process ->name ,
141
140
'workerName ' => $ this ->name ,
142
141
]),
143
142
'payload ' => [
144
143
'ReleaseCommand ' => $ this ->getReleaseCommandPayload ($ deployment , $ process , $ labels ),
145
144
'SecretVars ' => $ this ->getSecretVars ($ process ),
146
145
'SwarmServiceSpec ' => [
147
- 'Name ' => $ this ->dockerName ,
146
+ 'Name ' => $ this ->getDockerName ( $ process ) ,
148
147
'Labels ' => $ labels ,
149
148
'TaskTemplate ' => [
150
149
'ContainerSpec ' => [
0 commit comments