Skip to content

Commit

Permalink
CLOUD-4046 Deploy on dual-stack ocp4.8 fails
Browse files Browse the repository at this point in the history
On a dual-stack OpenShift cluster the command 'hostname -i' gives two IPs back. We only need one IP, either IPv4 or IPv6, to build JBOSS_HA_ARGS.
https://issues.redhat.com/browse/CLOUD-4046
  • Loading branch information
buuhsmead authored and hdaems committed Nov 9, 2021
1 parent 4fb0725 commit 4f80dd9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,19 @@ function splitAttributesStringIntoLines() {
local temp
temp=$(echo $input | sed "s|\" ${attribute_name}=\"|\" \n${attribute_name}=\"|g" | awk -F "\"" '{print $2}')
echo "${temp}"
}
}

# Find the ipv4 address of the host
# The host could have 1 or more ipv4 and/or ipv6 addresses
# For this function we need to return a single ipv4 address
function get_host_ipv4() {
mapfile < <(awk '/32 host/ { print f } {f=$2}' <<< "$(</proc/net/fib_trie)" | sort -n | uniq | grep -v '127.0.0.')

if [[ "${#MAPFILE[*]}" != "1" ]]
then
echo "WARNING: get_host_ipv4() returned ${#MAPFILE[*]} ipv4 addresses, only the first ${MAPFILE[0]} will be used. To override this value, please set JBOSS_HA_IP."
fi

echo "${MAPFILE[0]}"
}

2 changes: 1 addition & 1 deletion jboss/container/wildfly/launch/jgroups/added/launch/ha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ generate_dns_ping_config() {

configure_ha_args() {
# Set HA args
IP_ADDR=`hostname -i`
IP_ADDR=$(get_host_ipv4)
JBOSS_HA_ARGS="-b ${JBOSS_HA_IP:-${IP_ADDR}} -bprivate ${JBOSS_HA_IP:-${IP_ADDR}}"

init_node_name
Expand Down
2 changes: 1 addition & 1 deletion jboss/container/wildfly/launch/keycloak/added/keycloak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ function configure_client() {
client_config="${client_config},\"attributes\":{\"saml.signing.certificate\":\"${pem}\"${server_signature}}"
fi
else
service_addr=$(hostname -i)
service_addr=$(get_host_ipv4)
client_config="{\"redirectUris\":[${redirects}]"

if [ -n "$HOSTNAME_HTTP" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function configure() {
}

function configure_artemis_address() {
IP_ADDR=${JBOSS_MESSAGING_HOST:-`hostname -i`}
IP_ADDR=${JBOSS_MESSAGING_HOST:-$(get_host_ipv4)}
JBOSS_MESSAGING_ARGS="${JBOSS_MESSAGING_ARGS} -Djboss.messaging.host=${IP_ADDR}"
}
# /subsystem=messaging-activemq/server=default/jms-queue=queue_name:add(entries=[])
Expand Down

0 comments on commit 4f80dd9

Please sign in to comment.