Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operate state throw exception FailedPrecondition on windows #3344

Closed
doddgu opened this issue Jun 24, 2021 · 16 comments
Closed

Operate state throw exception FailedPrecondition on windows #3344

doddgu opened this issue Jun 24, 2021 · 16 comments

Comments

@doddgu
Copy link

doddgu commented Jun 24, 2021

In what area(s)?

/area runtime

What version of Dapr?

1.2.0
edge: output of git describe --dirty

Expected Behavior

Get state success.

Actual Behavior

OS: Windows 10 19042.1052
Mode: Self hosted

Note: I run the .net program on windows, not docker.

await _client.SaveStateAsync("statestore", key, value);

RpcException: Status(StatusCode="FailedPrecondition", Detail="state store is not configured")

image

image

Steps to Reproduce the Problem

Release Note

RELEASE NOTE:

@doddgu doddgu added the kind/bug Something isn't working label Jun 24, 2021
@doddgu
Copy link
Author

doddgu commented Jun 25, 2021

time="2021-06-25T10:09:09.8998877+08:00" level=warning msg="failed to init actors: actors: couldn't connect to placement service: address is empty" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime type=log ver=1.2.2

@doddgu
Copy link
Author

doddgu commented Jun 25, 2021

I set actorStateStore value to false, it still throw this exception.

@doddgu
Copy link
Author

doddgu commented Jun 25, 2021

I run daprd with -placement-host-address localhost:6050 parameter, then placement is working.

time="2021-06-25T12:11:30.6241137+08:00" level=debug msg="try to connect to placement service: dns:///localhost:6050" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-06-25T12:11:30.7224674+08:00" level=debug msg="established connection to placement service at dns:///localhost:6050" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-06-25T12:11:30.7245891+08:00" level=debug msg="placement order received: lock" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-06-25T12:11:30.7245891+08:00" level=debug msg="placement order received: update" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-06-25T12:11:30.7245891+08:00" level=info msg="placement tables updated, version: 0" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-06-25T12:11:30.7245891+08:00" level=debug msg="placement order received: unlock" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2

@msfussell
Copy link
Member

@doddgu - Can you summarize this issue. Are you saying that setting actorStateStore false should not result in needing the Placement service running, since so actors are being created? Or are you saying that the SaveStateAsync needs to have the Placement service running?

What exactly is the bug that you are reporting here?

@doddgu
Copy link
Author

doddgu commented Jun 25, 2021

@doddgu - Can you summarize this issue. Are you saying that setting actorStateStore false should not result in needing the Placement service running, since so actors are being created? Or are you saying that the SaveStateAsync needs to have the Placement service running?

What exactly is the bug that you are reporting here?

I want to run daprd on windows, not in docker.
So I start daprd in my .net program, the invocation can run but the state can't.

I think these are two questions, and the first I resolved.

  1. Run daprd must with -placement-host-address localhost:6050, it will resove below log's problem. Document does not give clear instructions, on Windows OS and self hosted mode how to do is correct.
time="2021-06-25T10:09:09.8998877+08:00" level=warning msg="failed to init actors: actors: couldn't connect to placement service: address is empty" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime type=log ver=1.2.2
  1. I resolved all warning, the problem still exsists.
    Log:
time="2021-06-25T13:31:42.8689126+08:00" level=debug msg="rpc error: code = FailedPrecondition desc = state store is not configured" app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime.grpc.api type=log ver=1.2.2

I found where the exception throw, but I don't know why.

if a.stateStores == nil || len(a.stateStores) == 0 {
    return nil, status.Error(codes.FailedPrecondition, messages.ErrStateStoresNotConfigured)
}

statestore.yaml

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: statestore
spec:
  type: state.redis
  version: v1
  metadata:
  - name: redisHost
    value: localhost:6379
  - name: redisPassword
    value: ""
  - name: actorStateStore
    value: "true"

@doddgu
Copy link
Author

doddgu commented Jun 25, 2021

I found another warning

time="2021-06-25T16:42:55.5863835+08:00" level=warning msg="failed to load components: open : The system cannot find the file specified." app_id=masa-dcc-service-admin instance=SSHZ014 scope=dapr.runtime type=log ver=1.2.2

@doddgu
Copy link
Author

doddgu commented Jun 25, 2021

@msfussell I resolved, but I'm not sure it's a bug. Two parameters can resolve it.

  1. -placement-host-address localhost:6050
    dapr init on windows set placement port to 6050, isn't 50005.
  2. -components-path C:\Users\YourComputerName\.dapr\components
    dapr on windows find component logic maybe correct, I'm not sure. But I run daprd in .net program, working directory changed.

@wcs1only
Copy link
Contributor

wcs1only commented Jun 25, 2021

So, when running in standalone mode, generally the dapr run command will take care of setting -components-path for you. I'm interested to hear about your use case for this, are you taking this approach to specifically avoid using docker containers?

Once dapr/cli#746 is merged and released, would that be sufficient to unblock you using dapr run, and therefore resolve this issue for you?

@doddgu
Copy link
Author

doddgu commented Jun 26, 2021

So, when running in standalone mode, generally the dapr run command will take care of setting -components-path for you. I'm interested to hear about your use case for this, are you taking this approach to specifically avoid using docker containers?

Once dapr/cli#746 is merged and released, would that be sufficient to unblock you using dapr run, and therefore resolve this issue for you?

Q: are you taking this approach to specifically avoid using docker containers
A: Yes, I use .net program start daprd imitate inject sidecar. I solved the problem use %USERPROFILE%.dapr\components in my starter config, and before start, I replace %USERPROFILE% to absolute path. It is best if daprd can get the user directory by default during starting.

Q: Once dapr/cli#746 is merged and released, would that be sufficient to unblock you using dapr run, and therefore resolve this issue for you?
A:

The format of --placement-host-address argument is either <hostname> or <hostname>:<port>. If the port is omitted, the default port 6050 for Windows and 50005 for Linux/MacOS applies.
// if placementHostAddr does not contain port, add default port value

I'm not sure that will solve the problem completely.
Here is how I solved the problem.

The first warning I saw was couldn't connect to placement service: address is empty, it prompted empty, not timeout.
So I set --placement-host-address localhost 50005, then it prompted another timeout warning.
Then I set --placement-host-address localhost 6050, there's no warning again.
I think in standalone mode on windows, set default address localhost:6050 is better than only set default port? In this way, users can get the same experience as on k8s.

@doddgu
Copy link
Author

doddgu commented Jun 26, 2021

if indx := strings.Index(placementHostAddr, ":"); indx == -1

Before it, I think need set placementHostAddr := "localhost" if placementHostAddr is nil. But, I'm not sure the address is empty warning is before or after this.

if placementHostAddr == nil {
    placementHostAddr := "localhost"
}

if indx := strings.Index(placementHostAddr, ":"); indx == -1

@doddgu
Copy link
Author

doddgu commented Jun 26, 2021

The --placement-host-address argument now accepts optional port number. Syntax: --placement-host-address <hostname>[:<port>]

I think it need to be [<hostname>][:<port>], and default hostname is localhost. It will solve this problem.

@wcs1only
Copy link
Contributor

wcs1only commented Jul 2, 2021

So once the dapr/cli#746 is merged and released you would accomplish what you want with the following:

 dapr run --placement-host-address localhost:50005

Until that is merged, you can actually start the placement service on the Windows port (provided you don't have a service running on 6050):

%USERPROFILE%\.dapr\bin\placement.exe -port 6050

Then if you use the CLI to run dapr, it will automatically set the components directory and the correct port:

dapr run --log-level debug
...
time="2021-07-02T02:37:16.918283Z" level=debug msg="try to connect to placement service: dns:///localhost:6050" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.9197732Z" level=info msg="dapr initialized. Status: Running. Init Elapsed 31.9476ms" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime type=log ver=1.2.2
time="2021-07-02T02:37:16.9626896Z" level=debug msg="established connection to placement service at dns:///localhost:6050" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.9723825Z" level=debug msg="placement order received: lock" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.974748Z" level=debug msg="placement order received: update" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.9763139Z" level=info msg="placement tables updated, version: 0" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.9763139Z" level=debug msg="placement order received: unlock" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
Checking if Dapr sidecar is listening on GRPC port 61055
Dapr sidecar is up and running.
You're up and running! Dapr logs will appear here.

@doddgu
Copy link
Author

doddgu commented Jul 2, 2021

So once the dapr/cli#746 is merged and released you would accomplish what you want with the following:

 dapr run --placement-host-address localhost:50005

Until that is merged, you can actually start the placement service on the Linux port (provided you don't have a service running on 6050):

%USERPROFILE%\.dapr\bin\placement.exe -port 6050

Then if you use the CLI to run dapr, it will automatically set the components directory and the correct port:

dapr run --log-level debug
...
time="2021-07-02T02:37:16.918283Z" level=debug msg="try to connect to placement service: dns:///localhost:6050" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.9197732Z" level=info msg="dapr initialized. Status: Running. Init Elapsed 31.9476ms" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime type=log ver=1.2.2
time="2021-07-02T02:37:16.9626896Z" level=debug msg="established connection to placement service at dns:///localhost:6050" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.9723825Z" level=debug msg="placement order received: lock" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.974748Z" level=debug msg="placement order received: update" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.9763139Z" level=info msg="placement tables updated, version: 0" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
time="2021-07-02T02:37:16.9763139Z" level=debug msg="placement order received: unlock" app_id=Shriekprong-Kangaroo instance=Win2 scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
Checking if Dapr sidecar is listening on GRPC port 61055
Dapr sidecar is up and running.
You're up and running! Dapr logs will appear here.

So, I should use dapr run, rather than daprd, I will try it.

@wcs1only
Copy link
Contributor

wcs1only commented Jul 3, 2021

Where you following this guide?:

https://docs.dapr.io/operations/hosting/self-hosted/self-hosted-no-docker/

I think this doc needs an update to reflect that the placement server needs a different port on Windows.

@doddgu
Copy link
Author

doddgu commented Jul 3, 2021

Where you following this guide?:

https://docs.dapr.io/operations/hosting/self-hosted/self-hosted-no-docker/

I think this doc needs an update to reflect that the placement server needs a different port on Windows.

I use the warning message, and then look up the source code to locate the problem.
But I'm not familiar with golang, so it took me some time.

@dapr-bot
Copy link
Collaborator

dapr-bot commented Aug 2, 2021

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 dapr-bot added stale Issues and PRs without response and removed stale Issues and PRs without response labels Aug 2, 2021
@doddgu doddgu closed this as completed Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants