dapr / cli

Command-line tools for Dapr.
Apache License 2.0
318 stars 202 forks source link

`dapr run` assigns the same port to `HTTP` and `gRPC` interface, fails to start #1382

Closed antbern closed 5 months ago

antbern commented 7 months ago

Expected Behavior

dapr run assigns two random free ports to the HTTP and gRPC interfaces, respectively, and starts without problems.

Actual Behavior

When only specifying an app gRPC port, and no dapr ports, it seems dapr run does not check for collisions when randomly assigning a port to the HTTP and gRPC interface, causing a crash when it fails to bind to the same port the second time.

In the Logs one can see that the HTTP and gRPC ports were assigned to be the same:

Logs

``` dapr run --app-protocol grpc --app-port 35500 ./service ℹ️ Starting Dapr with id service. HTTP Port: 45069. gRPC Port: 45069 time="2024-02-06T15:06:42.642615391Z" level=info msg="Starting Dapr Runtime -- version 1.12.4 -- commit e51e5cd3b1af27aef81daaf42530c232bf2b1594" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.642643448Z" level=info msg="Log level set to: info" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.644048223Z" level=warning msg="mTLS is disabled. Skipping certificate request and tls validation" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.security type=log ver=1.12.4 time="2024-02-06T15:06:42.64666133Z" level=info msg="metrics server started on :45177/" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.647044981Z" level=info msg="standalone mode configured" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.647083196Z" level=info msg="app id: service" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.647147099Z" level=info msg="Dapr trace sampler initialized: DaprTraceSampler(P=0.000100)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.647452474Z" level=info msg="local service entry announced: service -> 172.18.0.6:39709" app_id=service component="mdns (nameResolution/v1)" instance=6c38cb4471e1 scope=dapr.contrib type=log ver=1.12.4 time="2024-02-06T15:06:42.64748083Z" level=info msg="Initialized name resolution to mdns" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.647539491Z" level=info msg="Loading components…" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.650049682Z" level=info msg="Component loaded: secretstore (secretstores.local.file/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.650142293Z" level=info msg="successful init for input binding (crontimer (bindings.cron/v1))" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.processor.binding type=log ver=1.12.4 time="2024-02-06T15:06:42.650172439Z" level=info msg="Component loaded: crontimer (bindings.cron/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.678344825Z" level=info msg="Connected to MongoDB without a replica set. Transactions are not available, and the component cannot be used as actor state store." app_id=service component="customerstore (state.mongodb/v1)" instance=6c38cb4471e1 scope=dapr.contrib type=log ver=1.12.4 time="2024-02-06T15:06:42.678421755Z" level=info msg="Component loaded: customerstore (state.mongodb/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.680443199Z" level=info msg="Component loaded: pubsub (pubsub.redis/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.682801698Z" level=info msg="Using 'statestore' as actor state store" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.processor.state type=log ver=1.12.4 time="2024-02-06T15:06:42.682922274Z" level=info msg="Component loaded: statestore (state.redis/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.6830743Z" level=info msg="Waiting for all outstanding components to be processed…" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.697456773Z" level=info msg="Connected to MongoDB without a replica set. Transactions are not available, and the component cannot be used as actor state store." app_id=service component="taxstore (state.mongodb/v1)" instance=6c38cb4471e1 scope=dapr.contrib type=log ver=1.12.4 time="2024-02-06T15:06:42.697500281Z" level=info msg="Component loaded: taxstore (state.mongodb/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.697524233Z" level=info msg="All outstanding components processed" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.697535814Z" level=info msg="Loading endpoints…" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.698318158Z" level=info msg="Waiting for all outstanding http endpoints to be processed…" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.698338631Z" level=info msg="All outstanding http endpoints processed" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.698770801Z" level=info msg="gRPC server listening on TCP address: :45069" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.grpc.api type=log ver=1.12.4 time="2024-02-06T15:06:42.698791418Z" level=info msg="Enabled gRPC tracing middleware" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.grpc.api type=log ver=1.12.4 time="2024-02-06T15:06:42.698801127Z" level=info msg="Enabled gRPC metrics middleware" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.grpc.api type=log ver=1.12.4 time="2024-02-06T15:06:42.698851424Z" level=info msg="Registering workflow engine for gRPC endpoint: [::]:45069" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.grpc.api type=log ver=1.12.4 time="2024-02-06T15:06:42.698887089Z" level=info msg="API gRPC server is running on port 45069" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.698995489Z" level=info msg="Enabled max body size HTTP middleware with size 4 MB" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.http type=log ver=1.12.4 time="2024-02-06T15:06:42.699017551Z" level=info msg="Enabled tracing HTTP middleware" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.http type=log ver=1.12.4 time="2024-02-06T15:06:42.699027264Z" level=info msg="Enabled metrics HTTP middleware" app_id=service instance=6c38cb4471e1 scope=dapr.runtime.http type=log ver=1.12.4 time="2024-02-06T15:06:42.700277371Z" level=info msg="Dapr is shutting down" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.7003264Z" level=info msg="Shutting down component taxstore (state.mongodb/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.700351182Z" level=info msg="Shutting down component pubsub (pubsub.redis/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.701024933Z" level=info msg="Shutting down component customerstore (state.mongodb/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.700359779Z" level=info msg="Shutting down component statestore (state.redis/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.70033733Z" level=info msg="Shutting down component secretstore (secretstores.local.file/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.700330937Z" level=info msg="Shutting down component crontimer (bindings.cron/v1)" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.701215689Z" level=info msg="Dapr runtime stopped" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.700173125Z" level=info msg="Shutting down workflow engine" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 time="2024-02-06T15:06:42.702079794Z" level=info msg="stopping mDNS server for app id: service" app_id=service component="mdns (nameResolution/v1)" instance=6c38cb4471e1 scope=dapr.contrib type=log ver=1.12.4 time="2024-02-06T15:06:42.702968465Z" level=fatal msg="Fatal error from runtime: failed to start HTTP server: could not listen on any endpoint" app_id=service instance=6c38cb4471e1 scope=dapr.runtime type=log ver=1.12.4 ❌ The daprd process exited with error code: exit status 1 ```

Steps to Reproduce the Problem

Due to the random nature of port assignments, I suspect it is quite difficult to reproduce 😕

Release Note

RELEASE NOTE:

dapr-bot commented 6 months ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

antbern commented 6 months ago

As far as I know this is still an issue and has to do with the way dapr assigns free ports individually and not together, making it possible that the same port is reused.

dapr-bot commented 5 months ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot commented 5 months ago

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.