Improve error reporting from Kubernetes Publisher
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
Working with the Kubernetes publisher, I hit a number of issues that left me errors that were difficult to action (see #9051 for full context).
Two of the errors I got:
- `Bind mounts are not supported by the Kubernetes publisher`
- `Unsupported value type: Int32`
### Expected Behavior
The above errors could could instead be something like:
- `Kuberentes Publisher does not support the {Path} bind mount on {ResourceName}`
- `Failed to process '{EnvironmentVariable}' environment variable on {ResourceName}.
It would also be nice if the Kubernetes publisher could show me all the errors at once so I can fix them in one go, rather than having to play a game of whack-a-mole to fix one issue, then re-run the publisher to see what fails next.
### Steps To Reproduce
_No response_
### Exceptions (if any)
```
Exception Info: System.AggregateException: One or more errors occurred. (Bind mounts are not supported by the Kubernetes publisher)
---> System.InvalidOperationException: Bind mounts are not supported by the Kubernetes publisher
at Aspire.Hosting.Kubernetes.KubernetesResource.ProcessVolumes() in /_/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs:line 210
at Aspire.Hosting.Kubernetes.KubernetesResource.ProcessResourceAsync(KubernetesEnvironmentContext context, DistributedApplicationExecutionContext executionContext, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs:line 150
at Aspire.Hosting.Kubernetes.KubernetesEnvironmentContext.CreateKubernetesResourceAsync(IResource resource, DistributedApplicationExecutionContext executionContext, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentContext.cs:line 27
at Aspire.Hosting.Kubernetes.KubernetesInfrastructure.BeforeStartAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Kubernetes/KubernetesInfrastructure.cs:line 56
at Aspire.Hosting.DistributedApplication.ExecuteBeforeStartHooksAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/DistributedApplication.cs:line 462
at Aspire.Hosting.DistributedApplication.RunAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/DistributedApplication.cs:line 412
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Aspire.Hosting.DistributedApplication.Run() in /_/src/Aspire.Hosting/DistributedApplication.cs:line 443
at Program.$(String[] args) in REDACTED.AppHost\Program.cs:line 37
```
```
Exception Info: System.AggregateException: One or more errors occurred. (Unsupported value type: Int32)
---> System.NotSupportedException: Unsupported value type: Int32
at Aspire.Hosting.Kubernetes.KubernetesServiceResourceExtensions.ProcessValueAsync(KubernetesResource resource, KubernetesEnvironmentContext context, DistributedApplicationExecutionContext executionContext, Object value) in /_/src/Aspire.Hosting.Kubernetes/KubernetesServiceResourceExtensions.cs:line 92
at Aspire.Hosting.Kubernetes.KubernetesResource.ProcessEnvironmentAsync(KubernetesEnvironmentContext environmentContext, DistributedApplicationExecutionContext executionContext, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs:line 263
at Aspire.Hosting.Kubernetes.KubernetesResource.ProcessResourceAsync(KubernetesEnvironmentContext context, DistributedApplicationExecutionContext executionContext, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs:line 152
at Aspire.Hosting.Kubernetes.KubernetesEnvironmentContext.CreateKubernetesResourceAsync(IResource resource, DistributedApplicationExecutionContext executionContext, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentContext.cs:line 27
at Aspire.Hosting.Kubernetes.KubernetesInfrastructure.BeforeStartAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Kubernetes/KubernetesInfrastructure.cs:line 56
at Aspire.Hosting.DistributedApplication.ExecuteBeforeStartHooksAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/DistributedApplication.cs:line 462
at Aspire.Hosting.DistributedApplication.RunAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/DistributedApplication.cs:line 412
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Aspire.Hosting.DistributedApplication.Run() in /_/src/Aspire.Hosting/DistributedApplication.cs:line 443
at Program.$(String[] args) in REDACTED\Program.cs:line 66
```
### .NET Version info
_No response_
### Anything else?
_No response_
Contributor guide
Research direction
Start with KubernetesResource.cs at ProcessVolumes and ProcessEnvironmentAsync, then read KubernetesServiceResourceExtensions.cs at ProcessValueAsync and the BeforeStartAsync flow in KubernetesInfrastructure.cs. Trace how these failures are surfaced and add the requested resource, mount, and environment-variable context. Done means actionable messages are produced and multiple publisher errors are reported together.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, kubernetes
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100