@@ -270,24 +270,15 @@ private async Task ApplyContext(HostAssignmentContext assignmentContext)
270
270
}
271
271
else if ( ! string . IsNullOrEmpty ( assignmentContext . AzureFilesConnectionString ) )
272
272
{
273
- ApplyAzureFilesContext ( assignmentContext . AzureFilesConnectionString , assignmentContext . AzureFilesContentShare , "/home" ) ;
273
+ await MountCifs ( assignmentContext . AzureFilesConnectionString , assignmentContext . AzureFilesContentShare , "/home" ) ;
274
274
}
275
275
}
276
276
277
- private void ApplyAzureFilesContext ( string connectionString , string contentShare , string targetPath )
278
- {
279
- var sa = CloudStorageAccount . Parse ( connectionString ) ;
280
- var key = Convert . ToBase64String ( sa . Credentials . ExportKey ( ) ) ;
281
-
282
- var mountCommand = $ "mount -t cifs //{ sa . FileEndpoint . Host } /{ contentShare } { targetPath } -o vers=3.0,username={ sa . Credentials . AccountName } ,password={ key } ,dir_mode=0777,file_mode=0777,serverino";
283
- RunBashCommand ( $ "(mkdir -p { targetPath } || true) && ({ mountCommand } ) && (mkdir -p /home/site/wwwroot || true)", MetricEventNames . LinuxContainerSpecializationAzureFilesMount ) ;
284
- }
285
-
286
277
private async Task ApplyBlobPackageContext ( RunFromPackageContext pkgContext , string targetPath )
287
278
{
288
279
// download zip and extract
289
280
var filePath = await Download ( pkgContext ) ;
290
- UnpackPackage ( filePath , targetPath , pkgContext ) ;
281
+ await UnpackPackage ( filePath , targetPath , pkgContext ) ;
291
282
292
283
string bundlePath = Path . Combine ( targetPath , "worker-bundle" ) ;
293
284
if ( Directory . Exists ( bundlePath ) )
@@ -368,7 +359,7 @@ private void AriaDownload(string directory, string fileName, Uri zipUri)
368
359
_logger . LogInformation ( $ "{ fileInfo . Length } bytes downloaded") ;
369
360
}
370
361
371
- private void UnpackPackage ( string filePath , string scriptPath , RunFromPackageContext pkgContext )
362
+ private async Task UnpackPackage ( string filePath , string scriptPath , RunFromPackageContext pkgContext )
372
363
{
373
364
CodePackageType packageType ;
374
365
using ( _metricsLogger . LatencyEvent ( MetricEventNames . LinuxContainerSpecializationGetPackageType ) )
@@ -385,15 +376,15 @@ private void UnpackPackage(string filePath, string scriptPath, RunFromPackageCon
385
376
}
386
377
else
387
378
{
388
- MountFsImage ( filePath , scriptPath ) ;
379
+ await MountFuse ( "squashfs" , filePath , scriptPath ) ;
389
380
}
390
381
}
391
382
else if ( packageType == CodePackageType . Zip )
392
383
{
393
384
// default to unzip for zip packages
394
385
if ( _environment . IsMountEnabled ( ) )
395
386
{
396
- MountZipFile ( filePath , scriptPath ) ;
387
+ await MountFuse ( "zip" , filePath , scriptPath ) ;
397
388
}
398
389
else
399
390
{
@@ -451,40 +442,35 @@ private void UnzipPackage(string filePath, string scriptPath)
451
442
}
452
443
453
444
private void UnsquashImage ( string filePath , string scriptPath )
454
- => RunBashCommand ( $ "(mkdir -p ' { scriptPath } ' || true) && unsquashfs -f -d '{ scriptPath } ' '{ filePath } '", MetricEventNames . LinuxContainerSpecializationUnsquash ) ;
445
+ => RunBashCommand ( $ "unsquashfs -f -d '{ scriptPath } ' '{ filePath } '", MetricEventNames . LinuxContainerSpecializationUnsquash ) ;
455
446
456
- private void MountFsImage ( string filePath , string scriptPath )
457
- => RunFuseMount ( $ "squashfuse_ll -o nonempty '{ filePath } ' '{ scriptPath } '", scriptPath ) ;
447
+ private async Task MountFuse ( string type , string filePath , string scriptPath )
448
+ => await Mount ( new [ ]
449
+ {
450
+ new KeyValuePair < string , string > ( "operation" , type ) ,
451
+ new KeyValuePair < string , string > ( "filePath" , filePath ) ,
452
+ new KeyValuePair < string , string > ( "targetPath" , scriptPath ) ,
453
+ } ) ;
458
454
459
- private void MountZipFile ( string filePath , string scriptPath )
460
- => RunFuseMount ( $ "fuse-zip -o nonempty -r '{ filePath } ' '{ scriptPath } '", scriptPath ) ;
455
+ private async Task MountCifs ( string connectionString , string contentShare , string targetPath )
456
+ {
457
+ var sa = CloudStorageAccount . Parse ( connectionString ) ;
458
+ var key = Convert . ToBase64String ( sa . Credentials . ExportKey ( ) ) ;
459
+ await Mount ( new [ ]
460
+ {
461
+ new KeyValuePair < string , string > ( "operation" , "cifs" ) ,
462
+ new KeyValuePair < string , string > ( "host" , sa . FileEndpoint . Host ) ,
463
+ new KeyValuePair < string , string > ( "accountName" , sa . Credentials . AccountName ) ,
464
+ new KeyValuePair < string , string > ( "accountKey" , key ) ,
465
+ new KeyValuePair < string , string > ( "contentShare" , contentShare ) ,
466
+ new KeyValuePair < string , string > ( "targetPath" , targetPath ) ,
467
+ } ) ;
468
+ }
461
469
462
- private void RunFuseMount ( string mountCommand , string targetPath )
470
+ private async Task Mount ( IEnumerable < KeyValuePair < string , string > > formData )
463
471
{
464
- using ( _metricsLogger . LatencyEvent ( MetricEventNames . LinuxContainerSpecializationFuseMount ) )
465
- {
466
- var bashCommand = $ "(mknod /dev/fuse c 10 229 || true) && (mkdir -p '{ targetPath } ' || true) && ({ mountCommand } )";
467
- var process = new Process
468
- {
469
- StartInfo = new ProcessStartInfo
470
- {
471
- FileName = "bash" ,
472
- Arguments = $ "-c \" { bashCommand } \" ",
473
- RedirectStandardOutput = true ,
474
- RedirectStandardError = true ,
475
- UseShellExecute = false ,
476
- CreateNoWindow = true
477
- }
478
- } ;
479
- _logger . LogInformation ( $ "Running: { process . StartInfo . FileName } { process . StartInfo . Arguments } ") ;
480
- process . Start ( ) ;
481
- var output = process . StandardOutput . ReadToEnd ( ) ;
482
- var error = process . StandardError . ReadToEnd ( ) ;
483
- process . WaitForExit ( ) ;
484
- _logger . LogInformation ( $ "Output: { output } ") ;
485
- _logger . LogInformation ( $ "error: { output } ") ;
486
- _logger . LogInformation ( $ "exitCode: { process . ExitCode } ") ;
487
- }
472
+ var res = await _client . PostAsync ( _environment . GetEnvironmentVariable ( EnvironmentSettingNames . MeshInitURI ) , new FormUrlEncodedContent ( formData ) ) ;
473
+ _logger . LogInformation ( "Response {res} from init" , res ) ;
488
474
}
489
475
490
476
private ( string , string , int ) RunBashCommand ( string command , string metricName )
0 commit comments