dotnet-sdk icon indicating copy to clipboard operation
dotnet-sdk copied to clipboard

No option to shut down the side car

Open VenkateshSrini opened this issue 2 years ago • 6 comments

Expected Behavior

When using Dapr with Kubernetes Job it is advised by the documentation that we should call the shutdown endpoint either using the Dapr SDK or using the command option in deployment. The reference to the document is attached herewith (https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-job/). The Dapr SDK at present does not have a shutdown method. The "dispose" method does not shut down the Sidecar

Actual Behavior

We need a method to shutdown the side car

Steps to Reproduce the Problem

Run the yaml below. The job will not get completed at all. This is because there is no Shutdown method in SDK apiVersion: batch/v1 kind: Job metadata: creationTimestamp: null name: dapr-state-job namespace: m2c-steeltoe spec: template: metadata: creationTimestamp: null annotations: dapr.io/enabled: "true" dapr.io/app-id: "dapr-state-job" dapr.io/enable-api-logging: "true" spec: containers: - image: venkateshsrini3/dapr-state-job name: dapr-state-job #command: ["sh", "-c","apt-get update && apt-get -y install curl && dotnet dapr.state.console.dll && curl -X POST localhost:3500/v1.0/shutdown"] env: - name: "State.Store" value: "mongo-cache-store" restartPolicy: Never

Release Note

Add an method called hutdown in SDK

ADD

RELEASE NOTE:

VenkateshSrini avatar Jul 29 '22 05:07 VenkateshSrini

@VenkateshSrini - Thanks for opening this issue. This does seem to be something we're missing, but it should be easy to add.

halspang avatar Jul 29 '22 16:07 halspang

@halspang , I think this is a somewhat very painful issue. I say this because especially with .NET, as the .NET has multi-arch base images. When we create containers in the local WSL for local testing we use the ubuntu base image then the command is as below command: ["sh", "-c","apt-get update && apt-get -y install curl && dotnet dapr.state.console.dll && curl -X POST localhost:3500/v1.0/shutdown"]

But when we do the same thing via ArgoCD to the prod, the base image definitions are replaced with the alpine base images to reduce the size of the running container. In that case, the above command will fail as alpine does not have apt. It uses apk package manager. so the command should change as below command: ["/bin/sh", "-c", "apk --no-cache add curl && sleep 20 && curl -X POST localhost:3500/v1.0/shutdown"]

All these complexities are stemming out from the fact that the Shutdown endpoint is not available. if that was available I could call that from the app and could have avoided all these bizarre commands in deployment.yaml

If there is a workaround like getting an handle the Httpclient used by Dapr Client, then we could at least make a call to the shutdown endoint from the application instead of doing in yaml definition

VenkateshSrini avatar Jul 30 '22 02:07 VenkateshSrini

/assign

mcandeia avatar Aug 10 '22 22:08 mcandeia

@mcandeia - I took care of this one yesterday, see the PR referenced above.

halspang avatar Aug 10 '22 22:08 halspang

Totally! My bad, I really missed the assignment above, thanks for the headsup

mcandeia avatar Aug 10 '22 23:08 mcandeia

@halspang could you please let me know when this upgraded nuget package will be available?

VenkateshSrini avatar Aug 11 '22 02:08 VenkateshSrini