dotnet-sdk
dotnet-sdk copied to clipboard
No option to shut down the side car
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
ADDRELEASE NOTE:
@VenkateshSrini - Thanks for opening this issue. This does seem to be something we're missing, but it should be easy to add.
@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
/assign
@mcandeia - I took care of this one yesterday, see the PR referenced above.
Totally! My bad, I really missed the assignment above, thanks for the headsup
@halspang could you please let me know when this upgraded nuget package will be available?