microsoft / microsoft/aspire

Improve Kubernetes watch errors

Open
#14,514 0 comments 0 reactions 1 assignee Claimed by @karolz-ms View on GitHub
area-app-model
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

### Is your feature request related to a problem? Please describe the problem.

One of my app hosts is giving the below error, but I have no idea where to start troubleshooting it - as it's happening within the context of a specific resource, I would hope that the error would tell me which resource is being problematic.

```
crit: Aspire.Hosting.Dcp.DcpExecutor[0]
Watch task over Kubernetes Service resources terminated unexpectedly.
System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at Aspire.Hosting.Dcp.ResourceSnapshotBuilder.GetUrls(CustomResource resource, String resourceState)
at Aspire.Hosting.Dcp.ResourceSnapshotBuilder.ToSnapshot(Container container, CustomResourceSnapshot previous) in /_/src/Aspire.Hosting/Dcp/ResourceSnapshotBuilder.cs:line 23
at Aspire.Hosting.Dcp.DcpExecutor.<>c__DisplayClass57_0.b__0(CustomResourceSnapshot s) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 739
at Aspire.Hosting.ApplicationModel.ResourceNotificationService.PublishUpdateAsync(IResource resource, String resourceId, Func`2 stateFactory) in /_/src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs:line 600
at Aspire.Hosting.Orchestrator.ApplicationOrchestrator.OnResourceChanged(OnResourceChangedContext context) in /_/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs:line 407
at Aspire.Hosting.Dcp.DcpExecutorEvents.PublishAsync[T](T context) in /_/src/Aspire.Hosting/Dcp/DcpExecutorEvents.cs:line 33
at Aspire.Hosting.Dcp.DcpExecutor.TryRefreshResource(String resourceKind, String resourceName) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 735
at Aspire.Hosting.Dcp.DcpExecutor.ProcessServiceChange(WatchEventType watchEventType, Service service) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 713
at Aspire.Hosting.Dcp.DcpExecutor.<>c__DisplayClass47_1`1.<b__15>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 398
--- End of stack trace from previous location ---
at Aspire.Hosting.Dcp.DcpExecutor.<>c__DisplayClass47_1`1.<b__15>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 392
--- End of stack trace from previous location ---
at Polly.ResiliencePipeline.<>c.<b__3_0>d.MoveNext()
--- End of stack trace from previous location ---
at Polly.Outcome`1.GetResultOrRethrow()
at Polly.ResiliencePipeline.ExecuteAsync(Func`2 callback, CancellationToken cancellationToken)
at Aspire.Hosting.Dcp.DcpExecutor.<>c__DisplayClass47_0.<g__WatchKubernetesResourceAsync|3>d`1.MoveNext() in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 390
```

### Describe the solution you'd like

I'd hope the error could at least let me know which resource is problematic. Perhaps rather than appearing in the main app host console window, this error should be logged against a specific resource through `ResourceLoggerService`

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.