mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 15:21:05 -05:00
Floci's shutdown removed every MWAA environment's Postgres and Airflow containers, with their volumes, and nothing started them again, so after a restart with persistent storage an environment reported AVAILABLE with nothing behind its webserver URL. Shutdown now keeps the volumes while the environments are stored to come back, and Floci keeps the secrets the metadata database was set up with (its password, the Fernet key and the admin password) in a store of its own, which GetEnvironment never returns. Shutdown removes containers by the IDs Floci holds and under the environments' names, so none outlives it, the ones a restore had not reached yet included. At startup each environment reports MAINTENANCE, or CREATING while it was being created, and its containers come back in the background. Containers that outlived Floci are taken over, their secrets read back from the Airflow container. Otherwise new ones start on the kept volumes with the kept secrets, so DAG runs, connections and variables are back, and the startup script and requirements.txt run as at creation. Containers and volumes named before the floci-aws- prefix are found too. The web proxy comes back on the port WebserverUrl names, or on a new one when that port is taken. The first DAG sync after the restore compares the DAG volume with S3, so a DAG deleted while Floci was stopped is removed; the sync reads every page of the S3 listing, so no DAG past the first thousand reads as deleted. The readiness poller reports the environment AVAILABLE once Airflow is healthy, or UNAVAILABLE when a container exits first; one whose containers do not start is UNAVAILABLE, and tried again at the next start. An environment stored before Floci kept the secrets gets them back from a container left under its name, or, with none left, new ones, as its volumes went at the shutdown then; one whose volumes are still there is left UNAVAILABLE rather than started on new ones. Secrets found or given are kept before anything starts. When Docker cannot say which containers or volumes are left, the environment's restore fails, removing nothing. A DeleteEnvironment during the restore leaves the environment DELETING until its containers have started, and the restore then removes it; one still DELETING at the next start is removed then. A start that shutdown overtakes removes its containers. A new environment starts on empty volumes, so it never inherits a database set up with other secrets. Part of #5664.