diff --git a/bitnami/zookeeper/3.9/debian-11/Dockerfile b/bitnami/zookeeper/3.9/debian-11/Dockerfile index 03dfaf1e98dc..d46c028da357 100644 --- a/bitnami/zookeeper/3.9/debian-11/Dockerfile +++ b/bitnami/zookeeper/3.9/debian-11/Dockerfile @@ -7,10 +7,10 @@ ARG TARGETARCH LABEL com.vmware.cp.artifact.flavor="sha256:1e1b4657a77f0d47e9220f0c37b9bf7802581b93214fff7d1bd2364c8bf22e8e" \ org.opencontainers.image.base.name="docker.io/bitnami/minideb:bullseye" \ - org.opencontainers.image.created="2023-12-24T07:56:52Z" \ + org.opencontainers.image.created="2024-01-09T12:07:48Z" \ org.opencontainers.image.description="Application packaged by VMware, Inc" \ org.opencontainers.image.licenses="Apache-2.0" \ - org.opencontainers.image.ref.name="3.9.1-debian-11-r4" \ + org.opencontainers.image.ref.name="3.9.1-debian-11-r5" \ org.opencontainers.image.title="zookeeper" \ org.opencontainers.image.vendor="VMware, Inc." \ org.opencontainers.image.version="3.9.1" diff --git a/bitnami/zookeeper/3.9/debian-11/prebuildfs/usr/sbin/run-script b/bitnami/zookeeper/3.9/debian-11/prebuildfs/usr/sbin/run-script index b7a5bf1e50bf..4ca0f897277e 100755 --- a/bitnami/zookeeper/3.9/debian-11/prebuildfs/usr/sbin/run-script +++ b/bitnami/zookeeper/3.9/debian-11/prebuildfs/usr/sbin/run-script @@ -10,7 +10,7 @@ fi script=$1 exit_code="${2:-96}" -fail_if_not_present="${3:-y}" +fail_if_not_present="${3:-n}" if test -f "$script"; then sh $script diff --git a/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh b/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh index a16c4a0e0351..e0d1aa22825c 100644 --- a/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh +++ b/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/libzookeeper.sh @@ -581,3 +581,50 @@ is_zookeeper_running() { is_zookeeper_not_running() { ! is_zookeeper_running } + +######################## +# Check Zookeeper health +# Globals: +# ZOOKEEPER_* +# Arguments: +# None +# Returns: +# 0 when healthy +# 1 when unhealthy +######################### +zookeeper_healthcheck() { + local command="" + local args=() + local port="$ZOO_PORT_NUMBER" + + if [[ "$ZOO_TLS_CLIENT_ENABLE" = true ]]; then + port="$ZOO_TLS_PORT_NUMBER" + command="openssl" + args+=("s_client" "-quiet" "-crlf" "-connect" "localhost:${port}") + + debug "Running healthcheck command: 'echo \"ruok\" | timeout ${ZOO_HC_TIMEOUT} ${command} ${args[*]} \ + -key <(openssl pkcs12 -in ${ZOO_TLS_CLIENT_KEYSTORE_FILE} -nodes -nocerts -passin pass:\$ZOO_TLS_CLIENT_KEYSTORE_PASSWORD) \ + -cert <(openssl pkcs12 -in ${ZOO_TLS_CLIENT_KEYSTORE_FILE} -nodes -nokeys -passin pass:\$ZOO_TLS_CLIENT_KEYSTORE_PASSWORD)'" + response=$(echo "ruok" | timeout "$ZOO_HC_TIMEOUT" "$command" "${args[@]}" \ + -key <(openssl pkcs12 -in "$ZOO_TLS_CLIENT_KEYSTORE_FILE" -nodes -nocerts -passin pass:"$ZOO_TLS_CLIENT_KEYSTORE_PASSWORD") \ + -cert <(openssl pkcs12 -in "$ZOO_TLS_CLIENT_KEYSTORE_FILE" -nodes -nokeys -passin pass:"$ZOO_TLS_CLIENT_KEYSTORE_PASSWORD") 2> /dev/null + ) + else + command="nc" + # Only add flag '-q' if OpenBSD netcat is used + if nc -help 2>&1 | grep -q "\[-q seconds\]"; then + args+=("-q" "1") + fi + args+=("-w" "$ZOO_HC_TIMEOUT" "localhost" "$port") + debug "Running healthcheck command: 'echo \"ruok\" | timeout ${ZOO_HC_TIMEOUT} ${command} ${args[*]}'" + response=$(echo "ruok" | timeout "$ZOO_HC_TIMEOUT" "$command" "${args[@]}") + fi + + if [[ "$response" =~ "imok" ]]; then + info "Zookeeper healthcheck succeeded" + return 0 + else + error "Zookeeper healthcheck failed." + return 1 + fi +} diff --git a/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh b/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh index 259b4967ebc3..4e525cdabfa3 100644 --- a/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh +++ b/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/zookeeper-env.sh @@ -47,6 +47,7 @@ zookeeper_env_vars=( ZOO_MAX_SESSION_TIMEOUT ZOO_PRE_ALLOC_SIZE ZOO_SNAPCOUNT + ZOO_HC_TIMEOUT ZOO_TLS_CLIENT_ENABLE ZOO_TLS_PORT_NUMBER ZOO_TLS_CLIENT_KEYSTORE_FILE @@ -128,6 +129,7 @@ export ZOO_PROMETHEUS_METRICS_PORT_NUMBER="${ZOO_PROMETHEUS_METRICS_PORT_NUMBER: export ZOO_MAX_SESSION_TIMEOUT="${ZOO_MAX_SESSION_TIMEOUT:-40000}" export ZOO_PRE_ALLOC_SIZE="${ZOO_PRE_ALLOC_SIZE:-65536}" export ZOO_SNAPCOUNT="${ZOO_SNAPCOUNT:-100000}" +export ZOO_HC_TIMEOUT="${ZOO_HC_TIMEOUT:-5}" # ZooKeeper TLS settings export ZOO_TLS_CLIENT_ENABLE="${ZOO_TLS_CLIENT_ENABLE:-false}" diff --git a/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/zookeeper/healthcheck.sh b/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/zookeeper/healthcheck.sh new file mode 100755 index 000000000000..7fa8b3c3ea60 --- /dev/null +++ b/bitnami/zookeeper/3.9/debian-11/rootfs/opt/bitnami/scripts/zookeeper/healthcheck.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Copyright VMware, Inc. +# SPDX-License-Identifier: APACHE-2.0 + +# shellcheck disable=SC1091 + +set -o errexit +set -o nounset +set -o pipefail +# set -o xtrace # Uncomment this line for debugging purposes + +# Load libraries +. /opt/bitnami/scripts/libzookeeper.sh + +# Load Zookeeper environment variables +. /opt/bitnami/scripts/zookeeper-env.sh + +zookeeper_healthcheck