From dd26f8a12a94a8f1c76b8a0bd1807bb1ebcb9961 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Wed, 11 Feb 2026 16:50:20 +0200 Subject: [PATCH] Add systemd dependencies to s3-storage-provider-migrate service The migrate service now declares Requires/After on matrix-synapse.service, ensuring Synapse (and its transitive dependencies like Postgres and Docker) are running before the migration triggers. --- roles/custom/matrix-synapse/defaults/main.yml | 8 ++++++++ ...matrix-synapse-s3-storage-provider-migrate.service.j2 | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/roles/custom/matrix-synapse/defaults/main.yml b/roles/custom/matrix-synapse/defaults/main.yml index 90192142f..4866f2b6d 100644 --- a/roles/custom/matrix-synapse/defaults/main.yml +++ b/roles/custom/matrix-synapse/defaults/main.yml @@ -1503,6 +1503,14 @@ matrix_synapse_ext_synapse_s3_storage_provider_update_db_day_count: 0 # This is a systemd timer OnCalendar definition. Learn more here: https://man.archlinux.org/man/systemd.time.7#CALENDAR_EVENTS matrix_synapse_ext_synapse_s3_storage_provider_periodic_migration_schedule: '*-*-* 05:00:00' +# List of systemd services that matrix-synapse-s3-storage-provider-migrate.service requires. +# We only depend on matrix-synapse.service here, because its own dependencies (Postgres, Docker, etc.) +# are transitively resolved by systemd. +matrix_synapse_ext_synapse_s3_storage_provider_migrate_systemd_required_services_list: ['matrix-synapse.service'] + +# List of systemd services that matrix-synapse-s3-storage-provider-migrate.service wants +matrix_synapse_ext_synapse_s3_storage_provider_migrate_systemd_wanted_services_list: [] + # Synapse module to automatically accept room invites. # # Since Synapse v1.109.0 (https://github.com/element-hq/synapse/pull/17147), diff --git a/roles/custom/matrix-synapse/templates/synapse/ext/s3-storage-provider/systemd/matrix-synapse-s3-storage-provider-migrate.service.j2 b/roles/custom/matrix-synapse/templates/synapse/ext/s3-storage-provider/systemd/matrix-synapse-s3-storage-provider-migrate.service.j2 index 626c83857..8b44d852d 100644 --- a/roles/custom/matrix-synapse/templates/synapse/ext/s3-storage-provider/systemd/matrix-synapse-s3-storage-provider-migrate.service.j2 +++ b/roles/custom/matrix-synapse/templates/synapse/ext/s3-storage-provider/systemd/matrix-synapse-s3-storage-provider-migrate.service.j2 @@ -1,5 +1,14 @@ +#jinja2: lstrip_blocks: True [Unit] Description=Migrates locally-stored Synapse media store files to S3 +{% for service in matrix_synapse_ext_synapse_s3_storage_provider_migrate_systemd_required_services_list %} +Requires={{ service }} +After={{ service }} +{% endfor %} +{% for service in matrix_synapse_ext_synapse_s3_storage_provider_migrate_systemd_wanted_services_list %} +Wants={{ service }} +{% endfor %} +DefaultDependencies=no [Service] Type=oneshot