From c163e2e95e3dd4667bf903711619ace1939b15b2 Mon Sep 17 00:00:00 2001 From: tatankat Date: Thu, 2 Feb 2023 16:44:01 +0100 Subject: [PATCH] [bitnami/openldap] Fix timing issue where openldap is not yet ready (#22112) * Fix timing issue where openldap is not yet ready Signed-off-by: tatankat * Rename is_ldap_answering to is_ldap_ready and doc cleanup Signed-off-by: tatankat * Skip SC2015 as this works as intended Signed-off-by: tatankat --------- Signed-off-by: tatankat --- .../rootfs/opt/bitnami/scripts/libopenldap.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bitnami/openldap/2.6/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh b/bitnami/openldap/2.6/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh index 3b2a650ec888..bcc3f6a65e3d 100644 --- a/bitnami/openldap/2.6/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh +++ b/bitnami/openldap/2.6/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh @@ -150,6 +150,18 @@ ldap_validate() { [[ "$error_code" -eq 0 ]] || exit "$error_code" } +######################## +# Check if OpenLDAP is ready to answer +# Arguments: +# None +# Returns: +# Whether slapd is ready to answer +######################### +is_ldap_ready() { + # shellcheck disable=SC2015 + is_ldap_running && debug_execute ldapsearch -Y EXTERNAL -H "ldapi:///" -b cn=config -s base || false +} + ######################## # Check if OpenLDAP is running # Globals: @@ -197,7 +209,7 @@ ldap_start_bg() { ulimit -n "$LDAP_ULIMIT_NOFILES" am_i_root && flags=("-u" "$LDAP_DAEMON_USER" "${flags[@]}") debug_execute slapd "${flags[@]}" & - if ! retry_while is_ldap_running "$retries" "$sleep_time"; then + if ! retry_while is_ldap_ready "$retries" "$sleep_time"; then error "OpenLDAP failed to start" return 1 fi