@@ -430,14 +430,16 @@ export class Remote {
430
430
return
431
431
}
432
432
433
+ const logDir = this . getLogDir ( featureSet )
434
+
433
435
// This ensures the Remote SSH extension resolves the host to execute the
434
436
// Coder binary properly.
435
437
//
436
438
// If we didn't write to the SSH config file, connecting would fail with
437
439
// "Host not found".
438
440
try {
439
441
this . storage . writeToCoderOutputChannel ( "Updating SSH config..." )
440
- await this . updateSSHConfig ( workspaceRestClient , parts . label , parts . host , binaryPath , featureSet )
442
+ await this . updateSSHConfig ( workspaceRestClient , parts . label , parts . host , binaryPath , logDir )
441
443
} catch ( error ) {
442
444
this . storage . writeToCoderOutputChannel ( `Failed to configure SSH: ${ error } ` )
443
445
throw error
@@ -450,7 +452,7 @@ export class Remote {
450
452
return
451
453
}
452
454
disposables . push ( this . showNetworkUpdates ( pid ) )
453
- this . commands . workspaceLogPath = path . join ( this . storage . getLogPath ( ) , `${ pid } .log` )
455
+ this . commands . workspaceLogPath = logDir ? path . join ( logDir , `${ pid } .log` ) : undefined
454
456
} )
455
457
456
458
// Register the label formatter again because SSH overrides it!
@@ -476,20 +478,22 @@ export class Remote {
476
478
}
477
479
478
480
/**
479
- * Format's the --log-dir argument for the ProxyCommand
481
+ * Return the --log-dir argument value for the ProxyCommand. It may be an
482
+ * empty string if the setting is not set or the cli does not support it.
480
483
*/
481
- private async formatLogArg ( featureSet : FeatureSet ) : Promise < string > {
484
+ private getLogDir ( featureSet : FeatureSet ) : string {
482
485
if ( ! featureSet . proxyLogDirectory ) {
483
486
return ""
484
487
}
485
-
486
488
// If the proxyLogDirectory is not set in the extension settings we don't send one.
487
- // Question for Asher: How do VSCode extension settings behave in terms of semver for the extension?
488
- const logDir = expandPath ( String ( vscode . workspace . getConfiguration ( ) . get ( "coder.proxyLogDirectory" ) ?? "" ) . trim ( ) )
489
- if ( ! logDir ) {
490
- return ""
491
- }
489
+ return expandPath ( String ( vscode . workspace . getConfiguration ( ) . get ( "coder.proxyLogDirectory" ) ?? "" ) . trim ( ) )
490
+ }
492
491
492
+ /**
493
+ * Formats the --log-dir argument for the ProxyCommand after making sure it
494
+ * has been created.
495
+ */
496
+ private async formatLogArg ( logDir : string ) : Promise < string > {
493
497
await fs . mkdir ( logDir , { recursive : true } )
494
498
this . storage . writeToCoderOutputChannel ( `SSH proxy diagnostics are being written to ${ logDir } ` )
495
499
return ` --log-dir ${ escape ( logDir ) } `
@@ -502,7 +506,7 @@ export class Remote {
502
506
label : string ,
503
507
hostName : string ,
504
508
binaryPath : string ,
505
- featureSet : FeatureSet ,
509
+ logDir : string ,
506
510
) {
507
511
let deploymentSSHConfig = { }
508
512
try {
@@ -585,7 +589,7 @@ export class Remote {
585
589
Host : label ? `${ AuthorityPrefix } .${ label } --*` : `${ AuthorityPrefix } --*` ,
586
590
ProxyCommand : `${ escape ( binaryPath ) } ${ headerArg } vscodessh --network-info-dir ${ escape (
587
591
this . storage . getNetworkInfoPath ( ) ,
588
- ) } ${ await this . formatLogArg ( featureSet ) } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( label ) ) } --url-file ${ escape (
592
+ ) } ${ await this . formatLogArg ( logDir ) } --session-token-file ${ escape ( this . storage . getSessionTokenPath ( label ) ) } --url-file ${ escape (
589
593
this . storage . getUrlPath ( label ) ,
590
594
) } %h`,
591
595
ConnectTimeout : "0" ,
0 commit comments