cloud-ark / kubeplus

Kubernetes Operator for multi-instance multi-tenancy
https://cloudark.io/
Apache License 2.0
654 stars 78 forks source link

Make Custom Resource Instance delete asynchrounous #1180

Closed devdattakulkarni closed 1 year ago

devdattakulkarni commented 1 year ago

CR instance delete invokes helm delete behind the scene. Sometimes, helm delete can take a long time to finish. In such situations, the mutating webhook times out with the following exception: kubectl delete -f supabase.yaml Error from server (InternalError): error when deleting "supabase-emin.yaml": Internal error occurred: failed calling webhook "platform-as-code.crd-binding.v1": failed to call webhook: Post "https://crd-hook-service.default.svc:443/mutate?timeout=30s": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

The actual helm release does get deleted, but because there was a timeout, the CR instance resource does not get deleted.

One way to address this is to make the CR instance delete asynchronous.

Currently, deleteHelmRelease is a synchronous call. https://github.com/cloud-ark/kubeplus/blob/master/platform-operator/helm-pod/main.go#L334

We should change it to async call (run it as a go co-routine).

cc: @eminalparslan