dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.57k stars 390 forks source link

builder.AddDaprStateStore error - Dapr is not detecting `actorStateStore` setting #3039

Open ScottArbeit opened 5 months ago

ScottArbeit commented 5 months ago

Hi! I could use another set of eyes on this... I'm converting a Dapr project from Kubernetes to Aspire, and I'm getting Have you set the - name: actorStateStore value: \"true\" in your state store component file?, when, indeed, I have.

AppHost\Program.cs

The relevant bits from AppHost\Program.cs are:

builder.AddDapr(options =>
{
    options.DaprPath = config["DAPR_PATH"];
    options.EnableTelemetry = true;
});

// Add secret store
var secretstore = builder.AddDaprComponent("secretstore", "secretstores.azure.keyvault",
    new DaprComponentOptions { LocalPath = Path.Combine(daprConfigurationPath(), "secretstore - local.yaml") });

// Add actor state store
var actorstorage = builder.AddDaprStateStore("actorstorage",
    new DaprComponentOptions { LocalPath = Path.Combine(daprConfigurationPath(), "actorstorage - local.yaml") });

// Add pub/sub
var graceeventstream = builder.AddDaprPubSub("graceeventstream",
    new DaprComponentOptions { LocalPath = Path.Combine(daprConfigurationPath(), "graceeventstream - local.yaml") });

// etc.

// Add my .NET project
var graceServer = builder.AddProject<Projects.Grace_Server>("grace-server")
    .WithDaprSidecar(new DaprSidecarOptions { ... }) + lots of .WithEnvironment()

builder.Build().Run();

Dapr configuration

I'm configuring the state store with actorstorage - local.yaml, which is identical to what I configure Kubernetes with. I do set actorStateStore in it:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: actorstorage
spec:
  type: state.azure.cosmosdb
  version: v1
  initTimeout: 1m
  metadata:
  - name: actorStateStore    <---- it's right here
    value: "true"            <---- i'm not crazy,  right?
  - name: url
    secretKeyRef:
      name: azurecosmosdburl
      key: azurecosmosdburl
  - name: masterKey
    secretKeyRef:
      name: azurecosmosdbkey
      key: azurecosmosdbkey
  - name: database
    secretKeyRef:
      name: cosmosdatabasename
      key: cosmosdatabasename
  - name: collection
    secretKeyRef:
      name: cosmoscontainername
      key: cosmoscontainername
auth:
  secretStore: secretstore

Dapr starts correctly

The log looks good:

time="2024-03-19T23:29:24.3114502-07:00" level=debug msg="Found component: actorstorage (state.azure.cosmosdb/v1)" app_id=grace-server instance=Workstation scope=dapr.runtime type=log ver=1.13.0
time="2024-03-19T23:29:24.3124999-07:00" level=debug msg="Loading component: actorstorage (state.azure.cosmosdb/v1)" app_id=grace-server instance=Workstation scope=dapr.runtime.processor type=log ver=1.13.0
time="2024-03-19T23:29:25.3526777-07:00" level=debug msg="CosmosDB init start" app_id=grace-server component="actorstorage (state.azure.cosmosdb/v1)" instance=Workstation scope=dapr.contrib type=log ver=1.13.0
time="2024-03-19T23:29:25.5904111-07:00" level=info msg="Component loaded: actorstorage (state.azure.cosmosdb/v1)" app_id=grace-server instance=Workstation scope=dapr.runtime.processor type=log ver=1.13.0
...
time="2024-03-19T23:29:27.442645-07:00" level=info msg="dapr initialized. Status: Running. Init Elapsed 3174ms" app_id=grace-server instance=Workstation scope=dapr.runtime type=log ver=1.13.0

Sad trombone

Unfortunately, when I test my code, I get Have you set the - name: actorStateStore value: \"true\" in your state store component file?" from Dapr:

level=debug msg="api error: code = Internal desc = the state store is not configured to use the actor runtime. Have you set the - name: actorStateStore value: \"true\" in your state store component file?" app_id=grace-server instance=Workstation scope=dapr.runtime.http type=log ver=1.13.0

So...

Is there anything in Aspire's Dapr support that could be causing this?

mitchdenny commented 4 months ago

@philliphoff do you have some bandwidth to take a look at this?

philliphoff commented 4 months ago

@ScottArbeit Would you be able to share a more complete Dapr sidecar log-level debug log? Does it make a difference if you were to use AddDaprComponent("actorstorage", "state.azure.cosmosdb", /* ... */) instead of AddDaprStateStore()?

searus commented 3 months ago

@davidfowl, I'm looking for a way to set this by code.... I thought Aspire was our escape from yaml!

adrobson commented 2 months ago

I can't get any DAPR components from component definitions in a local folder to load either . I am using builder.AddDaprStateStore and builder.AddDaprComponent and neither seems to work.

Is this supposed to work or is it still in progress?

philliphoff commented 2 months ago

I can't get any DAPR components from component definitions in a local folder to load either . I am using builder.AddDaprStateStore and builder.AddDaprComponent and neither seems to work.

@adrobson Can you provide/show a repro project?

adrobson commented 2 months ago

@philliphoff. Ignore my previous question. I can get Dapr components working now. I was not doing it correctly.