From ee01f555fa664d441bcce259b54a43e46ff17e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Thu, 13 Mar 2025 17:48:09 +0100 Subject: [PATCH] Add configurable timeout to netcat calls with 10s default (#78370) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add configurable timeout to netcat calls with 10s default Without any timeout, netcat can get stuck forever (until Kubernetes kills unhealthy Pod) when configured address and port combination is wrong, or the connection gets stuck. For example `nc -z bitnami.com 12345` doesn't seem to ever finish. In the case when an attempt gets stuck, the timeout will allow further attempts to be performed, instead of waiting until Pod is killed. Signed-off-by: Mateusz MikuĊ‚a --- .../rootfs/opt/bitnami/scripts/ksql-env.sh | 2 + .../rootfs/opt/bitnami/scripts/libksql.sh | 2 +- bitnami/ksql/README.md | 17 ++++--- .../opt/bitnami/scripts/libschemaregistry.sh | 2 +- .../bitnami/scripts/schema-registry-env.sh | 2 + .../opt/bitnami/scripts/libschemaregistry.sh | 2 +- .../bitnami/scripts/schema-registry-env.sh | 2 + bitnami/schema-registry/README.md | 1 + .../rootfs/opt/bitnami/scripts/libsolr.sh | 2 +- .../rootfs/opt/bitnami/scripts/solr-env.sh | 2 + bitnami/solr/README.md | 51 ++++++++++--------- 11 files changed, 48 insertions(+), 37 deletions(-) diff --git a/bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/ksql-env.sh b/bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/ksql-env.sh index 735ca3114ae6..c7d1bfc824c3 100644 --- a/bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/ksql-env.sh +++ b/bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/ksql-env.sh @@ -30,6 +30,7 @@ ksql_env_vars=( KSQL_SSL_TRUSTSTORE_PASSWORD KSQL_CLIENT_AUTHENTICATION KSQL_BOOTSTRAP_SERVERS + KSQL_CONNECTION_ATTEMPT_TIMEOUT ) for env_var in "${ksql_env_vars[@]}"; do file_env_var="${env_var}_FILE" @@ -67,5 +68,6 @@ export KSQL_SSL_KEYSTORE_PASSWORD="${KSQL_SSL_KEYSTORE_PASSWORD:-}" export KSQL_SSL_TRUSTSTORE_PASSWORD="${KSQL_SSL_TRUSTSTORE_PASSWORD:-}" export KSQL_CLIENT_AUTHENTICATION="${KSQL_CLIENT_AUTHENTICATION:-}" export KSQL_BOOTSTRAP_SERVERS="${KSQL_BOOTSTRAP_SERVERS:-}" +export KSQL_CONNECTION_ATTEMPT_TIMEOUT="${KSQL_CONNECTION_ATTEMPT_TIMEOUT:10}" # Custom environment variables may be defined below diff --git a/bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/libksql.sh b/bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/libksql.sh index af7af40ccd21..b4716d473e58 100644 --- a/bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/libksql.sh +++ b/bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/libksql.sh @@ -181,7 +181,7 @@ ksql_wait_for_kafka_brokers() { if [[ "$b" =~ [_a-zA-Z]*://(.*):([0-9]*) ]]; then host="${BASH_REMATCH[1]}" port="${BASH_REMATCH[2]}" - if ! retry_while "debug_execute nc -z ${host} ${port}" 10 10; then + if ! retry_while "debug_execute nc -w $KSQL_CONNECTION_ATTEMPT_TIMEOUT -z ${host} ${port}" 10 10; then error "Failed to connect to the broker at $host:$port" return 1 fi diff --git a/bitnami/ksql/README.md b/bitnami/ksql/README.md index 32c4ab677a86..f279ab05e197 100644 --- a/bitnami/ksql/README.md +++ b/bitnami/ksql/README.md @@ -63,14 +63,15 @@ docker build -t bitnami/APP:latest . ### Customizable environment variables -| Name | Description | Default Value | -|--------------------------------|-----------------------------------------------------------------------------------------------|--------------------------| -| `KSQL_MOUNTED_CONF_DIR` | Directory for including custom configuration files (that override the default generated ones) | `${KSQL_VOLUME_DIR}/etc` | -| `KSQL_LISTENERS` | Comma-separated list of listeners that listen for API requests over either HTTP or HTTPS. | `nil` | -| `KSQL_SSL_KEYSTORE_PASSWORD` | Password to access the SSL keystore. | `nil` | -| `KSQL_SSL_TRUSTSTORE_PASSWORD` | Password to access the SSL truststore. | `nil` | -| `KSQL_CLIENT_AUTHENTICATION` | Client authentication configuration. Valid options: none, requested, over required. | `nil` | -| `KSQL_BOOTSTRAP_SERVERS` | The set of Kafka brokers to bootstrap Kafka cluster information from. | `nil` | +| Name | Description | Default Value | +|-----------------------------------|-----------------------------------------------------------------------------------------------|--------------------------| +| `KSQL_MOUNTED_CONF_DIR` | Directory for including custom configuration files (that override the default generated ones) | `${KSQL_VOLUME_DIR}/etc` | +| `KSQL_LISTENERS` | Comma-separated list of listeners that listen for API requests over either HTTP or HTTPS. | `nil` | +| `KSQL_SSL_KEYSTORE_PASSWORD` | Password to access the SSL keystore. | `nil` | +| `KSQL_SSL_TRUSTSTORE_PASSWORD` | Password to access the SSL truststore. | `nil` | +| `KSQL_CLIENT_AUTHENTICATION` | Client authentication configuration. Valid options: none, requested, over required. | `nil` | +| `KSQL_BOOTSTRAP_SERVERS` | The set of Kafka brokers to bootstrap Kafka cluster information from. | `nil` | +| `KSQL_CONNECTION_ATTEMPT_TIMEOUT` | Timeout in seconds for connection attempts. | `10` | ### Read-only environment variables diff --git a/bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh b/bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh index 16c99f37c54d..814c58bd1202 100644 --- a/bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh +++ b/bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh @@ -254,7 +254,7 @@ schema_registry_for_kafka_brokers() { if [[ "$b" =~ [_a-zA-Z]*://(.*):([0-9]*) ]]; then host="${BASH_REMATCH[1]}" port="${BASH_REMATCH[2]}" - if ! retry_while "debug_execute nc -z ${host} ${port}" 10 10; then + if ! retry_while "debug_execute nc -w $SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT -z ${host} ${port}" 10 10; then error "Failed to connect to the broker at $host:$port" return 1 fi diff --git a/bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/schema-registry-env.sh b/bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/schema-registry-env.sh index d294207a9856..3d243a1f7ba2 100644 --- a/bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/schema-registry-env.sh +++ b/bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/schema-registry-env.sh @@ -40,6 +40,7 @@ schema_registry_env_vars=( SCHEMA_REGISTRY_CLIENT_AUTHENTICATION SCHEMA_REGISTRY_AVRO_COMPATIBILY_LEVEL SCHEMA_REGISTRY_DEBUG + SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT ) for env_var in "${schema_registry_env_vars[@]}"; do file_env_var="${env_var}_FILE" @@ -87,5 +88,6 @@ export SCHEMA_REGISTRY_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM="${SCHEMA_REGISTRY_ export SCHEMA_REGISTRY_CLIENT_AUTHENTICATION="${SCHEMA_REGISTRY_CLIENT_AUTHENTICATION:-}" export SCHEMA_REGISTRY_AVRO_COMPATIBILY_LEVEL="${SCHEMA_REGISTRY_AVRO_COMPATIBILY_LEVEL:-}" export SCHEMA_REGISTRY_DEBUG="${SCHEMA_REGISTRY_DEBUG:-}" +export SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT="${SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT:10}" # Custom environment variables may be defined below diff --git a/bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh b/bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh index 16c99f37c54d..814c58bd1202 100644 --- a/bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh +++ b/bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh @@ -254,7 +254,7 @@ schema_registry_for_kafka_brokers() { if [[ "$b" =~ [_a-zA-Z]*://(.*):([0-9]*) ]]; then host="${BASH_REMATCH[1]}" port="${BASH_REMATCH[2]}" - if ! retry_while "debug_execute nc -z ${host} ${port}" 10 10; then + if ! retry_while "debug_execute nc -w $SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT -z ${host} ${port}" 10 10; then error "Failed to connect to the broker at $host:$port" return 1 fi diff --git a/bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/schema-registry-env.sh b/bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/schema-registry-env.sh index d294207a9856..3d243a1f7ba2 100644 --- a/bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/schema-registry-env.sh +++ b/bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/schema-registry-env.sh @@ -40,6 +40,7 @@ schema_registry_env_vars=( SCHEMA_REGISTRY_CLIENT_AUTHENTICATION SCHEMA_REGISTRY_AVRO_COMPATIBILY_LEVEL SCHEMA_REGISTRY_DEBUG + SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT ) for env_var in "${schema_registry_env_vars[@]}"; do file_env_var="${env_var}_FILE" @@ -87,5 +88,6 @@ export SCHEMA_REGISTRY_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM="${SCHEMA_REGISTRY_ export SCHEMA_REGISTRY_CLIENT_AUTHENTICATION="${SCHEMA_REGISTRY_CLIENT_AUTHENTICATION:-}" export SCHEMA_REGISTRY_AVRO_COMPATIBILY_LEVEL="${SCHEMA_REGISTRY_AVRO_COMPATIBILY_LEVEL:-}" export SCHEMA_REGISTRY_DEBUG="${SCHEMA_REGISTRY_DEBUG:-}" +export SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT="${SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT:10}" # Custom environment variables may be defined below diff --git a/bitnami/schema-registry/README.md b/bitnami/schema-registry/README.md index 052fc3bac45c..245cae2bdf9a 100644 --- a/bitnami/schema-registry/README.md +++ b/bitnami/schema-registry/README.md @@ -84,6 +84,7 @@ docker build -t bitnami/APP:latest . | `SCHEMA_REGISTRY_CLIENT_AUTHENTICATION` | Client authentication configuration. Valid options: none, requested, over required. | `nil` | | `SCHEMA_REGISTRY_AVRO_COMPATIBILY_LEVEL` | The Avro compatibility type. Valid options: none, backward, backward_transitive, forward, forward_transitive, full, or full_transitive | `nil` | | `SCHEMA_REGISTRY_DEBUG` | Enable Schema Registry debug logs. Valid options: true or false | `nil` | +| `SCHEMA_REGISTRY_CONNECTION_ATTEMPT_TIMEOUT` | Timeout for connection attempts in seconds. | `10` | #### Read-only environment variables diff --git a/bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/libsolr.sh b/bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/libsolr.sh index ea751520fbac..776dc738b14b 100644 --- a/bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/libsolr.sh +++ b/bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/libsolr.sh @@ -162,7 +162,7 @@ solr_wait_for_zookeeper() { host="${BASH_REMATCH[1]}" port="${BASH_REMATCH[2]}" debug "Trying: $host:$port" - if ! retry_while "debug_execute nc -z ${host} ${port}" "$SOLR_ZK_MAX_RETRIES" "$SOLR_ZK_SLEEP_TIME"; then + if ! retry_while "debug_execute nc -w $SOLR_ZK_CONNECTION_ATTEMPT_TIMEOUT -z ${host} ${port}" "$SOLR_ZK_MAX_RETRIES" "$SOLR_ZK_SLEEP_TIME"; then error "Failed to connect to the zookeeper node at ${host}:${port}" return 1 fi diff --git a/bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/solr-env.sh b/bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/solr-env.sh index c7cf2fd5dd0a..a41e93f1e8d1 100644 --- a/bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/solr-env.sh +++ b/bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/solr-env.sh @@ -48,6 +48,7 @@ solr_env_vars=( SOLR_ZK_CHROOT SOLR_ZK_HOSTS SOLR_COLLECTION + SOLR_ZK_CONNECTION_ATTEMPT_TIMEOUT ) for env_var in "${solr_env_vars[@]}"; do file_env_var="${env_var}_FILE" @@ -109,5 +110,6 @@ export SOLR_ZK_MAX_RETRIES="${SOLR_ZK_MAX_RETRIES:-5}" export SOLR_ZK_SLEEP_TIME="${SOLR_ZK_SLEEP_TIME:-5}" export SOLR_ZK_CHROOT="${SOLR_ZK_CHROOT:-/solr}" export SOLR_ZK_HOSTS="${SOLR_ZK_HOSTS:-}" +export SOLR_ZK_CONNECTION_ATTEMPT_TIMEOUT="${SOLR_ZK_CONNECTION_ATTEMPT_TIMEOUT:-10}" # Custom environment variables may be defined below diff --git a/bitnami/solr/README.md b/bitnami/solr/README.md index 46531c7abe9f..f0fc63dc0a6d 100644 --- a/bitnami/solr/README.md +++ b/bitnami/solr/README.md @@ -150,31 +150,32 @@ docker-compose up -d #### Customizable environment variables -| Name | Description | Default Value | -|---------------------------------|-------------------------------------------------------------------------------|----------------------------------------------------| -| `SOLR_ENABLE_CLOUD_MODE` | Starts solr in cloud mode | `no` | -| `SOLR_NUMBER_OF_NODES` | Number of nodes of the solr cloud cluster | `1` | -| `SOLR_HOST` | Solr Host name | `nil` | -| `SOLR_JETTY_HOST` | Configuration to listen on a specific IP address or host name | `0.0.0.0` | -| `SOLR_HEAP` | Solr Heap | `nil` | -| `SOLR_SECURITY_MANAGER_ENABLED` | Solr Java security manager | `false` | -| `SOLR_JAVA_MEM` | Solr JVM memory | `-Xms512m -Xmx512m` | -| `SOLR_PORT_NUMBER` | Solr port number | `8983` | -| `SOLR_CORES` | Solr CORE name | `nil` | -| `SOLR_COLLECTION` | Solr COLLECTION name | `nil` | -| `SOLR_COLLECTION_REPLICAS` | Solar collection replicas | `1` | -| `SOLR_COLLECTION_SHARDS` | Solar collection shards | `1` | -| `SOLR_ENABLE_AUTHENTICATION` | Enables authentication | `no` | -| `SOLR_ADMIN_USERNAME` | Administrator Username | `admin` | -| `SOLR_ADMIN_PASSWORD` | Administrator password | `bitnami` | -| `SOLR_CLOUD_BOOTSTRAP` | Indicates if this node is the one that performs the boostraping | `no` | -| `SOLR_CORE_CONF_DIR` | Solar CORE configuration directory | `${SOLR_SERVER_DIR}/solr/configsets/_default/conf` | -| `SOLR_SSL_ENABLED` | Indicates if Solr starts with SSL enabled | `no` | -| `SOLR_SSL_CHECK_PEER_NAME` | Indicates if Solr should check the peer names | `false` | -| `SOLR_ZK_MAX_RETRIES` | Maximum retries when waiting for zookeeper configuration operations to finish | `5` | -| `SOLR_ZK_SLEEP_TIME` | Sleep time when waiting for zookeeper configuration operations to finish | `5` | -| `SOLR_ZK_CHROOT` | ZooKeeper ZNode chroot where to store solr data. Default: /solr | `/solr` | -| `SOLR_ZK_HOSTS` | ZooKeeper nodes (comma-separated list of `host:port`\) | `nil` | +| Name | Description | Default Value | +|--------------------------------------|-------------------------------------------------------------------------------|----------------------------------------------------| +| `SOLR_ENABLE_CLOUD_MODE` | Starts solr in cloud mode | `no` | +| `SOLR_NUMBER_OF_NODES` | Number of nodes of the solr cloud cluster | `1` | +| `SOLR_HOST` | Solr Host name | `nil` | +| `SOLR_JETTY_HOST` | Configuration to listen on a specific IP address or host name | `0.0.0.0` | +| `SOLR_HEAP` | Solr Heap | `nil` | +| `SOLR_SECURITY_MANAGER_ENABLED` | Solr Java security manager | `false` | +| `SOLR_JAVA_MEM` | Solr JVM memory | `-Xms512m -Xmx512m` | +| `SOLR_PORT_NUMBER` | Solr port number | `8983` | +| `SOLR_CORES` | Solr CORE name | `nil` | +| `SOLR_COLLECTION` | Solr COLLECTION name | `nil` | +| `SOLR_COLLECTION_REPLICAS` | Solar collection replicas | `1` | +| `SOLR_COLLECTION_SHARDS` | Solar collection shards | `1` | +| `SOLR_ENABLE_AUTHENTICATION` | Enables authentication | `no` | +| `SOLR_ADMIN_USERNAME` | Administrator Username | `admin` | +| `SOLR_ADMIN_PASSWORD` | Administrator password | `bitnami` | +| `SOLR_CLOUD_BOOTSTRAP` | Indicates if this node is the one that performs the boostraping | `no` | +| `SOLR_CORE_CONF_DIR` | Solar CORE configuration directory | `${SOLR_SERVER_DIR}/solr/configsets/_default/conf` | +| `SOLR_SSL_ENABLED` | Indicates if Solr starts with SSL enabled | `no` | +| `SOLR_SSL_CHECK_PEER_NAME` | Indicates if Solr should check the peer names | `false` | +| `SOLR_ZK_MAX_RETRIES` | Maximum retries when waiting for zookeeper configuration operations to finish | `5` | +| `SOLR_ZK_SLEEP_TIME` | Sleep time when waiting for zookeeper configuration operations to finish | `5` | +| `SOLR_ZK_CHROOT` | ZooKeeper ZNode chroot where to store solr data. Default: /solr | `/solr` | +| `SOLR_ZK_HOSTS` | ZooKeeper nodes (comma-separated list of `host:port`\) | `nil` | +| `SOLR_ZK_CONNECTION_ATTEMPT_TIMEOUT` | ZooKeeper connection attempt timeout in seconds | `10` | #### Read-only environment variables