mirror of
https://github.com/bitnami/containers.git
synced 2026-03-20 14:58:20 +08:00
Add configurable timeout to netcat calls with 10s default (#78370)
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 <oss@mateuszmikula.dev>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user