Skip to content

Commit

Permalink
detect ipv6 stack and apply correct listen address
Browse files Browse the repository at this point in the history
on a dual-stack host (or an ipv6 only host), detect the
ipv6 and ipv4 addresses individually from /etc/hosts and
apply '[::]' as the gmcast_listen address if ipv6 is present.

Fixes: https://issues.redhat.com/browse/OSPRH-3330
  • Loading branch information
zzzeek committed Jan 16, 2024
1 parent 6fb96fd commit 52dd387
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions templates/galera/bin/mysql_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,22 @@ fi
# Generate the mariadb configs from the templates, these will get
# copied by `kolla_start` when the pod's main container will start
PODNAME=$(hostname -f | cut -d. -f1,2)
PODIP=$(grep "${PODNAME}" /etc/hosts | cut -d$'\t' -f1)
PODIPV4=$(grep "${PODNAME}" /etc/hosts | grep -v ':' | cut -d$'\t' -f1)
PODIPV6=$(grep "${PODNAME}" /etc/hosts | grep ':' | cut -d$'\t' -f1)

cd /var/lib/config-data
for cfg in *.cnf.in; do
if [ -s "${cfg}" ]; then
echo "Generating config file from template ${cfg}"

if [[ "" = "${PODIPV6}" ]]; then
PODIP="${PODIPV4}"
IPSTACK="IPV4"
else
PODIP="[::]"
IPSTACK="IPV6"
fi

echo "Generating config file from template ${cfg}, will use ${IPSTACK} listen address of ${PODIP}"
sed -e "s/{ PODNAME }/${PODNAME}/" -e "s/{ PODIP }/${PODIP}/" "/var/lib/config-data/${cfg}" > "/var/lib/pod-config-data/${cfg%.in}"
fi
done

0 comments on commit 52dd387

Please sign in to comment.