Skip to content

Commit e5574a4

Browse files
committed
Install libldap-2.5 explicitly when installing synapse-s3-storage-provider to satisfy its psycopg2 dependency
1 parent 64b3aeb commit e5574a4

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

roles/custom/matrix-synapse/defaults/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ matrix_synapse_container_image_customizations_s3_storage_provider_installation_e
5252
# https://github.com/aws/aws-cli/issues/9214
5353
matrix_synapse_container_image_customizations_s3_storage_provider_installation_old_boto_workaround_enabled: true
5454

55+
# Controls whether to install libldapXX explicitly when installing s3-storage-provider.
56+
# This is to work around it potentially not being there (after `autoremove` invoked by other scripts cleans it up, etc.)
57+
#
58+
# Some scripts in the custom Dockerfile may install and then autoremove git/ssh/openssh-client.
59+
# This has the side-effect of removing the libldap library that s3-storage-provider depends upon indirectly (via psycopg2).
60+
#
61+
# If this should happen, s3-storage-provider (the `s3_media_upload` script) will fail to start with an error like this:
62+
# > Traceback (most recent call last):
63+
# > File "/usr/local/bin/s3_media_upload", line 10, in <module>
64+
# > import psycopg2
65+
# > File "/usr/local/lib/python3.12/site-packages/psycopg2/__init__.py", line 51, in <module>
66+
# > from psycopg2._psycopg import ( # noqa
67+
# > ImportError: libldap-2.5.so.0: cannot open shared object file: No such file or directory
68+
#
69+
# The library (e.g. `/usr/lib/x86_64-linux-gnu/libldap-2.5.so.0`) appears to be available by default in the upstream Synapse image for some reason,
70+
# but it doesn't seem to be installed through a Debian package. Autoremoval would remove it, causing s3-storage-provider to fail.
71+
# Given that this is a dependency for s3-storage-provider (psycopg2), we prefer to install it explicitly.
72+
matrix_synapse_container_image_customizations_s3_storage_provider_installation_explicit_libldap_installation_enabled: true
73+
matrix_synapse_container_image_customizations_s3_storage_provider_installation_explicit_libldap_installation_package_name: libldap-2.5
74+
5575
# Controls whether custom build steps will be added to the Dockerfile for installing auto-accept-invite module.
5676
# The version that will be installed is specified in `matrix_synapse_ext_synapse_auto_accept_invite_version`.
5777
matrix_synapse_container_image_customizations_auto_accept_invite_installation_enabled: "{{ matrix_synapse_ext_synapse_auto_accept_invite_enabled }}"

roles/custom/matrix-synapse/templates/synapse/customizations/Dockerfile.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ RUN pip install 'boto3<1.36.0' 'botocore<1.36.0' synapse-s3-storage-provider=={{
1111
{% else %}
1212
RUN pip install synapse-s3-storage-provider=={{ matrix_synapse_ext_synapse_s3_storage_provider_version }}
1313
{% endif %}
14+
{% if matrix_synapse_container_image_customizations_s3_storage_provider_installation_explicit_libldap_installation_enabled %}
15+
RUN apt-get update && apt-get install --no-install-recommends -y {{ matrix_synapse_container_image_customizations_s3_storage_provider_installation_explicit_libldap_installation_package_name }}
16+
{% endif %}
1417
{% endif %}
1518
1619
{% if matrix_synapse_container_image_customizations_templates_enabled %}

0 commit comments

Comments
 (0)