ml-tooling / contaxy

MIT License
10 stars 8 forks source link

Connect backend to all docker networks of the installation on start up. #19

Closed JNKielmann closed 2 years ago

JNKielmann commented 2 years ago

For each service that is started, a dedicated docker network is created. It includes only the backend and service container. That way the service is isolated on a network level and can only communicate with the backend. After the backend container is recreated (e.g. updating the image), it is no longer part of the networks. This PR checks all networks on first creation of the DockerDeploymentManager and adds the backend back to the networks that belong to the installation.

One issue with this implementation: The reconnection to the networks happens the first time the DockerDeploymentManager is created. As it is created lazily on demand, this would happen after the first service related request. This first request could therefore take more time. To prevent this, the service manager could be created once on server startup to ensure the network reconnection happens.

JNKielmann commented 2 years ago

Thanks for having a look :) I added a get_backend_networks function for listing all networks of the current installation and handle errors. I also added handling of errors during network connection. The error is logged and execution is continued. This way the backend would still start and the missing network connections could be added manually.