Skip to content

Don't use a shared session folder.#7398

Merged
eerhardt merged 1 commit intomainfrom
davidfowl/dcp-session
Feb 4, 2025
Merged

Don't use a shared session folder.#7398
eerhardt merged 1 commit intomainfrom
davidfowl/dcp-session

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

  • Each session should have a different folder for maximum isolation. We'll need a different strategy here.

Saw this on a CI run:

[apphost]       System.IO.IOException: The process cannot access the file 'C:\h\w\AC440968\t\aspire.4tqrtr31.dfj\kubeconfig' because it is being used by another process.
[apphost]          at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
[apphost]          at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode) [apphost]          at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode)
[apphost]          at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode) [apphost]          at System.IO.FileInfo.OpenRead() [apphost]          at k8s.KubernetesClientConfiguration.LoadKubeConfigAsync(FileInfo kubeconfig, Boolean useRelativePaths) [apphost]          at k8s.KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(FileInfo kubeconfig, String currentContext, String masterUrl, Boolean useRelativePaths) [apphost]          at Aspire.Hosting.Dcp.KubernetesService.<>c__DisplayClass30_0.<<EnsureKubernetesAsync>b__0>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 482 [apphost]       --- End of stack trace from previous location --- [apphost]          at Polly.ResiliencePipeline.<>c__101.<<ExecuteAsync>b__10_0>d.MoveNext()
[apphost]       --- End of stack trace from previous location ---
[apphost]          at Polly.Outcome1.GetResultOrRethrow() [apphost]          at Polly.ResiliencePipeline.ExecuteAsync[TResult](Func2 callback, CancellationToken cancellationToken)
[apphost]          at Aspire.Hosting.Dcp.KubernetesService.EnsureKubernetesAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/KubernetesService.cs:line 473
[apphost]          at Aspire.Hosting.Dcp.KubernetesService.ExecuteWithRetry[TResult](DcpApiOperationType operationType, String resourceType, Func2 operation, Func2 isRetryable, CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/KubernetesService.cs:line 388
[apphost]          at Aspire.Hosting.Dcp.DcpExecutor.CreateResourcesAsync[RT](CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 1453
[apphost]          at Aspire.Hosting.Dcp.DcpExecutor.CreateServicesAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 585
[apphost]          at Aspire.Hosting.Dcp.DcpExecutor.RunApplicationAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 126
[apphost]          at Aspire.Hosting.Orchestrator.ApplicationOrchestrator.RunApplicationAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs:line 170
[apphost]          at Aspire.Hosting.Orchestrator.OrchestratorHostService.StartAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Orchestrator/OrchestratorHostService.cs:line 41
[apphost]          at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token)
[apphost]          at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List1 exceptions, Func3 operation) [apphost] [createdump] Writing full dump for process 840 to file C:\h\w\AC440968\t\86e8bb74-3544-4ffd-81be-60ad04eed6c4\aspire_starter_run_Release_ya3dkuw0_rq4.AppHost.exe_840_1738616051_crashdump.dmp [apphost] [createdump] Dump successfully written in 441ms [apphost] Unhandled exception. System.AggregateException: One or more errors occurred. (The process cannot access the file 'C:\h\w\AC440968\t\aspire.4tqrtr31.dfj\kubeconfig' because it is being used by another process.) [apphost]  ---> System.IO.IOException: The process cannot access the file 'C:\h\w\AC440968\t\aspire.4tqrtr31.dfj\kubeconfig' because it is being used by another process. [apphost]    at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options) [apphost]    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode)
[apphost]    at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode) [apphost]    at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode)
[apphost]    at System.IO.FileInfo.OpenRead()
[apphost]    at k8s.KubernetesClientConfiguration.LoadKubeConfigAsync(FileInfo kubeconfig, Boolean useRelativePaths)
[apphost]    at k8s.KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(FileInfo kubeconfig, String currentContext, String masterUrl, Boolean useRelativePaths)
[apphost]    at Aspire.Hosting.Dcp.KubernetesService.<>c__DisplayClass30_0.<<EnsureKubernetesAsync>b__0>d.MoveNext() in //src/Aspire.Hosting/Dcp/KubernetesService.cs:line 482
[apphost] --- End of stack trace from previous location ---
[apphost]    at Polly.ResiliencePipeline.<>c__101.<<ExecuteAsync>b__10_0>d.MoveNext() [apphost] --- End of stack trace from previous location --- [apphost]    at Polly.Outcome1.GetResultOrRethrow()
[apphost]    at Polly.ResiliencePipeline.ExecuteAsync[TResult](Func2 callback, CancellationToken cancellationToken) [apphost]    at Aspire.Hosting.Dcp.KubernetesService.EnsureKubernetesAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 473 [apphost]    at Aspire.Hosting.Dcp.KubernetesService.ExecuteWithRetry[TResult](DcpApiOperationType operationType, String resourceType, Func2 operation, Func2 isRetryable, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 388 [apphost]    at Aspire.Hosting.Dcp.DcpExecutor.CreateResourcesAsync[RT](CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 1453 [apphost]    at Aspire.Hosting.Dcp.DcpExecutor.CreateServicesAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 585 [apphost]    at Aspire.Hosting.Dcp.DcpExecutor.RunApplicationAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 126 [apphost]    at Aspire.Hosting.Orchestrator.ApplicationOrchestrator.RunApplicationAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs:line 170 [apphost]    at Aspire.Hosting.Orchestrator.OrchestratorHostService.StartAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Orchestrator/OrchestratorHostService.cs:line 41 [apphost]    at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token) [apphost]    at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List1 exceptions, Func3 operation)
[apphost]    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
[apphost]    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
[apphost]    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
[apphost]    at Aspire.Hosting.DistributedApplication.RunAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/DistributedApplication.cs:line 311
[apphost]    --- End of inner exception stack trace ---
[apphost]    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
[apphost]    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
[apphost]    at System.Threading.Tasks.Task.Wait()
[apphost]    at Aspire.Hosting.DistributedApplication.Run() in //src/Aspire.Hosting/DistributedApplication.cs:line 339
[apphost]    at Program.<Main>$(String[] args) in C:\h\w\AC440968\t\templates-testroot\aspire_starter_run_Release_ya3dkuw0_rq4\aspire_starter_run_Release_ya3dkuw0_rq4.AppHost\Program.cs:line 16

- Each session should have a different folder for maximum isolation. We'll need a different strategy here.
@eerhardt
Copy link
Copy Markdown
Member

eerhardt commented Feb 4, 2025

I don't understand this change. The error is:

The process cannot access the file 'C:\h\w\AC440968\t\aspire.4tqrtr31.dfj\kubeconfig'

Seems to be coming from this code:

https://github.com/dotnet/aspire/blob/c1c96662138475a786e85285a4782b44bed64013/src/Aspire.Hosting/Dcp/KubernetesService.cs#L475-L482

Which gets its path from:

https://github.com/dotnet/aspire/blob/c1c96662138475a786e85285a4782b44bed64013/src/Aspire.Hosting/Dcp/Locations.cs#L10-L20

So I'm not sure how this change is related to the stated error.

@davidfowl
Copy link
Copy Markdown
Contributor Author

You're right. Still @karolz-ms should we disable this in general to avoid potential conflicts?

@karolz-ms
Copy link
Copy Markdown
Contributor

@davidfowl I think so, yes. DCP was not designed to share the session folder between multiple instances.

@karolz-ms
Copy link
Copy Markdown
Contributor

I see the DCP logs remain captured properly with this change, so :shipit:

@eerhardt eerhardt merged commit 875b175 into main Feb 4, 2025
@eerhardt eerhardt deleted the davidfowl/dcp-session branch February 4, 2025 17:40
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 7, 2025
@github-actions github-actions Bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants