Invalid endpoint should fail to start resource
- 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
There are some conditions in which you can call `WithEndpoint()` on a resource, and yet the endpoint doesn't actually show up on the resource.
If you look at your console logs, you can see a `information about the port to expose the service is missing; service-producer annotation is invalid` error. This really feels like a terminal error hat should have caused the resource to fail to start.
```
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 5, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
info: Aspire.Hosting.DistributedApplication[0]
Now listening on: https://localhost:17092
info: Aspire.Hosting.DistributedApplication[0]
Login to the dashboard at https://localhost:17092/login?t=cdf72f9e243048c16667f35392b595fd
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 7, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 9, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
info: Aspire.Hosting.DistributedApplication[0]
Distributed application started. Press Ctrl+C to shut down.
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 41, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 42, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 43, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 55, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 56, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ExecutableReconciler[0]
Could not create Endpoint object {"Executable": "/pwsh-ygptcvwe", "Reconciliation": 57, "ServiceName": "pwsh", "Workload": "/pwsh-ygptcvwe", "error": "information about the port to expose the service is missing; service-producer annotation is invalid"}
```
### Expected Behavior
I'd expect this to fail either at `Build()` time, or at minimum do something to cause the resource to fail to start. (and I was sure this used to be the case in previous versions of Aspire)
Also for an unrecoverable error, does it need to repeatedly spam the logs with the error?
### Steps To Reproduce
```
builder.AddExecutable("pwsh", "pwsh", ".")
.WithArgs("-Command", "start-sleep -seconds 99999")
.WithHttpEndpoint();
```
### Exceptions (if any)
_No response_
### .NET Version info
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.