@@ -232,11 +232,10 @@ export class SandboxService {
232232 }
233233
234234 async createForWarmPool ( warmPoolItem : WarmPool ) : Promise < Sandbox > {
235- const sandbox = new Sandbox ( )
235+ const sandbox = new Sandbox ( warmPoolItem . target )
236236
237237 sandbox . organizationId = SANDBOX_WARM_POOL_UNASSIGNED_ORGANIZATION
238238
239- sandbox . region = warmPoolItem . target
240239 sandbox . class = warmPoolItem . class
241240 sandbox . snapshot = warmPoolItem . snapshot
242241 // TODO: default user should be configurable
@@ -281,7 +280,7 @@ export class SandboxService {
281280 let pendingDiskIncrement : number | undefined
282281
283282 try {
284- const region = this . getValidatedOrDefaultRegion ( createSandboxDto . target )
283+ const region = this . getValidatedOrDefaultRegion ( organization , createSandboxDto . target )
285284 const sandboxClass = this . getValidatedOrDefaultClass ( createSandboxDto . class )
286285
287286 let snapshotIdOrName = createSandboxDto . snapshot
@@ -362,7 +361,7 @@ export class SandboxService {
362361 const warmPoolSandbox = await this . warmPoolService . fetchWarmPoolSandbox ( {
363362 organizationId : organization . id ,
364363 snapshot : snapshotIdOrName ,
365- target : createSandboxDto . target ,
364+ target : region ,
366365 class : createSandboxDto . class ,
367366 cpu : cpu ,
368367 mem : mem ,
@@ -386,12 +385,11 @@ export class SandboxService {
386385 snapshotRef : snapshot . internalName ,
387386 } )
388387
389- const sandbox = new Sandbox ( createSandboxDto . name )
388+ const sandbox = new Sandbox ( region , createSandboxDto . name )
390389
391390 sandbox . organizationId = organization . id
392391
393392 // TODO: make configurable
394- sandbox . region = region
395393 sandbox . class = sandboxClass
396394 sandbox . snapshot = snapshot . name
397395 // TODO: default user should be configurable
@@ -523,7 +521,7 @@ export class SandboxService {
523521 let pendingDiskIncrement : number | undefined
524522
525523 try {
526- const region = this . getValidatedOrDefaultRegion ( createSandboxDto . target )
524+ const region = this . getValidatedOrDefaultRegion ( organization , createSandboxDto . target )
527525 const sandboxClass = this . getValidatedOrDefaultClass ( createSandboxDto . class )
528526
529527 const cpu = createSandboxDto . cpu || DEFAULT_CPU
@@ -551,11 +549,10 @@ export class SandboxService {
551549 await this . volumeService . validateVolumes ( organization . id , volumeIdOrNames )
552550 }
553551
554- const sandbox = new Sandbox ( createSandboxDto . name )
552+ const sandbox = new Sandbox ( region , createSandboxDto . name )
555553
556554 sandbox . organizationId = organization . id
557555
558- sandbox . region = region
559556 sandbox . class = sandboxClass
560557 sandbox . osUser = createSandboxDto . user || 'daytona'
561558 sandbox . env = createSandboxDto . env || { }
@@ -1082,9 +1079,9 @@ export class SandboxService {
10821079 }
10831080 }
10841081
1085- private getValidatedOrDefaultRegion ( region ?: string ) : string {
1082+ private getValidatedOrDefaultRegion ( organization : Organization , region ?: string ) : string {
10861083 if ( ! region || region . trim ( ) . length === 0 ) {
1087- return 'us'
1084+ return organization . defaultRegion
10881085 }
10891086
10901087 return region . trim ( )
0 commit comments