@@ -41,7 +41,7 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{
4141 "instanceLimit" : - 1 ,
4242 "createRetries" : 1 ,
4343 "region" : "us-west-2" ,
44- "zone" : "" ,
44+ "zone" : "" ,
4545 "monitoring" : false ,
4646 "tags" : [ "clusterodm" ] ,
4747 "ami" : "ami-07b4f3c02c7f83d59" ,
@@ -123,35 +123,34 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{
123123 const dockerImage = this . getConfig ( "dockerImage" ) ;
124124 const accessKey = this . getConfig ( "accessKey" ) ;
125125 const secretKey = this . getConfig ( "secretKey" ) ;
126- const dataDirMountPath = this . getConfig ( "dataDirMountPath" ) ;
126+ const dataDirMountPath = this . getConfig ( "dataDirMountPath" ) ;
127127 const s3 = this . getConfig ( "s3" ) ;
128128 const webhook = netutils . publicAddressPath ( "/commit" , req , token ) ;
129129
130130 const setupCmd = this . getConfig ( "nodeSetupCmd" ) ;
131- if ( setupCmd != null && setupCmd . length > 0 )
132- {
131+ if ( setupCmd != null && setupCmd . length > 0 ) {
133132 await dm . ssh ( setupCmd ) ;
134133 }
135134
136135 let dockerRunArgs = [ `sudo docker run -d -p 3000:3000` ] ;
137136
138- if ( dataDirMountPath . length > 0 ) {
139- dockerRunArgs . push ( `--mount type=bind,source=${ dataDirMountPath } ,target=/var/www/data` ) ;
140- }
141- if ( this . getConfig ( "dockerGpu" ) ) {
142- dockerRunArgs . push ( `--gpus all` ) ;
143- }
144-
145- dockerRunArgs . push ( `${ dockerImage } -q 1` ) ;
146- dockerRunArgs . push ( `--s3_access_key ${ accessKey } ` ) ;
147- dockerRunArgs . push ( `--s3_secret_key ${ secretKey } ` ) ;
148- dockerRunArgs . push ( `--s3_endpoint ${ s3 . endpoint } ` ) ;
149- dockerRunArgs . push ( `--s3_bucket ${ s3 . bucket } ` ) ;
150- dockerRunArgs . push ( `--s3_acl ${ s3 . acl } ` ) ;
151- dockerRunArgs . push ( `--webhook ${ webhook } ` ) ;
152- dockerRunArgs . push ( `--token ${ nodeToken } ` ) ;
153-
154- await dm . ssh ( dockerRunArgs . join ( " " ) ) ;
137+ if ( dataDirMountPath . length > 0 ) {
138+ dockerRunArgs . push ( `--mount type=bind,source=${ dataDirMountPath } ,target=/var/www/data` ) ;
139+ }
140+ if ( this . getConfig ( "dockerGpu" ) ) {
141+ dockerRunArgs . push ( `--gpus all` ) ;
142+ }
143+
144+ dockerRunArgs . push ( `${ dockerImage } -q 1` ) ;
145+ dockerRunArgs . push ( `--s3_access_key ${ accessKey } ` ) ;
146+ dockerRunArgs . push ( `--s3_secret_key ${ secretKey } ` ) ;
147+ dockerRunArgs . push ( `--s3_endpoint ${ s3 . endpoint } ` ) ;
148+ dockerRunArgs . push ( `--s3_bucket ${ s3 . bucket } ` ) ;
149+ dockerRunArgs . push ( `--s3_acl ${ s3 . acl } ` ) ;
150+ dockerRunArgs . push ( `--webhook ${ webhook } ` ) ;
151+ dockerRunArgs . push ( `--token ${ nodeToken } ` ) ;
152+
153+ await dm . ssh ( dockerRunArgs . join ( " " ) ) ;
155154 }
156155
157156 getImagePropertiesFor ( imagesCount ) {
@@ -177,12 +176,12 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{
177176 return this . getConfig ( "maxUploadTime" ) ;
178177 }
179178
180- async getCreateArgs ( imagesCount ) {
179+ async getCreateArgs ( imagesCount , attempt ) {
181180 const image_props = this . getImagePropertiesFor ( imagesCount ) ;
182181 const args = [
183182 "--amazonec2-access-key" , this . getConfig ( "accessKey" ) ,
184183 "--amazonec2-secret-key" , this . getConfig ( "secretKey" ) ,
185- "--amazonec2-region" , this . getConfig ( "region" ) ,
184+ "--amazonec2-region" , this . getConfigArrayItem ( "region" , attempt - 1 ) ,
186185 "--amazonec2-ami" , this . getConfig ( "ami" ) ,
187186 "--amazonec2-instance-type" , image_props [ "slug" ] ,
188187 "--amazonec2-root-size" , image_props [ "storage" ] ,
@@ -206,37 +205,42 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{
206205
207206 if ( this . getConfig ( "usePrivateAddress" ) ) {
208207 args . push ( "--amazonec2-use-private-address" ) ;
209- if ( this . getConfig ( "assignPrivateAddressOnly" ) ) {
210- args . push ( "--amazonec2-private-address-only" ) ;
211- }
208+ if ( this . getConfig ( "assignPrivateAddressOnly" ) ) {
209+ args . push ( "--amazonec2-private-address-only" ) ;
210+ }
212211 }
213212
214213 if ( this . getConfig ( "engineInstallUrl" ) ) {
215214 args . push ( "--engine-install-url" )
216215 args . push ( this . getConfig ( "engineInstallUrl" ) ) ;
217216 }
218217
219- if ( this . getConfig ( "zone" ) . length > 0 ) {
220- args . push ( "--amazonec2-zone" )
221- args . push ( this . getConfig ( "zone" ) ) ;
222- }
218+ if ( this . getConfig ( "zone" ) . length > 0 ) {
219+ args . push ( "--amazonec2-zone" )
220+ args . push ( this . getConfig ( "zone" ) ) ;
221+ }
223222
224223 if ( this . getConfig ( "vpc" ) . length > 0 ) {
225224 args . push ( "--amazonec2-vpc-id" )
226225 args . push ( this . getConfig ( "vpc" ) ) ;
227226 }
228227
229- if ( this . getConfig ( "subnet" ) . length > 0 ) {
228+ if ( this . getConfig ( "subnet" ) . length > 0 ) {
230229 args . push ( "--amazonec2-subnet-id" )
231230 args . push ( this . getConfig ( "subnet" ) ) ;
232231 }
233232
234-
235- if ( this . getConfig ( "iamrole" ) . length > 0 ) {
233+ if ( this . getConfig ( "iamrole" ) . length > 0 ) {
236234 args . push ( "--amazonec2-iam-instance-profile" )
237235 args . push ( this . getConfig ( "iamrole" ) ) ;
238236 }
239237
240238 return args ;
241239 }
240+
241+ getFailureSleepTime ( attempt ) {
242+ const numRegions = this . getConfigArray ( "region" ) . length ;
243+ if ( attempt <= numRegions ) return 1000 ;
244+ else return 10000 * ( attempt - numRegions ) ;
245+ }
242246} ;
0 commit comments