Skip to content

Commit 3d66450

Browse files
committed
Add 10s timeout to netcat calls
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>
1 parent aa7f951 commit 3d66450

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

bitnami/ksql/7.8/debian-12/rootfs/opt/bitnami/scripts/libksql.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ ksql_wait_for_kafka_brokers() {
181181
if [[ "$b" =~ [_a-zA-Z]*://(.*):([0-9]*) ]]; then
182182
host="${BASH_REMATCH[1]}"
183183
port="${BASH_REMATCH[2]}"
184-
if ! retry_while "debug_execute nc -z ${host} ${port}" 10 10; then
184+
if ! retry_while "debug_execute nc -w 10 -z ${host} ${port}" 10 10; then
185185
error "Failed to connect to the broker at $host:$port"
186186
return 1
187187
fi

bitnami/schema-registry/7.7/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ schema_registry_for_kafka_brokers() {
254254
if [[ "$b" =~ [_a-zA-Z]*://(.*):([0-9]*) ]]; then
255255
host="${BASH_REMATCH[1]}"
256256
port="${BASH_REMATCH[2]}"
257-
if ! retry_while "debug_execute nc -z ${host} ${port}" 10 10; then
257+
if ! retry_while "debug_execute nc -w 10 -z ${host} ${port}" 10 10; then
258258
error "Failed to connect to the broker at $host:$port"
259259
return 1
260260
fi

bitnami/schema-registry/7.8/debian-12/rootfs/opt/bitnami/scripts/libschemaregistry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ schema_registry_for_kafka_brokers() {
254254
if [[ "$b" =~ [_a-zA-Z]*://(.*):([0-9]*) ]]; then
255255
host="${BASH_REMATCH[1]}"
256256
port="${BASH_REMATCH[2]}"
257-
if ! retry_while "debug_execute nc -z ${host} ${port}" 10 10; then
257+
if ! retry_while "debug_execute nc -w 10 -z ${host} ${port}" 10 10; then
258258
error "Failed to connect to the broker at $host:$port"
259259
return 1
260260
fi

bitnami/solr/9/debian-12/rootfs/opt/bitnami/scripts/libsolr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ solr_wait_for_zookeeper() {
162162
host="${BASH_REMATCH[1]}"
163163
port="${BASH_REMATCH[2]}"
164164
debug "Trying: $host:$port"
165-
if ! retry_while "debug_execute nc -z ${host} ${port}" "$SOLR_ZK_MAX_RETRIES" "$SOLR_ZK_SLEEP_TIME"; then
165+
if ! retry_while "debug_execute nc -w 10 -z ${host} ${port}" "$SOLR_ZK_MAX_RETRIES" "$SOLR_ZK_SLEEP_TIME"; then
166166
error "Failed to connect to the zookeeper node at ${host}:${port}"
167167
return 1
168168
fi

0 commit comments

Comments
 (0)