ml-tooling / contaxy

MIT License
10 stars 8 forks source link

Stop services if they have not been accessed for a specified idle timeout #58

Closed JNKielmann closed 2 years ago

JNKielmann commented 2 years ago

This PR introduces the idle_timeout setting for services. If a service is not accessed longer than specified in the idle timeout, it will be automatically stopped. For computing the idle time, the last_access_time attribute is used. It is updated automatically when a new session token in generated for the service. That way, it is updated regular as long as the service is in use.

A background task is scheduled that will regularly check all services and stops the ones that are over their idle_timeout. Therefore, the services are not guaranteed to be stopped immediately when they pass their idle timeout. Instead, they will be stopped on the next run of the clean up task. The scheduled interval for this clean up task can be set via the SERVICE_IDLE_CHECK_INTERVAL.

Moreover, the flag clear_volume_on_stop was added to the service. If it is set to true, any attached volumes of the services will be deleted on stop. This allows the creation of services, that completely delete all their data if they idle for too long.

lgtm-com[bot] commented 2 years ago

This pull request introduces 1 alert when merging d9dee664e2616e036c124c9ff9224f95f21ef79e into 44bb7b958ccdda376bc117a48e797bebb1fda750 - view on LGTM.com

new alerts: