OpenMined / PyDentity

A repository for leveraging Self-Sovereign Identity in applications
65 stars 25 forks source link

Properly catching POSIX SIGTERM signal - gracefull pod shutdown from python - Kubernetes #85

Open frogman opened 3 years ago

frogman commented 3 years ago

Description

If we are working towards container implementation (docker, Kubernetes, Openshift etc.) for a good design we would need to create a class that properly kills the PODs, since we want them to be stateless. Python uses here the signal library. Openshift (specially in HA setup) sends the SIGTERM to stop the app/pod/aca-py instance. We would need to properly catch that signal and gracefully stop the instance of aca-py.
We need to deisgn the class as improvement to do any necessary clean up when it receives a SIGTERM and to do it quick. Quick would mean that we need to force existing sessions to be cleaned or transfered to another POD(instance). Because the pods will be stateless we do not need to worry about any local state management, which eases the operation (if we keep the state somewhere Redis/Postgres/queues..)

Are you interested in working on this improvement yourself?

Additional Context

There is an example of a GracefulKiller Python Class in the GIST below using Python Signal library. I guess if we are using aries_controller.py to initialise the aca-py instance, we should add the class to this part of the code. https://gist.github.com/eshleebien/98fc2b90ff4bcd7e3e6ae5ce14f55219#file-medium-terminating-with-grace-py

Cheers.

Z